From 5a791d140e3033dbe47301fc324f8282ba182459 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 22 May 2024 08:03:52 +0200 Subject: Add $filesystem.file_exists(), $filesystem.directory_exists() --- tests/function/filesystem/testscript | 48 ++++++++++++++++++++++++++++++++++++ tests/function/path/testscript | 2 ++ 2 files changed, 50 insertions(+) (limited to 'tests/function') 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 -- cgit v1.1