git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t0070: Use precondition CANNOTWRITE
@ 2013-06-08  6:51 Torsten Bögershausen
  2013-06-08  7:23 ` Johannes Sixt
  0 siblings, 1 reply; 2+ messages in thread
From: Torsten Bögershausen @ 2013-06-08  6:51 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-08  7:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-08  6:51 [PATCH] t0070: Use precondition CANNOTWRITE Torsten Bögershausen
2013-06-08  7:23 ` Johannes Sixt

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).