summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: be53dee)
raw | patch | inline | side by side (parent: be53dee)
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | |
Fri, 6 Aug 2010 22:09:09 +0000 (22:09 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 18 Aug 2010 19:42:04 +0000 (12:42 -0700) |
Some tests depend on not being able to write to files after chmod
-w. This doesn't work when running the tests as root.
Change test-lib.sh to test if this works, and if so it sets a new
SANITY test prerequisite. The tests that use this previously failed
when run under root.
There was already a test for this in t3600-rm.sh, added by Junio C
Hamano in 2283645 in 2006. That check now uses the new SANITY
prerequisite.
Some of this was resurrected from the "Tests in Cygwin" thread in May
2009:
http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118385
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-w. This doesn't work when running the tests as root.
Change test-lib.sh to test if this works, and if so it sets a new
SANITY test prerequisite. The tests that use this previously failed
when run under root.
There was already a test for this in t3600-rm.sh, added by Junio C
Hamano in 2283645 in 2006. That check now uses the new SANITY
prerequisite.
Some of this was resurrected from the "Tests in Cygwin" thread in May
2009:
http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118385
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/t/README b/t/README
index dc07939375c416d73c503cf1134d0706107e5ad6..28effb44372a5115bd138ac37b18efd4906b5bb4 100644 (file)
--- a/t/README
+++ b/t/README
The filesystem we're on supports symbolic links. E.g. a FAT
filesystem doesn't support these. See 704a3143 for details.
+ - SANITY
+
+ Test is not run by root user, and an attempt to write to an
+ unwritable file is expected to fail correctly.
+
Tips for Writing Tests
----------------------
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 7c0a698b92696ff2bbb91e65e0a42e87f9163a1d..7a7599987abebd953c385594691a9f04aefa41fa 100755 (executable)
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
)
'
-test_expect_success POSIXPERM 'init notices EPERM' '
+test_expect_success POSIXPERM,SANITY 'init notices EPERM' '
rm -fr newdir &&
(
mkdir newdir &&
diff --git a/t/t0004-unwritable.sh b/t/t0004-unwritable.sh
index 2342ac5788a9976b591cb78593279f092d1dc2f6..385b1265de53829053bae40f111a0bf30004b98b 100755 (executable)
--- a/t/t0004-unwritable.sh
+++ b/t/t0004-unwritable.sh
'
-test_expect_success POSIXPERM 'write-tree should notice unwritable repository' '
+test_expect_success POSIXPERM,SANITY 'write-tree should notice unwritable repository' '
(
chmod a-w .git/objects .git/objects/?? &&
'
-test_expect_success POSIXPERM 'commit should notice unwritable repository' '
+test_expect_success POSIXPERM,SANITY 'commit should notice unwritable repository' '
(
chmod a-w .git/objects .git/objects/?? &&
'
-test_expect_success POSIXPERM 'update-index should notice unwritable repository' '
+test_expect_success POSIXPERM,SANITY 'update-index should notice unwritable repository' '
(
echo 6O >file &&
'
-test_expect_success POSIXPERM 'add should notice unwritable repository' '
+test_expect_success POSIXPERM,SANITY 'add should notice unwritable repository' '
(
echo b >file &&
index f19b4a2a4afa89fd1242d1acccb1e999e6a88c6d..eb8e3d447613ce7383f53a7a09039c01d72f35ef 100755 (executable)
'
-test_expect_success SYMLINKS 'funny symlink in work tree, un-unlink-able' '
+test_expect_success SYMLINKS,SANITY 'funny symlink in work tree, un-unlink-able' '
rm -fr a b &&
git reset --hard &&
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index b514cbb60665fef9d5cd67b8f7bcd8e8a3c2d0a5..b26cabd571503696a2bfa356e4f6ac46febf74ba 100755 (executable)
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
git commit -m 'add files with tabs and newlines'
"
-# Determine rm behavior
-# Later we will try removing an unremovable path to make sure
-# git rm barfs, but if the test is run as root that cannot be
-# arranged.
-: >test-file
-chmod a-w .
-rm -f test-file 2>/dev/null
-if test -f test-file
-then
- test_set_prereq RO_DIR
-else
- skip_all='skipping removal failure test (perhaps running as root?)'
-fi
-chmod 775 .
-rm -f test-file
-
test_expect_success \
'Pre-check that foo exists and is in index before git rm foo' \
'[ -f foo ] && git ls-files --error-unmatch foo'
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 7d7140db380225bfffd3b64c125e2599b6be77c2..ec7108358e7b7f54f0b5e7530c8368e4a56576af 100755 (executable)
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
test -z "`git diff-index HEAD -- foo`"
'
-test_expect_success POSIXPERM 'git add should fail atomically upon an unreadable file' '
+test_expect_success POSIXPERM,SANITY 'git add should fail atomically upon an unreadable file' '
git reset --hard &&
date >foo1 &&
date >foo2 &&
@@ -190,7 +190,7 @@ test_expect_success POSIXPERM 'git add should fail atomically upon an unreadable
rm -f foo2
-test_expect_success POSIXPERM 'git add --ignore-errors' '
+test_expect_success POSIXPERM,SANITY 'git add --ignore-errors' '
git reset --hard &&
date >foo1 &&
date >foo2 &&
rm -f foo2
-test_expect_success POSIXPERM 'git add (add.ignore-errors)' '
+test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors)' '
git config add.ignore-errors 1 &&
git reset --hard &&
date >foo1 &&
'
rm -f foo2
-test_expect_success POSIXPERM 'git add (add.ignore-errors = false)' '
+test_expect_success POSIXPERM,SANITY 'git add (add.ignore-errors = false)' '
git config add.ignore-errors 0 &&
git reset --hard &&
date >foo1 &&
'
rm -f foo2
-test_expect_success POSIXPERM '--no-ignore-errors overrides config' '
+test_expect_success POSIXPERM,SANITY '--no-ignore-errors overrides config' '
git config add.ignore-errors 1 &&
git reset --hard &&
date >foo1 &&
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh
index 7d8ed68befed0e85ad85f9f933a2b887125e38e8..fe8abf6fd9e15fe0812d70a7e6faca2c26219352 100755 (executable)
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
'
-test_expect_success 'removal failure' '
+test_expect_success SANITY 'removal failure' '
mkdir foo &&
touch foo/bar &&
(exec <foo/bar &&
chmod 0 foo &&
- test_must_fail git clean -f -d)
-
+ test_must_fail git clean -f -d &&
+ chmod 755 foo)
'
-chmod 755 foo
test_expect_success 'nested git work tree' '
rm -fr foo bar &&
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index a72fe3ae640378350102a07124aee201fb1c637b..ee0e57352dc7a0d1e28952842a4a5b6d4cd2fdf9 100755 (executable)
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
test_cmp expect output
'
-test_expect_success POSIXPERM 'status succeeds in a read-only repository' '
+test_expect_success POSIXPERM,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 9ded0eee18e7479b0674a7bce217de46744b1dff..78c4874465c8713c5306c9d3ec708ebfc2c63be5 100644 (file)
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
# test whether the filesystem supports symbolic links
ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
rm -f y
+
+# 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