diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_exec_nonexistent.out | 19 | ||||
-rw-r--r-- | tests/test_exec_plus_nonexistent.out | 19 | ||||
-rw-r--r-- | tests/test_execdir_nonexistent.out | 19 | ||||
-rw-r--r-- | tests/test_execdir_plus_nonexistent.out | 19 | ||||
-rwxr-xr-x | tests/tests.sh | 40 |
5 files changed, 116 insertions, 0 deletions
diff --git a/tests/test_exec_nonexistent.out b/tests/test_exec_nonexistent.out new file mode 100644 index 0000000..a7ccfe4 --- /dev/null +++ b/tests/test_exec_nonexistent.out @@ -0,0 +1,19 @@ +basic +basic/a +basic/b +basic/c +basic/c/d +basic/e +basic/e/f +basic/g +basic/g/h +basic/i +basic/j +basic/j/foo +basic/k +basic/k/foo +basic/k/foo/bar +basic/l +basic/l/foo +basic/l/foo/bar +basic/l/foo/bar/baz diff --git a/tests/test_exec_plus_nonexistent.out b/tests/test_exec_plus_nonexistent.out new file mode 100644 index 0000000..a7ccfe4 --- /dev/null +++ b/tests/test_exec_plus_nonexistent.out @@ -0,0 +1,19 @@ +basic +basic/a +basic/b +basic/c +basic/c/d +basic/e +basic/e/f +basic/g +basic/g/h +basic/i +basic/j +basic/j/foo +basic/k +basic/k/foo +basic/k/foo/bar +basic/l +basic/l/foo +basic/l/foo/bar +basic/l/foo/bar/baz diff --git a/tests/test_execdir_nonexistent.out b/tests/test_execdir_nonexistent.out new file mode 100644 index 0000000..a7ccfe4 --- /dev/null +++ b/tests/test_execdir_nonexistent.out @@ -0,0 +1,19 @@ +basic +basic/a +basic/b +basic/c +basic/c/d +basic/e +basic/e/f +basic/g +basic/g/h +basic/i +basic/j +basic/j/foo +basic/k +basic/k/foo +basic/k/foo/bar +basic/l +basic/l/foo +basic/l/foo/bar +basic/l/foo/bar/baz diff --git a/tests/test_execdir_plus_nonexistent.out b/tests/test_execdir_plus_nonexistent.out new file mode 100644 index 0000000..a7ccfe4 --- /dev/null +++ b/tests/test_execdir_plus_nonexistent.out @@ -0,0 +1,19 @@ +basic +basic/a +basic/b +basic/c +basic/c/d +basic/e +basic/e/f +basic/g +basic/g/h +basic/i +basic/j +basic/j/foo +basic/k +basic/k/foo +basic/k/foo/bar +basic/l +basic/l/foo +basic/l/foo/bar +basic/l/foo/bar/baz diff --git a/tests/tests.sh b/tests/tests.sh index 8c65c72..64bd04d 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -262,8 +262,10 @@ posix_tests=( test_L_depth test_exec + test_exec_nonexistent test_exec_nopath test_exec_plus + test_exec_plus_nonexistent test_exec_plus_status test_exec_plus_semicolon @@ -401,6 +403,7 @@ bsd_tests=( test_exec_substring + test_execdir_nonexistent test_execdir_pwd test_execdir_slash test_execdir_slash_pwd @@ -559,6 +562,7 @@ gnu_tests=( test_exec_plus_flush_fail test_execdir + test_execdir_nonexistent test_execdir_substring test_execdir_plus_semicolon test_execdir_pwd @@ -822,6 +826,7 @@ bfs_tests=( test_exec_flush_fprint_fail test_execdir_plus + test_execdir_plus_nonexistent test_fprint_duplicate_stdout test_fprint_error_stdout @@ -1770,6 +1775,17 @@ function test_exec() { bfs_diff basic -exec echo {} \; } +function test_exec_nonexistent() { + # Failure to execute the command should lead to an error message and + # non-zero exit status. See https://unix.stackexchange.com/q/704522/56202 + + local stderr=$(invoke_bfs basic -exec "$TESTS/nonexistent" {} \; 2>&1 >/dev/null) + [ -n "$stderr" ] || return 1 + + bfs_diff basic -print -exec "$TESTS/nonexistent" {} \; -print + (($? == EX_BFS)) +} + function test_exec_nopath() { ( unset PATH @@ -1789,6 +1805,14 @@ function test_exec_plus() { bfs_diff basic -exec "$TESTS/sort-args.sh" {} + } +function test_exec_plus_nonexistent() { + local stderr=$(invoke_bfs basic -exec "$TESTS/nonexistent" {} + 2>&1 >/dev/null) + [ -n "$stderr" ] || return 1 + + bfs_diff basic -exec "$TESTS/nonexistent" {} + -print + (($? == EX_BFS)) +} + function test_exec_plus_status() { # -exec ... {} + should always return true, but if the command fails, bfs # should exit with a non-zero status @@ -1845,6 +1869,14 @@ function test_execdir() { bfs_diff basic -execdir echo {} \; } +function test_execdir_nonexistent() { + local stderr=$(invoke_bfs basic -execdir "$TESTS/nonexistent" {} \; 2>&1 >/dev/null) + [ -n "$stderr" ] || return 1 + + bfs_diff basic -print -execdir "$TESTS/nonexistent" {} \; -print + (($? == EX_BFS)) +} + function test_execdir_plus() { local tree=$(invoke_bfs -D tree 2>&1 -quit) @@ -1855,6 +1887,14 @@ function test_execdir_plus() { bfs_diff basic -execdir "$TESTS/sort-args.sh" {} + } +function test_execdir_plus_nonexistent() { + local stderr=$(invoke_bfs basic -execdir "$TESTS/nonexistent" {} + 2>&1 >/dev/null) + [ -n "$stderr" ] || return 1 + + bfs_diff basic -execdir "$TESTS/nonexistent" {} + -print + (($? == EX_BFS)) +} + function test_execdir_substring() { bfs_diff basic -execdir echo '-{}-' \; } |