diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-05-22 08:03:52 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-05-22 08:03:52 +0200 |
commit | 5a791d140e3033dbe47301fc324f8282ba182459 (patch) | |
tree | 3c8e72135deb31192f1c9f0411ae7495bdec9a1e /tests/function | |
parent | e416c54b985832c25f0e7861a3c295303ffb9da1 (diff) |
Add $filesystem.file_exists(), $filesystem.directory_exists()
Diffstat (limited to 'tests/function')
-rw-r--r-- | tests/function/filesystem/testscript | 48 | ||||
-rw-r--r-- | tests/function/path/testscript | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/function/filesystem/testscript b/tests/function/filesystem/testscript index cf93b8b..c7c08f1 100644 --- a/tests/function/filesystem/testscript +++ b/tests/function/filesystem/testscript @@ -73,3 +73,51 @@ EOE } } + +: file_exists +: +{ + : file + : + touch f; + $* <'print $file_exists(f)' >'true' + + : symlink + : + touch f && ln -s f s; + $* <'print $file_exists([path] s)' >'true' + + : directory + : + mkdir d; + $* <'print $file_exists([dir_path] d)' >'false' + + : testscript + : + touch f; + echo $file_exists(f) >'true' +} + +: directory_exists +: +{ + : directory + : + mkdir d; + $* <'print $directory_exists(d)' >'true' + + : symlink + : + mkdir d && ln -s d s; + $* <'print $directory_exists([dir_path] d)' >'true' + + : file + : + touch f; + $* <'print $directory_exists([path] f)' >'false' + + : testscript + : + mkdir d; + echo $directory_exists(d) >'true' +} diff --git a/tests/function/path/testscript b/tests/function/path/testscript index d49e9e5..6321b3d 100644 --- a/tests/function/path/testscript +++ b/tests/function/path/testscript @@ -210,6 +210,8 @@ s = ($posix ? '/' : '\') $* <'print $complete([path] a)' >"$~$(s)a" : path $* <'print $complete([dir_path] a)' >"$~$(s)a$(s)" : dir-path $* <'print $path.complete(a)' >"$~$(s)a" : untyped + + echo $path.complete(a) > "$~$(s)a" : testscript } : canonicalize |