+2011-08-21 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ 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 <stefano.lattarini@gmail.com>
tap: real (but still incomplete) awk implementation of TAP driver
*) expect_failure=0;;
esac
-case $color_tests in
- yes) color_tests=1;;
- *) color_tests=0;;
-esac
-
if test $color_tests = yes; then
- red='\e[0;31m' # Red.
- grn='\e[0;32m' # Green.
- lgn='\e[1;32m' # Light green.
- blu='\e[1;34m' # Blue.
- mgn='\e[0;35m' # Magenta.
- std='\e[m' # No color.
+ init_colors='
+ color_map["red"]="\e[0;31m" # Red.
+ color_map["grn"]="\e[0;32m" # Green.
+ color_map["lgn"]="\e[1;32m" # Light green.
+ color_map["blu"]="\e[1;34m" # Blue.
+ color_map["mgn"]="\e[0;35m" # Magenta.
+ color_map["std"]="\e[m" # 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
{
-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" \
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)
BEGIN {
+ '"$init_colors"'
+
# Properly initialized once the TAP plan is seen.
planned_tests = 0