From 3d18446acef5462e946fe79909b198b35c2bbfa0 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 29 May 2016 01:23:34 +0300 Subject: Port to MinGW --- tests/test.sh | 84 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 61 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/test.sh b/tests/test.sh index 3a56c10..4752698 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -32,6 +32,12 @@ trap 'exit 1' ERR +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 @@ -41,6 +47,10 @@ function error () bpkg="../bpkg/bpkg" cfg=/tmp/conf +if [ "${MSYSTEM:0:5}" = "MINGW" ]; then + msys=y +fi + verbose=n remote=n options= @@ -79,19 +89,16 @@ fi bpkg="$bpkg $options" -# Repository location, name, and absolute location prefixes. Note that the -# local path is carefully crafted so that we end up with the same repository -# names in both cases. This is necessary for the authentication tests to work -# in both cases. +# Repository location and name prefixes. Note that the local path is carefully +# crafted so that we end up with the same repository names in both cases. This +# is necessary for the authentication tests to work in both cases. # if [ "$remote" = "y" ]; then rep=https://build2.org/bpkg/1 repn=build2.org/ - repa=$rep else rep=pkg/1/build2.org repn=build2.org/ - repa=`pwd`/$rep fi # @@ -115,10 +122,8 @@ function test () if [ -t 0 ]; then $bpkg $cmd $ops $* else - # There is no way to get the exit code in process substitution - # so ruin the output. - # - diff -u - <($bpkg $cmd $ops $* || echo "") + $bpkg $cmd $ops $* >$tmp_file + diff --strip-trailing-cr -u - $tmp_file fi if [ $? -ne 0 ]; then @@ -196,6 +201,21 @@ function edit () mv $path.bak $path } +# Repository absolute location from a relative path. +# +function location () +{ + if [ "$remote" = "y" ]; then + echo $rep/$1 + elif [ "$msys" = "y" ]; then + # Convert Windows path like c:/abc/xyz to the c:\abc\xyz canonical form. + # + echo `pwd -W`/$rep/$1 | sed 's%/%\\%g' + else + echo `pwd`/$rep/$1 + fi +} + ## ## Low-level commands. ## @@ -233,13 +253,13 @@ test rep-create pkg/1/build2.org/common/bar/unstable fail rep-info # repository location expected test rep-info --trust-yes $rep/common/foo/testing <