[PATCH v3 4/8] test-lib: self-test that --verbose works
- From
Thomas Rast <trast@inf.ethz.ch>
- Date
- Jun 18, 2013, 12:26 UTC
- Message-ID
- <81378a78ec46f876a2b426be99cbb6c3f85498f9.1371557431.git.trast@inf.ethz.ch>
- In-Reply-To
- <cover.1371557431.git.trast@inf.ethz.ch>
t0000 contains some light self-tests of test-lib.sh, but --verbose was not covered. Add a test.
The only catch is that the presence of a test harness influences the output (specifically, the presence of some empty lines). The easiest fix is to unset TEST_HARNESS for the sub-test scripts. This means that we no longer check whether test-lib.sh works under the harness; however, since running everything under 'prove' seems far more common than the esoteric --verbose-only feature introduced in the next commit, this seems the smaller risk.
Signed-off-by: Thomas Rast <trast@inf.ethz.ch> --- t/t0000-basic.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index cefe33d..b568c06 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -47,8 +47,10 @@ test_expect_failure 'pretend we have a known breakage' ' run_sub_test_lib_test () { name="$1" descr="$2" # stdin is the body of the test code + shift 2 mkdir "$name" && ( + unset HARNESS_ACTIVE cd "$name" && cat >"$name.sh" <<-EOF && #!$SHELL_PATH @@ -65,7 +67,7 @@ run_sub_test_lib_test () { cat >>"$name.sh" && chmod +x "$name.sh" && export TEST_DIRECTORY && - ./"$name.sh" >out 2>err + ./"$name.sh" "$@" >out 2>err ) } @@ -215,6 +217,30 @@ test_expect_success 'pretend we have a mix of all possible results' " EOF " +test_expect_success 'test --verbose' ' + test_must_fail run_sub_test_lib_test \ + test-verbose "test verbose" --verbose <<-\EOF && + test_expect_success "passing test" true + test_expect_success "test with output" "echo foo" + test_expect_success "failing test" false + test_done + EOF + check_sub_test_lib_test test-verbose <<-\EOF + > expecting success: true + > ok 1 - passing test + > + > expecting success: echo foo + > foo + > + > ok 2 - test with output + > expecting success: false + > not ok 3 - failing test + > # false + > # failed 1 among 3 test(s) + > 1..3 + EOF +' + test_set_prereq HAVEIT haveit=no test_expect_success HAVEIT 'test runs if prerequisite is satisfied' '
-- 1.8.3.1.530.g6f90e57