From: Stefano Lattarini Date: Sun, 21 Aug 2011 18:09:34 +0000 (+0200) Subject: tap/awk: support colorized output X-Git-Tag: ng-0.5a~89^2~97^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bc8f828ae07b6a3537ef0ca46cd698ba99659e2;p=thirdparty%2Fautomake.git tap/awk: support colorized output * lib/tap-driver.sh: Pass definition of colors to the BEGIN block of the awk script, using ... ($init_colors): ... this new variable, which supersedes ... ($red, $grn, $lgn, $blu, $mgn, $std): ... these variables, which have been consequently removed. ($color_tests): We don't have to pass this anymore to the awk script, so do not convert it to a numeric boolean. (decorate_result): Implement for real. With this change, the test 'tap-color.test' now passes. --- diff --git a/ChangeLog b/ChangeLog index e9509fdb8..80889c9ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2011-08-21 Stefano Lattarini + + tap/awk: support colorized output + * lib/tap-driver.sh: Pass definition of colors to the BEGIN block + of the awk script, using ... + ($init_colors): ... this new variable, which supersedes ... + ($red, $grn, $lgn, $blu, $mgn, $std): ... these variables, which + have been consequently removed. + ($color_tests): We don't have to pass this anymore to the awk + script, so do not convert it to a numeric boolean. + (decorate_result): Implement for real. + With this change, the test 'tap-color.test' now passes. + 2011-08-21 Stefano Lattarini tap: real (but still incomplete) awk implementation of TAP driver diff --git a/lib/tap-driver.sh b/lib/tap-driver.sh index dc19fa03b..28eacb7be 100755 --- a/lib/tap-driver.sh +++ b/lib/tap-driver.sh @@ -97,20 +97,22 @@ case $expect_failure in *) expect_failure=0;; esac -case $color_tests in - yes) color_tests=1;; - *) color_tests=0;; -esac - if test $color_tests = yes; then - red='' # Red. - grn='' # Green. - lgn='' # Light green. - blu='' # Blue. - mgn='' # Magenta. - std='' # No color. + init_colors=' + color_map["red"]="" # Red. + color_map["grn"]="" # Green. + color_map["lgn"]="" # Light green. + color_map["blu"]="" # Blue. + color_map["mgn"]="" # Magenta. + color_map["std"]="" # No color. + color_for_result["ERROR"] = "mgn" + color_for_result["PASS"] = "grn" + color_for_result["XPASS"] = "red" + color_for_result["FAIL"] = "red" + color_for_result["XFAIL"] = "lgn" + color_for_result["SKIP"] = "blu"' else - red= grn= lgn= blu= mgn= std= + init_colors='' fi { @@ -125,7 +127,6 @@ fi -v test_script_name="$test_name" \ -v log_file="$log_file" \ -v trs_file="$trs_file" \ - -v color_tests="$color_tests" \ -v expect_failure="$expect_failure" \ -v merge="$merge" \ -v ignore_exit="$ignore_exit" \ @@ -232,7 +233,12 @@ function stringify_result_obj(obj) function decorate_result(result) { - return result # TODO! + color_name = color_for_result[result] + if (color_name) + return color_map[color_name] "" result "" color_map["std"] + # If we are not using colorized output, or if we do not know how + # to colorize the given result, we should return it unchanged. + return result } function report(result, details) @@ -432,6 +438,8 @@ function write_test_results() BEGIN { + '"$init_colors"' + # Properly initialized once the TAP plan is seen. planned_tests = 0