From c56a14582de4fbbed34d231e521ab2e6af5d43c3 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Wed, 24 Feb 2016 16:57:54 +0000 Subject: [PATCH] run_tests.sh: don't crash on absolute filepaths in test names. This patch fixes bug #137 "run_tests.sh fail when running configure script with absolute path". The fix: copy all test files into temporary build directory (which is addressed by a relative filepath) and keep messing with relative filepaths. --- re2c/run_tests.sh.in | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/re2c/run_tests.sh.in b/re2c/run_tests.sh.in index 6d097711..c0c42d8e 100644 --- a/re2c/run_tests.sh.in +++ b/re2c/run_tests.sh.in @@ -54,14 +54,21 @@ do done echo "Running in ${threads} thread(s)" -test_srcdir="" +test_blddir="test_"`date +%y%m%d%H%M%S` +rm -rf $test_blddir && mkdir $test_blddir + +# preserve directory structure unless given explicit args if [ ${#tests[@]} -eq 0 ] then - test_srcdir="@top_srcdir@/test" - tests=(`find $test_srcdir -name '*.re' | sort`) + cp -R "@top_srcdir@/test"/* $test_blddir + find $test_blddir -type f ! -name '*.re' -a ! -name '*.c' -exec rm {} \; +else + for f in ${tests[@]} + do + cp $f ${f%.re}.c $test_blddir + done fi -test_blddir="test_"`date +%y%m%d%H%M%S` -rm -rf $test_blddir && mkdir $test_blddir +tests=(`find $test_blddir -name '*.re' | sort`) tests_per_thread=$((${#tests[@]} / threads + 1)) packs=() @@ -108,16 +115,11 @@ run_pack() { do cd $test_blddir - # preserve directory structure unless given explicit args - if [ -z "$test_srcdir" ] - then - local outx=`basename $x` - else - # remove prefix - local outx=${x:$((${#test_srcdir} + 1))} - mkdir -p `dirname $outx` - fi + # remove prefix + local outx=${x:$((${#test_blddir} + 1))} local outc="${outx%.re}.c" + local c="${outx%.re}.c.orig" + mv $outc $c # filename (dot short* (long arg?)*)? ext # must keep to POSIX standard: no syntactic sugar like +,?, etc. @@ -178,17 +180,14 @@ run_pack() { && rm -rf "$tmpdir" # compare results - local c="${x%.re}.c" local status="" - [ -z $status ] && status=`[ -f "../$c" ] || echo "MISSING"` - [ -z $status ] && status=`$diff_prog "../$c" "$outc" > "$outc.diff" || echo "FAIL"` + [ -z $status ] && status=`[ -f "$c" ] || echo "MISSING"` + [ -z $status ] && status=`$diff_prog "$c" "$outc" > "$outc.diff" || echo "FAIL"` [ -z $status ] && status="OK" if [ $status = "OK" ] then - rm "$outc" "$outc.diff" + rm "$outc" "$outc.diff" $c $outx else - cp -f "../$x" "$outx" - cp -f "../$c" "$outc.orig" local errcnt=$(($errcnt + 1)) fi -- 2.40.0