t0070: Use precondition CANNOTWRITE
PATCH 1/1 t0070: Use precondition CANNOTWRITE
POSIX like file systems allows to create a file when the user has write permissions to the directory.
Filesystems like VFAT or NTFS allow to create files regardless of the write permissions of the directory.
Therefore "mktemp to unwritable directory" in t0700 will always fail on Windows using NTFS.
This TC has been disabled for MINGW, and needs to be disabled for CYGWIN.
Use the precondition CANNOTWRITE which is probing the file system and works for MINGW, CYGWIN and even for Linux using VFAT.
--- t/t0070-fundamental.sh | 19 ++++++++++++------- t/test-lib.sh | 12 ++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-)
t/t0070-fundamental.sh +12 -7
@@ -17,13 +17,18 @@ test_expect_success 'mktemp to nonexistent directory prints filename' ' grep "doesnotexist/test" err ' -test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' ' - mkdir cannotwrite && - chmod -w cannotwrite && - test_when_finished "chmod +w cannotwrite" && - test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err && - grep "cannotwrite/test" err -' +if test_have_prereq CANNOTWRITE +then + test_expect_success 'mktemp to unwritable directory prints filename' ' + mkdir cannotwrite && + chmod -w cannotwrite && + test_when_finished "chmod +w cannotwrite" && + test_must_fail test-mktemp cannotwrite/testXXXXXX 2>err && + grep "cannotwrite/test" err + ' +else + say "Skipping mktemp to unwritable directory prints filename" +fi test_expect_success 'check for a bug in the regex routines' ' # if this test fails, re-build git with NO_REGEX=1
t/test-lib.sh +12 -0
@@ -770,6 +770,18 @@ test_lazy_prereq AUTOIDENT ' git var GIT_AUTHOR_IDENT ' +test_lazy_prereq CANNOTWRITE ' + chmod -w . + >e || : + chmod +w . + case "$(echo *)" in + e) + false ;; + *) + true ;; + esac +' + # When the tests are run as root, permission tests will report that # things are writable when they shouldn't be. test -w / || test_set_prereq SANITY
Signature · 1 line
1.8.2.411.g65a544e
Am 08.06.2013 08:51, schrieb Torsten Bögershausen:
Quoted 9 lines
Filesystems like VFAT or NTFS allow to create files regardless of the write permissions of the directory.
Therefore "mktemp to unwritable directory" in t0700 will always fail on Windows using NTFS.
This TC has been disabled for MINGW, and needs to be disabled for CYGWIN.Use the precondition CANNOTWRITE which is probing the file system and works for MINGW, CYGWIN and even for Linux using VFAT.
Shouldn't it be a matter of
-test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' ' +test_expect_success SANITY 'mktemp to unwritable directory prints filename' '
It probably wouldn't catch Linux VFAT, but there're already a lot of tests that don't pass on Linux VFAT.
-- Hannes