]> granicus.if.org Git - re2c/commitdiff
run_tests.sh: don't crash on absolute filepaths in test names.
authorUlya Trofimovich <skvadrik@gmail.com>
Wed, 24 Feb 2016 16:57:54 +0000 (16:57 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Wed, 24 Feb 2016 16:57:54 +0000 (16:57 +0000)
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

index 6d097711c8929b7678233c1d83c03a7651a4d682..c0c42d8eb84a4763d389848c9e0b772cdaff2039 100644 (file)
@@ -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