Re: [PATCH] t/lib-httpd: switch SANITY check for NOT_ROOT
Junio C Hamano <gitster@pobox.com> writes:
> I think we will later make SANITY to require NOT_ROOT and POSIXPERM,
> at which point many existing tests that require POSIXPERM,SANITY can
> be simplified to require only SANITY, but that will be a follow-up
> change to this fix.
And here is such a follow-up.
-- >8 --
Subject: [PATCH] tests: SANITY requires POSIXPERM
SANITY requires that a file or a directory is indeed accessible (or inaccessible) when its permission bits would say it ought to be accessible (or inaccessible). Running tests as root would lose this prerequisite for obvious reasons, and a test that requires SANITY implies it needs POSIXPERM working.
Redefine SANITY in terms of POSIXPERM and NOT_ROOT and simplify tests that require both to only require SANITY.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
t/t0001-init.sh | 2 +-
t/t0004-unwritable.sh | 8 ++++----
t/t0061-run-command.sh | 2 +-
t/t0070-fundamental.sh | 2 +-
t/t3700-add.sh | 10 +++++-----
t/t4056-diff-order.sh | 2 +-
t/t5537-fetch-shallow.sh | 2 +-
t/t7508-status.sh | 2 +-
t/test-lib.sh | 4 +++-
9 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index e62c0ff..4aa8660 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -261,7 +261,7 @@ test_expect_success 'init notices EEXIST (2)' '
test_path_is_file newdir/a
'
-test_expect_success POSIXPERM,SANITY 'init notices EPERM' '
+test_expect_success SANITY 'init notices EPERM' '
rm -fr newdir &&
mkdir newdir &&
chmod -w newdir &&
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
index e3137d6..d5729d4 100755
--- a/t/t0004-unwritable.sh
+++ b/t/t0004-unwritable.sh
@@ -15,26 +15,26 @@ test_expect_success setup '
'
-test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable repository' '
+test_expect_success SANITY 'write-tree should notice unwritable repository' '
test_when_finished "chmod 775 .git/objects .git/objects/??" &&
chmod a-w .git/objects .git/objects/?? &&
test_must_fail git write-tree
'
-test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
+test_expect_success SANITY 'commit should notice unwritable repository' '
test_when_finished "chmod 775 .git/objects .git/objects/??" &&
chmod a-w .git/objects .git/objects/?? &&
test_must_fail git commit -m second
'
-test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repository' '
+test_expect_success SANITY 'update-index should notice unwritable repository' '
test_when_finished "chmod 775 .git/objects .git/objects/??" &&
echo 6O >file &&
chmod a-w .git/objects .git/objects/?? &&
test_must_fail git update-index file
'
-test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '
+test_expect_success SANITY 'add should notice unwritable repository' '
test_when_finished "chmod 775 .git/objects .git/objects/??" &&
echo b >file &&
chmod a-w .git/objects .git/objects/?? &&
diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh
index 9acf628..52722ee 100755
--- a/t/t0061-run-command.sh
+++ b/t/t0061-run-command.sh
@@ -34,7 +34,7 @@ test_expect_success POSIXPERM 'run_command reports EACCES' '
grep "fatal: cannot exec.*hello.sh" err
'
-test_expect_success POSIXPERM,SANITY 'unreadable directory in PATH' '
+test_expect_success SANITY 'unreadable directory in PATH' '
mkdir local-command &&
test_when_finished "chmod u+rwx local-command && rm -fr local-command" &&
git config alias.nitfol "!echo frotz" &&
diff --git a/t/t0070-fundamental.sh b/t/t0070-fundamental.sh
index 5ed69a6..ccd88e2 100755
--- a/t/t0070-fundamental.sh
+++ b/t/t0070-fundamental.sh
@@ -17,7 +17,7 @@ test_expect_success 'mktemp to nonexistent directory prints filename' '
grep "doesnotexist/test" err
'
-test_expect_success POSIXPERM,SANITY 'mktemp to unwritable directory prints filename' '
+test_expect_success SANITY 'mktemp to unwritable directory prints filename' '
mkdir cannotwrite &&
chmod -w cannotwrite &&
test_when_finished "chmod +w cannotwrite" &&
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index fe274e2..2bc2bcc 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -191,7 +191,7 @@ test_expect_success 'git add --refresh with pathspec' '
grep baz actual
'
-test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' '
+test_expect_success SANITY 'git add should fail atomically upon an unreadable file' '
git reset --hard &&
date >foo1 &&
date >foo2 &&
@@ -202,7 +202,7 @@ test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unr
rm -f foo2
-test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '
+test_expect_success SANITY 'git add --ignore-errors' '
git reset --hard &&
date >foo1 &&
date >foo2 &&
@@ -213,7 +213,7 @@ test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '
rm -f foo2
-test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '
+test_expect_success SANITY 'git add (add.ignore-errors)' '
git config add.ignore-errors 1 &&
git reset --hard &&
date >foo1 &&
@@ -224,7 +224,7 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '
'
rm -f foo2
-test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '
+test_expect_success SANITY 'git add (add.ignore-errors = false)' '
git config add.ignore-errors 0 &&
git reset --hard &&
date >foo1 &&
@@ -235,7 +235,7 @@ test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '
'
rm -f foo2
-test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '
+test_expect_success SANITY '--no-ignore-errors overrides config' '
git config add.ignore-errors 1 &&
git reset --hard &&
date >foo1 &&
diff --git a/t/t4056-diff-order.sh b/t/t4056-diff-order.sh
index c0460bb..b7abfb2 100755
--- a/t/t4056-diff-order.sh
+++ b/t/t4056-diff-order.sh
@@ -62,7 +62,7 @@ test_expect_success 'missing orderfile' '
test_must_fail git diff -Obogus_file --name-only HEAD^..HEAD
'
-test_expect_success POSIXPERM,SANITY 'unreadable orderfile' '
+test_expect_success SANITY 'unreadable orderfile' '
>unreadable_file &&
chmod -r unreadable_file &&
test_must_fail git diff -Ounreadable_file --name-only HEAD^..HEAD
diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
index a980574..56bead1 100755
--- a/t/t5537-fetch-shallow.sh
+++ b/t/t5537-fetch-shallow.sh
@@ -173,7 +173,7 @@ EOF
)
'
-test_expect_success POSIXPERM,SANITY 'shallow fetch from a read-only repo' '
+test_expect_success SANITY 'shallow fetch from a read-only repo' '
cp -R .git read-only.git &&
find read-only.git -print | xargs chmod -w &&
test_when_finished "find read-only.git -type d -print | xargs chmod +w" &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 8ed5788..6037415 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -1035,7 +1035,7 @@ EOF
test_i18ncmp expect output
'
-test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
+test_expect_success SANITY 'status succeeds in a read-only repository' '
(
chmod a-w .git &&
# make dir1/tracked stat-dirty
diff --git a/t/test-lib.sh b/t/test-lib.sh
index b2b2ec7..37d1b0e 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -999,7 +999,9 @@ test_lazy_prereq NOT_ROOT '
# 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
+test_lazy_prereq SANITY '
+ test_have_prereq POSIXPERM,NOT_ROOT
+'
GIT_UNZIP=${GIT_UNZIP:-unzip}
test_lazy_prereq UNZIP '
--
2.3.0-rc0-149-g0286818
--
--
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.
You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en
---
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.