From: Jan-Marek Glogowski <glogow@fbihome.de>
To: git@vger.kernel.org
Cc: Jan-Marek Glogowski <glogow@fbihome.de>
Subject: [PATCH] Prefix shell test output messages with test id
Date: Thu, 6 Sep 2012 13:45:21 +0200 [thread overview]
Message-ID: <1346931921-5901-1-git-send-email-glogow@fbihome.de> (raw)
This adds the test ID (tXXXX) prefix to the test result message of
all shell tests. This is especially useful when doing a parallel
check run, where it's currently quite hard to identify the actual
failing test case.
Signed-off-by: Jan-Marek Glogowski <glogow@fbihome.de>
---
t/t0000-basic.sh | 28 ++++++++++++++--------------
t/test-lib-functions.sh | 11 +++++++----
t/test-lib.sh | 10 ++++++----
3 Dateien geändert, 27 Zeilen hinzugefügt(+), 22 Zeilen entfernt(-)
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index ccb5435..1bbf5b8 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -58,7 +58,7 @@ test_expect_failure 'pretend we have a known breakage' '
test_expect_success 'pretend we have fixed a known breakage (run in sub test-lib)' "
mkdir passing-todo &&
(cd passing-todo &&
- cat >passing-todo.sh <<-EOF &&
+ cat >0000t05-passing-todo.sh <<-EOF &&
#!$SHELL_PATH
test_description='A passing TODO test
@@ -77,14 +77,14 @@ test_expect_success 'pretend we have fixed a known breakage (run in sub test-lib
test_done
EOF
- chmod +x passing-todo.sh &&
- ./passing-todo.sh >out 2>err &&
+ chmod +x 0000t05-passing-todo.sh &&
+ ./0000t05-passing-todo.sh >out 2>err &&
! test -s err &&
sed -e 's/^> //' >expect <<-\\EOF &&
- > ok 1 - pretend we have fixed a known breakage # TODO known breakage
- > # fixed 1 known breakage(s)
- > # passed all 1 test(s)
- > 1..1
+ > 0000t05: ok 1 - pretend we have fixed a known breakage # TODO known breakage
+ > 0000t05: # fixed 1 known breakage(s)
+ > 0000t05: # passed all 1 test(s)
+ > 0000t05: 1..1
EOF
test_cmp expect out)
"
@@ -141,7 +141,7 @@ test_expect_success 'tests clean up even on failures' "
(
cd failing-cleanup &&
- cat >failing-cleanup.sh <<-EOF &&
+ cat >0000t12-failing-cleanup.sh <<-EOF &&
#!$SHELL_PATH
test_description='Failing tests with cleanup commands'
@@ -162,23 +162,23 @@ test_expect_success 'tests clean up even on failures' "
EOF
- chmod +x failing-cleanup.sh &&
- test_must_fail ./failing-cleanup.sh >out 2>err &&
+ chmod +x 0000t12-failing-cleanup.sh &&
+ test_must_fail ./0000t12-failing-cleanup.sh >out 2>err &&
! test -s err &&
! test -f \"trash directory.failing-cleanup/clean-after-failure\" &&
sed -e 's/Z$//' -e 's/^> //' >expect <<-\\EOF &&
- > not ok - 1 tests clean up even after a failure
+ > 0000t12: not ok 1 - tests clean up even after a failure
> # Z
> # touch clean-after-failure &&
> # test_when_finished rm clean-after-failure &&
> # (exit 1)
> # Z
- > not ok - 2 failure to clean up causes the test to fail
+ > 0000t12: not ok 2 - failure to clean up causes the test to fail
> # Z
> # test_when_finished \"(exit 2)\"
> # Z
- > # failed 2 among 2 test(s)
- > 1..2
+ > 0000t12: # failed 2 among 2 test(s)
+ > 0000t12: 1..2
EOF
test_cmp expect out
)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 9bc57d2..c81ad7f 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -24,6 +24,9 @@
#
# In particular, quoting isn't enough, as the path may contain the same quote
# that we're using.
+
+TID=$(basename ${0%%-*})
+
test_set_editor () {
FAKE_EDITOR="$1"
export FAKE_EDITOR
@@ -434,7 +437,7 @@ test_external_without_stderr () {
test_path_is_file () {
if ! [ -f "$1" ]
then
- echo "File $1 doesn't exist. $*"
+ echo "$TID: File $1 doesn't exist. $*"
false
fi
}
@@ -442,7 +445,7 @@ test_path_is_file () {
test_path_is_dir () {
if ! [ -d "$1" ]
then
- echo "Directory $1 doesn't exist. $*"
+ echo "$TID: Directory $1 doesn't exist. $*"
false
fi
}
@@ -450,7 +453,7 @@ test_path_is_dir () {
test_path_is_missing () {
if [ -e "$1" ]
then
- echo "Path exists:"
+ echo "$TID: Path exists:"
ls -ld "$1"
if [ $# -ge 1 ]; then
echo "$*"
@@ -476,7 +479,7 @@ test_line_count () {
error "bug in the test script: not 3 parameters to test_line_count"
elif ! test $(wc -l <"$3") "$1" "$2"
then
- echo "test_line_count: line count for $3 !$1 $2"
+ echo "$TID: test_line_count: line count for $3 !$1 $2"
cat "$3"
return 1
fi
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 78c4286..6fccbe9 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -31,6 +31,8 @@ done,*)
;;
esac
+TID=$(basename ${0%%-*})
+
# Keep the original TERM for say_color
ORIGINAL_TERM=$TERM
@@ -185,7 +187,7 @@ if test -n "$color"; then
*) test -n "$quiet" && return;;
esac
shift
- printf "%s" "$*"
+ printf "$TID: %s" "$*"
tput sgr0
echo
)
@@ -194,12 +196,12 @@ else
say_color() {
test -z "$1" && test -n "$quiet" && return
shift
- echo "$*"
+ echo "$TID: $*"
}
fi
error () {
- say_color error "error: $*"
+ say_color error "$TID: error: $*"
GIT_EXIT_OK=t
exit 1
}
@@ -262,7 +264,7 @@ test_ok_ () {
test_failure_ () {
test_failure=$(($test_failure + 1))
- say_color error "not ok - $test_count $1"
+ say_color error "not ok $test_count - $1"
shift
echo "$@" | sed -e 's/^/# /'
test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
--
1.7.11.5
next reply other threads:[~2012-09-06 11:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 11:45 Jan-Marek Glogowski [this message]
2012-09-06 12:34 ` [PATCH] Prefix shell test output messages with test id Thomas Gummerer
2012-09-06 15:10 ` Jeff King
2012-09-06 20:29 ` Jan-Marek Glogowski
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=1346931921-5901-1-git-send-email-glogow@fbihome.de \
--to=glogow@fbihome.de \
--cc=git@vger.kernel.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).