From d3bcf8c21e02e2e3bea3e9a77ffa72f84877f24a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 25 Apr 2016 22:17:42 +0100 Subject: [PATCH] Fix handling of expected to fail tests --- test/run | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/test/run b/test/run index a17246fc..42c51a43 100755 --- a/test/run +++ b/test/run @@ -70,16 +70,7 @@ main() { failed=yes fi echo - diff -u $test/$dir/$expect $expect | while read -r line; do - first_character=$(echo "$line" | cut -b 1) - case $first_character in - +) color=green ;; - -) color=red ;; - @) color=magenta ;; - *) color=none ;; - esac - echo "$line" | colorize $color normal - done + show_diff $test/$dir/$expect $expect fi done if [ "$failed" = no ]; then @@ -95,20 +86,25 @@ main() { fi fi else - color=green + failed=no if [ ! -e stderr ]; then if [ $retval -eq 0 ]; then - color=red + echo "$indent$name" | colorize red normal number_failures=$(($number_failures + 1)) + failed=yes fi else sed -i -e 's/^[0-9]*:[0-9]*: //g' stderr if [ -s error ] && ! cmp -s error stderr; then - color=yellow + echo "$indent$name" | colorize yellow normal + show_diff error stderr + failed=yes fi fi - echo "$indent$name" | colorize $color normal + if [ "$failed" = no ]; then + echo "$indent$name" | colorize green normal + fi fi fi done @@ -151,5 +147,17 @@ colorize() { echo "$(get_ansi_code $color_name $style_name)$text$(get_ansi_code none none)" } +show_diff() { + diff -u $1 $2 | while read -r line; do + first_character=$(echo "$line" | cut -b 1) + case $first_character in + +) color=green ;; + -) color=red ;; + @) color=magenta ;; + *) color=none ;; + esac + echo "$line" | colorize $color normal + done +} main $@