* various fixes to the test library
@ 2009-06-01 12:14 Clemens Buchacher
2009-06-01 12:14 ` [PATCH 1/3] test-lib: fail if invalid options are passed Clemens Buchacher
0 siblings, 1 reply; 5+ messages in thread
From: Clemens Buchacher @ 2009-06-01 12:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
If a http test failed, and the test was run with --immediate, the cleanup code
would not be executed and stale web server instance were left behind. This is
fixed by 2/3.
Clemens
[PATCH 1/3] test-lib: fail if invalid options are passed
[PATCH 2/3] test-lib: allow exit trap to be used for cleanup by tests
[PATCH 3/3] test-lib: fix http exit codes
t/lib-httpd.sh | 6 ++++--
t/test-lib.sh | 23 +++++++++++++++--------
2 files changed, 19 insertions(+), 10 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] test-lib: fail if invalid options are passed
2009-06-01 12:14 various fixes to the test library Clemens Buchacher
@ 2009-06-01 12:14 ` Clemens Buchacher
2009-06-01 12:14 ` [PATCH 2/3] test-lib: allow exit trap to be used for cleanup by tests Clemens Buchacher
0 siblings, 1 reply; 5+ messages in thread
From: Clemens Buchacher @ 2009-06-01 12:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Clemens Buchacher
Previously, unknown options would be ignored, including any subsequent
valid options.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
t/test-lib.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index dad1437..6e83ceb 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -115,7 +115,7 @@ do
--tee)
shift ;; # was handled already
*)
- break ;;
+ echo "error: unknown test option '$1'" >&2; exit 1 ;;
esac
done
--
1.6.3.1.147.g637c3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] test-lib: allow exit trap to be used for cleanup by tests
2009-06-01 12:14 ` [PATCH 1/3] test-lib: fail if invalid options are passed Clemens Buchacher
@ 2009-06-01 12:14 ` Clemens Buchacher
2009-06-01 12:14 ` [PATCH 3/3] test-lib: fix http exit codes Clemens Buchacher
0 siblings, 1 reply; 5+ messages in thread
From: Clemens Buchacher @ 2009-06-01 12:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Clemens Buchacher
Exit trap should not be removed in case tests require cleanup code. This
is especially important if tests are executed with the --immediate option.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
t/test-lib.sh | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 6e83ceb..5fdc5d9 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -147,7 +147,7 @@ fi
error () {
say_color error "error: $*"
- trap - EXIT
+ GIT_EXIT_OK=t
exit 1
}
@@ -179,10 +179,17 @@ test_broken=0
test_success=0
die () {
- echo >&5 "FATAL: Unexpected exit with code $?"
- exit 1
+ code=$?
+ if test -n "$GIT_EXIT_OK"
+ then
+ exit $code
+ else
+ echo >&5 "FATAL: Unexpected exit with code $code"
+ exit 1
+ fi
}
+GIT_EXIT_OK=
trap 'die' EXIT
# The semantics of the editor variables are that of invoking
@@ -285,7 +292,7 @@ test_failure_ () {
say_color error "FAIL $test_count: $1"
shift
echo "$@" | sed -e 's/^/ /'
- test "$immediate" = "" || { trap - EXIT; exit 1; }
+ test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }
}
test_known_broken_ok_ () {
@@ -347,7 +354,7 @@ test_expect_failure () {
then
test_known_broken_ok_ "$1"
else
- test_known_broken_failure_ "$1"
+ test_known_broken_failure_ "$1"
fi
fi
echo >&3 ""
@@ -498,7 +505,7 @@ test_create_repo () {
}
test_done () {
- trap - EXIT
+ GIT_EXIT_OK=t
test_results_dir="$TEST_DIRECTORY/test-results"
mkdir -p "$test_results_dir"
test_results_path="$test_results_dir/${0%.sh}-$$"
@@ -640,7 +647,7 @@ fi
test="trash directory.$(basename "$0" .sh)"
test ! -z "$debug" || remove_trash="$TEST_DIRECTORY/$test"
rm -fr "$test" || {
- trap - EXIT
+ GIT_EXIT_OK=t
echo >&5 "FATAL: Cannot prepare test area"
exit 1
}
--
1.6.3.1.147.g637c3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] test-lib: fix http exit codes
2009-06-01 12:14 ` [PATCH 2/3] test-lib: allow exit trap to be used for cleanup by tests Clemens Buchacher
@ 2009-06-01 12:14 ` Clemens Buchacher
2009-06-01 12:28 ` [PATCH 3/3 v2] " Clemens Buchacher
0 siblings, 1 reply; 5+ messages in thread
From: Clemens Buchacher @ 2009-06-01 12:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Clemens Buchacher
Previously, die() would report the exit code of stop_httpd. Instead,
save the exit code and pass it to die() explicitly.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
t/lib-httpd.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index cde659d..6765b08 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -93,14 +93,16 @@ prepare_httpd() {
start_httpd() {
prepare_httpd >&3 2>&4
- trap 'stop_httpd; die' EXIT
+ trap 'code=$?; stop_httpd; (exit $code); die' EXIT
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
>&3 2>&4
- if ! test $? = 0; then
+ if test $? -ne 0
+ then
say "skipping test, web server setup failed"
+ trap 'die' EXIT
test_done
fi
}
--
1.6.3.1.147.g637c3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 3/3 v2] test-lib: fix http exit codes
2009-06-01 12:14 ` [PATCH 3/3] test-lib: fix http exit codes Clemens Buchacher
@ 2009-06-01 12:28 ` Clemens Buchacher
0 siblings, 0 replies; 5+ messages in thread
From: Clemens Buchacher @ 2009-06-01 12:28 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Previously, die() would report the exit code of stop_httpd. Instead,
save and reset the exit code before dying.
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
---
On Mon, Jun 01, 2009 at 02:14:42PM +0200, Clemens Buchacher wrote:
> Previously, die() would report the exit code of stop_httpd. Instead,
> save the exit code and pass it to die() explicitly.
Oops, I forgot to fix the commit message. (I tried to pass the exit code to
die() explicitly, but then I realized that this is much easier.)
Clemens
t/lib-httpd.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index cde659d..6765b08 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -93,14 +93,16 @@ prepare_httpd() {
start_httpd() {
prepare_httpd >&3 2>&4
- trap 'stop_httpd; die' EXIT
+ trap 'code=$?; stop_httpd; (exit $code); die' EXIT
"$LIB_HTTPD_PATH" -d "$HTTPD_ROOT_PATH" \
-f "$TEST_PATH/apache.conf" $HTTPD_PARA \
-c "Listen 127.0.0.1:$LIB_HTTPD_PORT" -k start \
>&3 2>&4
- if ! test $? = 0; then
+ if test $? -ne 0
+ then
say "skipping test, web server setup failed"
+ trap 'die' EXIT
test_done
fi
}
--
1.6.3.1.147.g637c3
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-01 12:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-01 12:14 various fixes to the test library Clemens Buchacher
2009-06-01 12:14 ` [PATCH 1/3] test-lib: fail if invalid options are passed Clemens Buchacher
2009-06-01 12:14 ` [PATCH 2/3] test-lib: allow exit trap to be used for cleanup by tests Clemens Buchacher
2009-06-01 12:14 ` [PATCH 3/3] test-lib: fix http exit codes Clemens Buchacher
2009-06-01 12:28 ` [PATCH 3/3 v2] " Clemens Buchacher
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).