{"thread":{"id":"34062","subject":"[PATCH] t0070: Use precondition CANNOTWRITE","startedAt":"2013-06-08T06:51:15Z","lastAt":"2013-06-08T07:23:22Z","messageCount":2,"participants":["Torsten Bögershausen","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"219784","messageId":"201306080851.17044.tboegi@web.de","threadId":"34062","inReplyTo":null,"subject":"[PATCH] t0070: Use precondition CANNOTWRITE","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2013-06-08T06:51:15Z","receivedAt":"2013-06-08T06:51:15Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"POSIX like file systems allows to create a file when the user has\nwrite permissions to the directory.\n\nFilesystems like VFAT or NTFS allow to create files regardless of\nthe write permissions of the directory.\n\nTherefore \"mktemp to unwritable directory\" in t0700 will always fail on\nWindows using NTFS.\nThis TC has been disabled for MINGW, and needs to be disabled for CYGWIN.\n\nUse the precondition CANNOTWRITE which is probing the file system and\nworks for MINGW, CYGWIN and even for Linux using VFAT.\n\nSigned-off-by: Torsten Bögershausen <tboegi@web.de>\n---\n t/t0070-fundamental.sh | 19 ++++++++++++-------\n t/test-lib.sh          | 12 ++++++++++++\n 2 files changed, 24 insertions(+), 7 deletions(-)\n\ndiff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh\nindex da2c504..a907445 100755\n--- a/t/t0070-fundamental.sh\n+++ b/t/t0070-fundamental.sh\n@@ -17,13 +17,18 @@ test_expect_success 'mktemp to nonexistent directory prints filename' '\n \tgrep \"doesnotexist/test\" err\n '\n \n-test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '\n-\tmkdir cannotwrite &&\n-\tchmod -w cannotwrite &&\n-\ttest_when_finished \"chmod +w cannotwrite\" &&\n-\ttest_must_fail test-mktemp cannotwrite/testXXXXXX 2>err &&\n-\tgrep \"cannotwrite/test\" err\n-'\n+if test_have_prereq CANNOTWRITE\n+then\n+\ttest_expect_success 'mktemp to unwritable directory prints filename' '\n+\t\tmkdir cannotwrite &&\n+\t\tchmod -w cannotwrite &&\n+\t\ttest_when_finished \"chmod +w cannotwrite\" &&\n+\t\ttest_must_fail test-mktemp cannotwrite/testXXXXXX 2>err &&\n+\t\tgrep \"cannotwrite/test\" err\n+\t'\n+else\n+\tsay \"Skipping mktemp to unwritable directory prints filename\"\n+fi\n \n test_expect_success 'check for a bug in the regex routines' '\n \t# if this test fails, re-build git with NO_REGEX=1\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex ca6bdef..1342630 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -770,6 +770,18 @@ test_lazy_prereq AUTOIDENT '\n \tgit var GIT_AUTHOR_IDENT\n '\n \n+test_lazy_prereq CANNOTWRITE '\n+\tchmod -w .\n+\t>e || :\n+\tchmod +w .\n+\tcase \"$(echo *)\" in\n+\te)\n+\t\tfalse ;;\n+\t*)\n+\t\ttrue ;;\n+\tesac\n+'\n+\n # When the tests are run as root, permission tests will report that\n # things are writable when they shouldn't be.\n test -w / || test_set_prereq SANITY\n-- \n1.8.2.411.g65a544e\n"},{"id":"219785","messageId":"51B2DBEA.10205@kdbg.org","threadId":"34062","inReplyTo":"201306080851.17044.tboegi@web.de","subject":"Re: [PATCH] t0070: Use precondition CANNOTWRITE","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2013-06-08T07:23:22Z","receivedAt":"2013-06-08T07:23:22Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 08.06.2013 08:51, schrieb Torsten Bögershausen:\n> Filesystems like VFAT or NTFS allow to create files regardless of\n> the write permissions of the directory.\n> \n> Therefore \"mktemp to unwritable directory\" in t0700 will always fail on\n> Windows using NTFS.\n> This TC has been disabled for MINGW, and needs to be disabled for CYGWIN.\n> \n> Use the precondition CANNOTWRITE which is probing the file system and\n> works for MINGW, CYGWIN and even for Linux using VFAT.\n\nShouldn't it be a matter of\n\n-test_expect_success POSIXPERM 'mktemp to unwritable directory prints filename' '\n+test_expect_success SANITY 'mktemp to unwritable directory prints filename' '\n\nIt probably wouldn't catch Linux VFAT, but there're already a lot of\ntests that don't pass on Linux VFAT.\n\n-- Hannes\n"}]}