From: Simon Ruderich Date: Mon, 1 Jul 2013 01:12:24 +0000 (+0200) Subject: tests: Don't require bash. X-Git-Tag: 0.1~14 X-Git-Url: https://ruderich.org/simon/gitweb/?p=coloredstderr%2Fcoloredstderr.git;a=commitdiff_plain;h=b926752fac0fc420ae8e8d78c26f1815d35e89ed tests: Don't require bash. Instead merge continuous regions of colored output. This way different shell implementations shouldn't make a difference. --- diff --git a/tests/example.expected b/tests/example.expected index 72a30ac..7a8277a 100644 --- a/tests/example.expected +++ b/tests/example.expected @@ -1,9 +1,9 @@ >STDERR>write to stderr: 1 STDERR>error!: Cannot allocate memory -STDERR>write to stderr 2STDERR> +write to stderr 2STDERR> STDERR>more on stderr -STDERR>stderr ... +stderr ... STDERR>xSTDERR>example_err: error: message STDERR>example_err: warning: message: Cannot allocate memory -STDERR>example_err: warning: message +example_err: warning: message STDERR>./example_error:STDERR> STDERR>STDERR> -STDERR>./example_error:STDERR>file:42:STDERR> STDERR>STDERR> -STDERR>./example_error:STDERR> STDERR>STDERR>: Cannot allocate memorySTDERR> -STDERR>./example_error:STDERR>file:42:STDERR> STDERR>STDERR>: Cannot allocate memorySTDERR> -STDERR>./example_error:STDERR>file:42:STDERR> STDERR>STDERR>: Cannot allocate memorySTDERR> -STDERR>PROGSTDERR>STDERR> -STDERR>PROGSTDERR>file:42:STDERR> STDERR>STDERR> -STDERR>PROGSTDERR>STDERR>: Cannot allocate memorySTDERR> -STDERR>PROGSTDERR>file:42:STDERR> STDERR>STDERR>: Cannot allocate memorySTDERR> +>STDERR>./example_error: +./example_error:file:42: +./example_error: : Cannot allocate memory +./example_error:file:42: : Cannot allocate memory +./example_error:file:42: : Cannot allocate memory +PROG +PROGfile:42: +PROG: Cannot allocate memory +PROGfile:42: : Cannot allocate memory STDERR>writeSTDERR> STDERR>toSTDERR> STDERR>stderrSTDERR> STDERR>1STDERR> +>STDERR>write to stderr 1 STDERR>writeSTDERR> STDERR>toSTDERR> STDERR>stdoutSTDERR> STDERR>whichSTDERR> STDERR>getsSTDERR> STDERR>redirectedSTDERR> STDERR>toSTDERR> STDERR>stderrSTDERR> +>STDERR>write to stdout which gets redirected to stderr STDERR>anotherSTDERR> STDERR>redirectSTDERR> STDERR>toSTDERR> STDERR>stderrSTDERR> +>STDERR>another redirect to stderr STDERR>writeSTDERR> STDERR>toSTDERR> STDERR>stderrSTDERR> +>STDERR>write to stderr STDERR>write to stderr without newlineSTDERR>Before vfork(). -STDERR>After vfork(). +After vfork(). "$output" 2>&1 ) + # Merge continuous regions of colored output. The exact calls don't matter + # as long as the output is colored. + sed 's/STDERR>//g' < "$output" > "$output.tmp" + mv "$output.tmp" "$output" + diff -u "$expected" "$output" \ || die 'failed!' rm "$output" @@ -118,7 +123,7 @@ test_script() { run_test "$srcdir/$testcase" "$srcdir/$expected.expected" "$@" } test_script_subshell() { - test_script "$1" "$2" bash -c 'bash $1' '' + test_script "$1" "$2" sh -c 'sh $1' '' } test_program() { testcase="$1"