From b926752fac0fc420ae8e8d78c26f1815d35e89ed Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 1 Jul 2013 03:12:24 +0200 Subject: [PATCH] tests: Don't require bash. Instead merge continuous regions of colored output. This way different shell implementations shouldn't make a difference. --- tests/example.expected | 4 ++-- tests/example_err.expected | 2 +- tests/example_error.expected | 18 +++++++++--------- tests/example_redirects.sh | 5 +---- tests/example_redirects.sh.expected | 6 +++--- tests/example_simple.sh | 5 +---- tests/example_simple.sh.expected | 2 +- tests/example_vfork.expected | 2 +- tests/lib.sh | 7 ++++++- 9 files changed, 25 insertions(+), 26 deletions(-) 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" -- 2.45.2