aboutsummaryrefslogtreecommitdiff
path: root/t/test-lib.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-03-24 14:42:50 -0700
committerJunio C Hamano <gitster@pobox.com>2009-03-24 14:42:50 -0700
commit78360b576acb0ee47c90552cb3f976a3c6ba4d6a (patch)
treee0128da2b0290c7eba533afc506e312b0676de1c /t/test-lib.sh
parentedbc25c5b377d6fe768cefcc8614cd254a9fc4ff (diff)
parent28baf82ea359d9f2579fd3a7e7e2e5e2bd5da2a9 (diff)
downloadgit-78360b576acb0ee47c90552cb3f976a3c6ba4d6a.tar.gz
git-78360b576acb0ee47c90552cb3f976a3c6ba4d6a.tar.xz
Merge branch 'js/windows-tests'
* js/windows-tests: t0060: fix whitespace in "wc -c" invocation t5503: GIT_DEBUG_SEND_PACK is not supported on MinGW t7004: Use prerequisite tags to skip tests that need gpg Use prerequisites to skip tests that need unzip t3700: Skip a test with backslashes in pathspec Skip tests that require a filesystem that obeys POSIX permissions t0060: Fix tests on Windows Use prerequisite tags to skip tests that depend on symbolic links t9100, t9129: Use prerequisite tags for UTF-8 tests t5302: Use prerequisite tags to skip 64-bit offset tests Skip tests that fail if the executable bit is not handled by the filesystem t3600: Use test prerequisite tags test-lib: Infrastructure to test and check for prerequisites t0050: Check whether git init detected symbolic link support correctly Tests on Windows: $(pwd) must return Windows-style paths test-lib: Work around missing sum on Windows test-lib: Work around incompatible sort and find on Windows Conflicts: t/t3000-ls-files-others.sh
Diffstat (limited to 't/test-lib.sh')
-rw-r--r--t/test-lib.sh74
1 files changed, 69 insertions, 5 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 7ff75644c..8de5ee1b5 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -247,6 +247,31 @@ test_chmod () {
git update-index --add "--chmod=$@"
}
+# Use test_set_prereq to tell that a particular prerequisite is available.
+# The prerequisite can later be checked for in two ways:
+#
+# - Explicitly using test_have_prereq.
+#
+# - Implicitly by specifying the prerequisite tag in the calls to
+# test_expect_{success,failure,code}.
+#
+# The single parameter is the prerequisite tag (a simple word, in all
+# capital letters by convention).
+
+test_set_prereq () {
+ satisfied="$satisfied$1 "
+}
+satisfied=" "
+
+test_have_prereq () {
+ case $satisfied in
+ *" $1 "*)
+ : yes, have it ;;
+ *)
+ ! : nope ;;
+ esac
+}
+
# You are not expected to call test_ok_ and test_failure_ directly, use
# the text_expect_* functions instead.
@@ -293,6 +318,11 @@ test_skip () {
to_skip=t
esac
done
+ if test -z "$to_skip" && test -n "$prereq" &&
+ ! test_have_prereq "$prereq"
+ then
+ to_skip=t
+ fi
case "$to_skip" in
t)
say_color skip >&3 "skipping test: $@"
@@ -306,8 +336,9 @@ test_skip () {
}
test_expect_failure () {
+ test "$#" = 3 && { prereq=$1; shift; } || prereq=
test "$#" = 2 ||
- error "bug in the test script: not 2 parameters to test-expect-failure"
+ error "bug in the test script: not 2 or 3 parameters to test-expect-failure"
if ! test_skip "$@"
then
say >&3 "checking known breakage: $2"
@@ -323,8 +354,9 @@ test_expect_failure () {
}
test_expect_success () {
+ test "$#" = 3 && { prereq=$1; shift; } || prereq=
test "$#" = 2 ||
- error "bug in the test script: not 2 parameters to test-expect-success"
+ error "bug in the test script: not 2 or 3 parameters to test-expect-success"
if ! test_skip "$@"
then
say >&3 "expecting success: $2"
@@ -340,8 +372,9 @@ test_expect_success () {
}
test_expect_code () {
+ test "$#" = 4 && { prereq=$1; shift; } || prereq=
test "$#" = 3 ||
- error "bug in the test script: not 3 parameters to test-expect-code"
+ error "bug in the test script: not 3 or 4 parameters to test-expect-code"
if ! test_skip "$@"
then
say >&3 "expecting exit code $1: $3"
@@ -365,8 +398,9 @@ test_expect_code () {
# Usage: test_external description command arguments...
# Example: test_external 'Perl API' perl ../path/to/test.pl
test_external () {
- test "$#" -eq 3 ||
- error >&5 "bug in the test script: not 3 parameters to test_external"
+ test "$#" = 4 && { prereq=$1; shift; } || prereq=
+ test "$#" = 3 ||
+ error >&5 "bug in the test script: not 3 or 4 parameters to test_external"
descr="$1"
shift
if ! test_skip "$descr" "$@"
@@ -643,3 +677,33 @@ do
test_done
esac
done
+
+# Fix some commands on Windows
+case $(uname -s) in
+*MINGW*)
+ # Windows has its own (incompatible) sort and find
+ sort () {
+ /usr/bin/sort "$@"
+ }
+ find () {
+ /usr/bin/find "$@"
+ }
+ sum () {
+ md5sum "$@"
+ }
+ # git sees Windows-style pwd
+ pwd () {
+ builtin pwd -W
+ }
+ # no POSIX permissions
+ # backslashes in pathspec are converted to '/'
+ ;;
+*)
+ test_set_prereq POSIXPERM
+ test_set_prereq BSLASHPSPEC
+ ;;
+esac
+
+# 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