* tests/test/test-file.sh: Check that -nt and -ot work properly when files may or may not exist. --- tests/test/test-file.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/tests/test/test-file.sh b/tests/test/test-file.sh index 0bc917348..469f5ca9b 100755 --- a/tests/test/test-file.sh +++ b/tests/test/test-file.sh @@ -37,4 +37,25 @@ returns_ 1 env test -c file || fail=1 returns_ 1 env test -b file || fail=1 returns_ 1 env test -p file || fail=1 +# Check that 'test' returns true if the file name following "-nt" does not +# resolve. +env test file -nt missing || fail=1 +returns_ 1 env test missing -nt file || fail=1 + +# Check that 'test' returns true if the file name preceding "-ot" does not +# resolve. +env test missing -ot file || fail=1 +returns_ 1 env test file -ot missing || fail=1 + +# At this point the "newfile" should have a later timestamp than "file". +touch newfile || framework_failure_ + +# Test "-nt" on two existing files. +env test newfile -nt file || fail=1 +returns_ 1 env test file -nt newfile || fail=1 + +# Test "-ot" on two existing files. +env test file -ot newfile || fail=1 +returns_ 1 env test newfile -ot file || fail=1 + Exit $fail -- 2.51.1
