add tests for file module predicates
reproduce failing `directory_exists/1` with working directory passed as first argument reproduce failing `delete_directory/1` with ./test directory passed as first argument reproduce failing `file_size/1` with 2 bytes files passed as first argument reproduce failing `file_exists/1` with existing file passed as first argument reproduce failing `file_modification_time/1`, `file_access_time/1` and `file_creation_time/1` with existing file passed as first argument reproduce failing `directory_files/2` with existing directory passed as first argument reproduce failing `delete_file/1` with existing file passed as first argument reproduce failing `make_directory/1` with non-existing directory passed as first argument reproduce failing `make_directory_path/1` with non-existing path passed as first argument reproduce failing `path_canonical/2` with non-canonical path passed as first argument reproduce failing `rename_file/2` with existing file passed as first argument, target file as second arg revised `directory_exists/1` test case renamed test files, test directories use `path_segments/2`, remove path separators do not write file size to current output revised `directory_files/2` test revised `path_canonical/2` test revised `file_exists/1` test removed hardcoded expected size extracted hardcoded directory argument remove path prefix containing path separator revised expected ls cmd exit code so that it is platform-agnostic Signed-off-by: Thierry Marianne <thierry@marianne.io>
This commit is contained in:
36
tests-pl/issue_file_copy.pl
Normal file
36
tests-pl/issue_file_copy.pl
Normal file
@@ -0,0 +1,36 @@
|
||||
:- use_module(library(files)).
|
||||
:- use_module(library(iso_ext)).
|
||||
:- use_module(library(lists)).
|
||||
:- use_module(library(os), [setenv/2, getenv/2, shell/2]).
|
||||
|
||||
check :-
|
||||
act(Source, Destination),
|
||||
ground(Source),
|
||||
ground(Destination).
|
||||
|
||||
act(Source, Destination) :-
|
||||
getenv("SOURCE", Source),
|
||||
getenv("DESTINATION", Destination),
|
||||
append("ls ", Source, Cmd),
|
||||
shell(Cmd, 0),
|
||||
file_copy(Source, Destination),
|
||||
append("ls ", Destination, Cmd),
|
||||
\+ shell(Cmd, 0),
|
||||
throw(existence_error(directory,Destination)).
|
||||
act(Source, Destination) :-
|
||||
getenv("SOURCE", Source),
|
||||
getenv("DESTINATION", Destination),
|
||||
append("ls ", Destination, Cmd),
|
||||
shell(Cmd, 0),
|
||||
write(file_copied).
|
||||
|
||||
main :-
|
||||
call_cleanup(
|
||||
(setenv("SOURCE", "file_copy_test_source"),
|
||||
setenv("DESTINATION", "file_copy_test_destination"),
|
||||
shell("touch file_copy_test_source", 0),
|
||||
check),
|
||||
shell("rm -f file_copy_test_source file_copy_test_destination", 0)
|
||||
).
|
||||
|
||||
:- initialization(main).
|
||||
Reference in New Issue
Block a user