From: Junio C Hamano <gitster@pobox.com>
To: Don Slutz <Don.Slutz@SierraAtlantic.com>
Cc: Hannu Koivisto <azure@iki.fi>,
git@vger.kernel.org, Johannes Sixt <j6t@kdbg.org>
Subject: Re: Tests in Cygwin
Date: Wed, 06 May 2009 13:42:27 -0700 [thread overview]
Message-ID: <7vvdoet13g.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4A01E64C.7050703@SierraAtlantic.com> (Don Slutz's message of "Wed\, 06 May 2009 15\:34\:36 -0400")
Don Slutz <Don.Slutz@SierraAtlantic.com> writes:
> A lot of these failures are do to running as root (member of
> Administrators)....
Perhaps we can do this to reduce the noise level.
---
t/README | 26 +++++++++++++++++++++++---
t/t1004-read-tree-m-u-wf.sh | 2 +-
t/t7300-clean.sh | 2 +-
t/test-lib.sh | 22 +++++++++++++++-------
4 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/t/README b/t/README
index d8f6c7d..a532c32 100644
--- a/t/README
+++ b/t/README
@@ -194,19 +194,28 @@ Test harness library
There are a handful helper functions defined in the test harness
library for your script to use.
- - test_expect_success <message> <script>
+ - test_expect_success [<prereq>] <message> <script>
- This takes two strings as parameter, and evaluates the
+ This takes two or three strings as parameters, and evaluates the
<script>. If it yields success, test is considered
successful. <message> should state what it is testing.
+ An optional parameter <prereq> is a space separated list of prerequisite
+ tokens. The test will be skipped if the test environment lacks any of
+ the prerequiste feature listed (see below for commonly used
+ prerequisites).
+
Example:
test_expect_success \
'git-write-tree should be able to write an empty tree.' \
'tree=$(git-write-tree)'
- - test_expect_failure <message> <script>
+ test_expect_success SANITY '/ should not be writable' '
+ ! test -w /
+ '
+
+ - test_expect_failure [<prereq>] <message> <script>
This is NOT the opposite of test_expect_success, but is used
to mark a test that demonstrates a known breakage. Unlike
@@ -247,6 +256,17 @@ library for your script to use.
Merges the given rev using the given message. Like test_commit,
creates a tag and calls test_tick before committing.
+Prerequisites
+-------------
+
+ POSIXPERM The filesystem supports POSIX style permission bits
+ BSLASHPSPEC ???
+ EXECKEEPSPID The process retains the same pid across exec(2)
+
+ SANITY Test is not run by root user, and an attempt to an
+ unwritable file is expected to fail correctly.
+
+
Tips for Writing Tests
----------------------
diff --git a/t/t1004-read-tree-m-u-wf.sh b/t/t1004-read-tree-m-u-wf.sh
index f19b4a2..eb60f80 100755
--- a/t/t1004-read-tree-m-u-wf.sh
+++ b/t/t1004-read-tree-m-u-wf.sh
@@ -177,7 +177,7 @@ test_expect_success SYMLINKS 'funny symlink in work tree' '
'
-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/t7300-clean.sh b/t/t7300-clean.sh
index 929d5d4..7a5f680 100755
--- a/t/t7300-clean.sh
+++ b/t/t7300-clean.sh
@@ -369,7 +369,7 @@ test_expect_success 'core.excludesfile' '
'
-test_expect_success 'removal failure' '
+test_expect_success SANITY 'removal failure' '
mkdir foo &&
touch foo/bar &&
diff --git a/t/test-lib.sh b/t/test-lib.sh
index dad1437..1922e0b 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -264,12 +264,16 @@ test_set_prereq () {
satisfied=" "
test_have_prereq () {
- case $satisfied in
- *" $1 "*)
- : yes, have it ;;
- *)
- ! : nope ;;
- esac
+ for prerequisite
+ do
+ case $satisfied in
+ *" $prerequisite "*)
+ : yes, have it ;;
+ *)
+ return 1 ;;
+ esac
+ done
+ :
}
# You are not expected to call test_ok_ and test_failure_ directly, use
@@ -670,6 +674,10 @@ do
esac
done
+# When tests are run as root (which is silly), permission
+# tests will report things are writable when they should not be.
+test -w / || test_set_prereq SANITY
+
# Fix some commands on Windows
case $(uname -s) in
*MINGW*)
@@ -692,7 +700,7 @@ case $(uname -s) in
# exec does not inherit the PID
;;
*)
- test_set_prereq POSIXPERM
+ test_have_prereq SANITY && test_set_prereq POSIXPERM
test_set_prereq BSLASHPSPEC
test_set_prereq EXECKEEPSPID
;;
next prev parent reply other threads:[~2009-05-06 20:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-17 9:47 Tests in Cygwin Hannu Koivisto
2009-05-06 19:34 ` Don Slutz
2009-05-06 20:42 ` Junio C Hamano [this message]
2009-05-07 7:13 ` Johannes Sixt
2009-05-07 15:47 ` Don Slutz
2009-05-07 18:29 ` Don Slutz
2009-05-08 0:02 ` Junio C Hamano
2009-05-08 6:03 ` Johannes Sixt
2009-05-08 2:00 ` Jeff King
2009-05-08 6:02 ` Johannes Sixt
2009-05-08 6:41 ` Junio C Hamano
2009-05-08 9:28 ` Alex Riesen
2009-05-08 14:19 ` Don Slutz
2009-05-08 14:28 ` Johannes Sixt
2009-05-08 16:45 ` Alex Riesen
2009-05-08 0:00 ` Junio C Hamano
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=7vvdoet13g.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Don.Slutz@SierraAtlantic.com \
--cc=azure@iki.fi \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.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).