X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tests%2Flib.sh;h=e579b511bf96b57454d0ac8e9f8dfd64f6f0245c;hb=545c6af1daceb29e4a9dc419273a3f2339dfaa7c;hp=2f2c736711fc787fb74ca066aac4d3afb68b4cc6;hpb=0d7f3068981f2b08e583cec21d9069e97c73addd;p=coloredstderr%2Fcoloredstderr.git diff --git a/tests/lib.sh b/tests/lib.sh index 2f2c736..e579b51 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -1,6 +1,6 @@ # Library for the test suite. -# Copyright (C) 2013 Simon Ruderich +# Copyright (C) 2013-2018 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,6 +20,7 @@ set -e # Allow running the script directly without running `make check`. test "x$builddir" = x && builddir=. +test "x$abs_builddir" = x && abs_builddir="`pwd`" test "x$EGREP" = x && EGREP='grep -E' # The tests fail if running under coloredstderr because the tests redirect @@ -99,6 +100,15 @@ run_test() { $valgrind_cmd "$@" "$testcase" > "$output" 2>&1 ) + # Some sed implementations (e.g. on FreeBSD 9.1) always append a trailing + # newline. Add "EOF" to detect if the real output had one. + echo EOF >> "$output" + + # 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 +128,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"