From: "Torsten Bögershausen" <tboegi@web.de>
To: git@vger.kernel.org
Subject: [PATCH] t0070: Use precondition CANNOTWRITE
Date: Sat, 8 Jun 2013 08:51:15 +0200 [thread overview]
Message-ID: <201306080851.17044.tboegi@web.de> (raw)
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.
Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
t/t0070-fundamental.sh | 19 ++++++++++++-------
t/test-lib.sh | 12 ++++++++++++
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index da2c504..a907445 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -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
diff --git a/t/test-lib.sh b/t/test-lib.sh
index ca6bdef..1342630 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -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
--
1.8.2.411.g65a544e
next reply other threads:[~2013-06-08 6:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-08 6:51 Torsten Bögershausen [this message]
2013-06-08 7:23 ` [PATCH] t0070: Use precondition CANNOTWRITE Johannes Sixt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201306080851.17044.tboegi@web.de \
--to=tboegi@web.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).