diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-02 23:25:02 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-03-02 23:25:02 +0300 |
commit | 3045a5709df597526f474aa0c5a583a76d9921db (patch) | |
tree | 2748f8219f1f2abb837305935aead2370894636c /tests/path-entry | |
parent | 4e56a2167c1091dd65b041a36bfd2b8307bafd0a (diff) |
Backup
Diffstat (limited to 'tests/path-entry')
-rw-r--r-- | tests/path-entry/driver.cxx | 22 | ||||
-rw-r--r-- | tests/path-entry/testscript | 9 |
2 files changed, 28 insertions, 3 deletions
diff --git a/tests/path-entry/driver.cxx b/tests/path-entry/driver.cxx index d48bf49..e4dddf3 100644 --- a/tests/path-entry/driver.cxx +++ b/tests/path-entry/driver.cxx @@ -25,20 +25,36 @@ import butl.filesystem; using namespace std; using namespace butl; -// Usage: argv[0] <path> +// Usage: argv[0] [-l] <path> // // If path entry exists then print it's type and size (meaningful for the // regular file only) to STDOUT, and exit with the zero code. Otherwise exit // with the one code. Don't follow symlink. On failure print the error // description to STDERR and exit with the two code. // +// -l +// Follow symlinks. +// int main (int argc, const char* argv[]) try { - assert (argc == 2); + bool follow_symlinks (false); + + int i (1); + for (; i != argc; ++i) + { + string v (argv[i]); + + if (v == "-l") + follow_symlinks = true; + else + break; + } + + assert (i == argc - 1); - auto es (path_entry (argv[1])); + auto es (path_entry (argv[i], follow_symlinks)); if (!es.first) return 1; diff --git a/tests/path-entry/testscript b/tests/path-entry/testscript index 456f96f..35b6f6f 100644 --- a/tests/path-entry/testscript +++ b/tests/path-entry/testscript @@ -25,6 +25,15 @@ directory /. EOO + + : followed-symlink + : + cat <:'abc' >=f; + ln -s f l; + $* -l l >>EOO + regular + 3 + EOO } : non-existent |