From: Stephan Beyer <s-beyer@gmx.net>
To: git@vger.kernel.org
Cc: Stephan Beyer <s-beyer@gmx.net>
Subject: [HACK] t/test-lib.sh HACK: Add -s/--show-hack to test suite.
Date: Sun, 6 Jul 2008 22:22:31 +0200 [thread overview]
Message-ID: <1215375751-30853-1-git-send-email-s-beyer@gmx.net> (raw)
This option realizes a stupid hack that tries to run the test
cases line by line (separated by &&).
Furthermore it shows the line it is testing.
With that information it is easier to find the reason
why a test fails.
This hack works as long as there are no multi-line
for/while/subshell/... in the test cases.
Note, that the -s option should only be used if a test case failed.
It is slow and error-prone.
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
---
Hi,
I wrote that before I started to make the sequencer prototype and
then I used this hack more than expected ;-)
Today I cherry-picked this commit into another branch and then
I thought this could be useful for others, too.
(Explicitly not for inclusion!)
So how to use it?
When running a test case in t/, add the -s option and then it shows
something like this:
--snip--[...]
-------
Testing:
! test -d "$SEQDIR"
-------
Testing:
session_ok
* FAIL 3: "pick", "squash", "ref" from stdin
next_session squashCE &&
valgrind git sequencer <todotest1 &&
! test -d "$SEQDIR" &&
session_ok &&
test -f file2 &&
test -f file3 &&
test $(git rev-parse CE) = $(git rev-parse HEAD) &&
test $(git rev-parse I) = $(git rev-parse HEAD^)
--snap--
Because of the "Testing:" lines you can explicitly see where it failed.
Regards,
Stephan
t/test-lib.sh | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 43 insertions(+), 2 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index c0c5e0e..6f42106 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -86,6 +86,8 @@ do
help=t; shift ;;
-v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
verbose=t; shift ;;
+ -s|--show-hack)
+ verbose=t; show_hack=t; immediate=t; shift ;;
-q|--q|--qu|--qui|--quie|--quiet)
quiet=t; shift ;;
--no-color)
@@ -225,9 +227,48 @@ test_debug () {
test "$debug" = "" || eval "$1"
}
-test_run_ () {
- eval >&3 2>&4 "$1"
+test_run__ () {
+ eval "$1"
eval_ret="$?"
+}
+
+test_run_op_ () {
+ echo "Testing:"
+ printf "%s\n" "$op_"
+ echo
+ eval "$op_"
+ eval_ret="$?"
+}
+
+test_run_hack_ () {
+ i_=1
+ j_=1
+ total_=$(printf '%s' "$1" | wc -l)
+ while test "$j_" -lt $(expr "$total_" + 1)
+ do
+ op_=$(printf '%s' "$1" | sed -n -e "$i_,$j_ p")
+ if test -n "$(printf '%s' "$op_" | sed -n -e '/<<[-\\ A-Za-z]/q;/&& *$/p;')"
+ then
+ i_=$(expr "$j_" + 1)
+ op_=$(printf '%s' "$op_" | sed -e 's/ *&& *$//')
+ test_run_op_
+ test "$eval_ret" -ne 0 && return 0
+ echo -------
+ fi
+ j_=$(expr "$j_" + 1)
+ done
+ op_="$(printf '%s' "$1" | sed -n -e "$i_,$j_ p")"
+ test_run_op_
+ return 0
+}
+
+test_run_ () {
+ if test -z "$show_hack"
+ then
+ test_run__ >&3 2>&4 "$1"
+ else
+ test_run_hack_ >&3 2>&4 "$1"
+ fi
return 0
}
--
1.5.6.363.g7ba71
next reply other threads:[~2008-07-06 20:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-06 20:22 Stephan Beyer [this message]
2008-07-06 20:41 ` [HACK] t/test-lib.sh HACK: Add -s/--show-hack to test suite Johannes Schindelin
2008-07-07 14:08 ` Stephan Beyer
2008-07-07 14:41 ` Johannes Schindelin
2008-07-12 22:22 ` Stephan Beyer
2008-07-13 0:25 ` Johannes Schindelin
2008-07-13 11:09 ` Stephan Beyer
2008-07-13 13:21 ` Johannes Schindelin
2008-07-21 1:24 ` Stephan Beyer
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=1215375751-30853-1-git-send-email-s-beyer@gmx.net \
--to=s-beyer@gmx.net \
--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).