diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2011-08-25 12:44:32 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2011-08-25 13:56:11 +0200 |
commit | 33d456f2f6387bc2ead8fbe16d67a77edc0336eb (patch) | |
tree | 6797f09c246b0ef47c5bc84eceef124b51b7717b /lib/tap-driver.sh | |
parent | aba3010e83194e2172006059db08f4fd5992f021 (diff) | |
download | automake-33d456f2f6387bc2ead8fbe16d67a77edc0336eb.tar.gz |
tap: improve syncing between awk+shell and perl implementations
* lib/tap-driver.pl (stringify_test_result): Renamed ...
(stringify_result_obj): ... to this. Break up a clause in the
long "if/elsif/.../else" construct to avoid unaesthetic line
breaks and to be more synced with the sibling function in
`tap-driver.sh'. Rename the `$result', `$PASS' and `$FAIL'
variables to respectively `$result_obj', `$COOKED_PASS' and
`$COOKED_FAIL', for clarity and better syncing.
(handle_tap_test): Renamed ...
(handle_tap_result): ... to this, and change the name of the
`$test' local variable to `$result_obj'.
(extract_comment): Reimplement using the simpler `index' and
`substr' builtins, rather than with more advanced uses of
regular expressions.
(%test_results, @test_results): Renamed respectively ...
(%test_results_seen, @test_results_list): ... to these, and
related adjustments throughout the `TEST_RESULTS' block.
(main, get_global_test_result): Refactor and do some cosmetic
changes to make these functions clearer and better synced with
sibling code in `tap-driver.sh'.
Other minor cosmetic and typo fixes.
* lib/tap-driver.sh (extract_tap_comment): Remove outdated
"FIXME" comments.
(get_global_test_result): Small reordering to make it better
synced with its sibling function in `tap-driver.pl'.
(stringify_result_obj): Consistently use `result_obj' as the
parameter name.
Other minor cosmetic and typo fixes.
Diffstat (limited to 'lib/tap-driver.sh')
-rwxr-xr-x | lib/tap-driver.sh | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh index 16a4e0418..535bc2b9b 100755 --- a/lib/tap-driver.sh +++ b/lib/tap-driver.sh @@ -23,7 +23,7 @@ # bugs to <bug-automake@gnu.org> or send patches to # <automake-patches@gnu.org>. -scriptversion=2011-08-24.09; # UTC +scriptversion=2011-08-25.10; # UTC # Make unconditional expansion of undefined variables an error. This # helps a lot in preventing typo-related bugs. @@ -195,35 +195,35 @@ function get_global_test_result() { if ("ERROR" in test_results_seen) return "ERROR" + if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) + return "FAIL" all_skipped = 1 for (k in test_results_seen) if (k != "SKIP") all_skipped = 0 if (all_skipped) return "SKIP" - if ("FAIL" in test_results_seen || "XPASS" in test_results_seen) - return "FAIL" return "PASS"; } -function stringify_result_obj(obj) +function stringify_result_obj(result_obj) { - if (obj["is_unplanned"] || obj["number"] != testno) + if (result_obj["is_unplanned"] || result_obj["number"] != testno) return "ERROR" if (plan_seen == LATE_PLAN) return "ERROR" if (result_obj["directive"] == "TODO") - return obj["is_ok"] ? "XPASS" : "XFAIL" + return result_obj["is_ok"] ? "XPASS" : "XFAIL" if (result_obj["directive"] == "SKIP") - return obj["is_ok"] ? "SKIP" : COOKED_FAIL; + return result_obj["is_ok"] ? "SKIP" : COOKED_FAIL; if (length(result_obj["directive"])) abort("in function stringify_result_obj()") - return obj["is_ok"] ? COOKED_PASS : COOKED_FAIL + return result_obj["is_ok"] ? COOKED_PASS : COOKED_FAIL } function decorate_result(result) @@ -294,7 +294,7 @@ function handle_tap_result() report(stringify_result_obj(result_obj), details) } -# `skip_reason` should be emprty whenever planned > 0. +# `skip_reason` should be empty whenever planned > 0. function handle_tap_plan(planned, skip_reason) { planned += 0 # Avoid getting confused if, say, `planned` is "00" @@ -329,11 +329,9 @@ function handle_tap_plan(planned, skip_reason) function extract_tap_comment(line) { - # FIXME: verify there is not an off-by-one bug here. if (index(line, diag_string) == 1) { # Strip leading `diag_string` from `line`. - # FIXME: verify there is not an off-by-one bug here. line = substr(line, length(diag_string) + 1) # And strip any leading and trailing whitespace left. sub("^[ \t]*", "", line) |