From b0e481a653b01e4329bccb1d101d56e3e878e960 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 3 Jun 2016 16:43:46 +0300 Subject: Port to MinGW --- tests/amalgam/unnamed/test.sh | 2 +- tests/escaping/test.sh | 2 +- tests/eval/test.sh | 2 +- tests/function/call/test.sh | 2 +- tests/if-else/test.sh | 2 +- tests/keyword/test.sh | 2 +- tests/names/test.sh | 2 +- tests/pairs/test.sh | 2 +- tests/quote/test.sh | 2 +- tests/scope/test.sh | 7 +++++-- tests/test.sh | 30 ++++++++++++++++++++++++++++++ tests/variable/expansion/test.sh | 2 +- tests/variable/null/test.sh | 2 +- tests/variable/override/test.sh | 30 ++++++++++++++++++++++++++---- tests/variable/prepend/test.sh | 2 +- tests/variable/qualified/test.sh | 2 +- tests/variable/type/test.sh | 2 +- 17 files changed, 75 insertions(+), 20 deletions(-) create mode 100755 tests/test.sh (limited to 'tests') diff --git a/tests/amalgam/unnamed/test.sh b/tests/amalgam/unnamed/test.sh index afcb3bd..c745b76 100755 --- a/tests/amalgam/unnamed/test.sh +++ b/tests/amalgam/unnamed/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/escaping/test.sh b/tests/escaping/test.sh index afcb3bd..c745b76 100755 --- a/tests/escaping/test.sh +++ b/tests/escaping/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/eval/test.sh b/tests/eval/test.sh index afcb3bd..c745b76 100755 --- a/tests/eval/test.sh +++ b/tests/eval/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/function/call/test.sh b/tests/function/call/test.sh index afcb3bd..c745b76 100755 --- a/tests/function/call/test.sh +++ b/tests/function/call/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/if-else/test.sh b/tests/if-else/test.sh index afcb3bd..c745b76 100755 --- a/tests/if-else/test.sh +++ b/tests/if-else/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/keyword/test.sh b/tests/keyword/test.sh index afcb3bd..c745b76 100755 --- a/tests/keyword/test.sh +++ b/tests/keyword/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/names/test.sh b/tests/names/test.sh index afcb3bd..c745b76 100755 --- a/tests/names/test.sh +++ b/tests/names/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/pairs/test.sh b/tests/pairs/test.sh index afcb3bd..c745b76 100755 --- a/tests/pairs/test.sh +++ b/tests/pairs/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/quote/test.sh b/tests/quote/test.sh index afcb3bd..c745b76 100755 --- a/tests/quote/test.sh +++ b/tests/quote/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/scope/test.sh b/tests/scope/test.sh index 61194f6..2728a9d 100755 --- a/tests/scope/test.sh +++ b/tests/scope/test.sh @@ -2,11 +2,14 @@ # In-tree. # -b amalgamation/l1/ 2>/dev/null | diff -u test-1.out - +b amalgamation/l1/ 2>/dev/null | diff --strip-trailing-cr -u test-1.out - # Out-of-tree. # rm -rf a-out/ b 'configure(amalgamation/@a-out/)' 2>/dev/null -b amalgamation/l1/@a-out/l1/ 2>/dev/null | diff -u test-2.out - + +b amalgamation/l1/@a-out/l1/ 2>/dev/null | \ + diff --strip-trailing-cr -u test-2.out - + rm -rf a-out/ diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..ce115d5 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,30 @@ +#! /usr/bin/env bash + +cur_dir="`pwd`" +trap 'cd "$cur_dir"' EXIT + +export PATH=$cur_dir/../build2:$PATH + +function test () +{ + echo "Testing $1" + cd "$cur_dir/$1" + ./test.sh +} + +test "amalgam/unnamed" +test "escaping" +test "eval" +test "function/call" +test "if-else" +test "keyword" +test "names" +test "pairs" +test "quote" +test "scope" +test "variable/expansion" +test "variable/null" +test "variable/override" +test "variable/prepend" +test "variable/qualified" +test "variable/type" diff --git a/tests/variable/expansion/test.sh b/tests/variable/expansion/test.sh index afcb3bd..c745b76 100755 --- a/tests/variable/expansion/test.sh +++ b/tests/variable/expansion/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/variable/null/test.sh b/tests/variable/null/test.sh index afcb3bd..c745b76 100755 --- a/tests/variable/null/test.sh +++ b/tests/variable/null/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/variable/override/test.sh b/tests/variable/override/test.sh index 63a792f..e960929 100755 --- a/tests/variable/override/test.sh +++ b/tests/variable/override/test.sh @@ -2,6 +2,25 @@ verbose=n +# By default when MSYS2 executable (bash.exe in particular) runs another +# executable it converts arguments that look like POSIX paths to Windows +# representations. More about it at: +# +# http://www.mingw.org/wiki/Posix_path_conversion +# +# So when you run b /v=X, build2 gets 'C:/msys64/v=X' argument instead of +# '/v=X'. To disable this behavior set MSYS2_ARG_CONV_EXCL environment +# variable, so all arguments starting with / will not be converted. You can +# list more prefixes using ';' as a separator. +# +export MSYS2_ARG_CONV_EXCL=/ + +tmp_file=`mktemp` + +# Remove temporary file on exit. Cover the case when exit due to an error. +# +trap 'rm -f $tmp_file' EXIT + function error () { echo "$*" 1>&2; exit 1; } function fail () @@ -21,10 +40,13 @@ function fail () function test () { - # There is no way to get the exit code in process substitution - # so ruin the output. - # - diff -u - <(b -q $* || echo "") + b -q $* >$tmp_file + + if [ $? -ne 0 ]; then + error "failed: b -q $* >$tmp_file" + fi + + diff --strip-trailing-cr -u - $tmp_file if [ $? -ne 0 ]; then error "failed: b $*" diff --git a/tests/variable/prepend/test.sh b/tests/variable/prepend/test.sh index afcb3bd..c745b76 100755 --- a/tests/variable/prepend/test.sh +++ b/tests/variable/prepend/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/variable/qualified/test.sh b/tests/variable/qualified/test.sh index afcb3bd..c745b76 100755 --- a/tests/variable/qualified/test.sh +++ b/tests/variable/qualified/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - diff --git a/tests/variable/type/test.sh b/tests/variable/type/test.sh index afcb3bd..c745b76 100755 --- a/tests/variable/type/test.sh +++ b/tests/variable/type/test.sh @@ -1,3 +1,3 @@ #!/bin/sh -b -q | diff -u test.out - +b -q | diff --strip-trailing-cr -u test.out - -- cgit v1.1