tests: update sav for test_parser
[nit.git] / tests / tests.sh
index d11c60a..738ccd2 100755 (executable)
@@ -145,6 +145,13 @@ else
        TIMESTAMP=
 fi
 
+# Detect a working hostname command
+if hostname --version | grep coreutils >/dev/null 2>&1; then
+       HOSTNAME="hostname"
+else
+       HOSTNAME="hostname -s"
+fi
+
 # $1 is the pattern of the test
 # $2 is the file to compare to
 # the result is:
@@ -158,7 +165,7 @@ function compare_to_result()
        local sav="$2"
        if [ ! -r "$sav" ]; then return 0; fi
        test "`cat -- "$sav"`" = "UNDEFINED" && return 1
-       diff -u -- "$sav" "$outdir/$pattern.res" > "$outdir/$pattern.diff.sav.log"
+       diff -u --strip-trailing-cr -- "$sav" "$outdir/$pattern.res" > "$outdir/$pattern.diff.sav.log"
        if [ "$?" == 0 ]; then
                return 1
        fi
@@ -166,7 +173,7 @@ function compare_to_result()
        sed '/[Ww]arning/d;/[Ee]rror/d' "$sav" > "$outdir/$pattern.sav2"
        grep '[Ee]rror' "$outdir/$pattern.res" >/dev/null && echo "Error" >> "$outdir/$pattern.res2"
        grep '[Ee]rror' "$sav" >/dev/null && echo "Error" >> "$outdir/$pattern.sav2"
-       diff -u "$outdir/$pattern.sav2" "$outdir/$pattern.res2" > "$outdir/$pattern.diff.sav.log2"
+       diff -u --strip-trailing-cr "$outdir/$pattern.sav2" "$outdir/$pattern.res2" > "$outdir/$pattern.diff.sav.log2"
        if [ "$?" == 0 ]; then
                return 2
        else
@@ -372,7 +379,7 @@ need_skip()
        fi
 
        # Skip by hostname
-       local host_skip_file=`hostname -s`.skip
+       local host_skip_file=`$HOSTNAME`.skip
        if test -e $host_skip_file && echo "$1" | grep -f "$host_skip_file" >/dev/null 2>&1; then
                echo "=> $2: [skip hostname]"
                echo >>$xml "<testcase classname='`xmlesc "$3"`' name='`xmlesc "$2"`' `timestamp`><skipped/></testcase>"
@@ -521,7 +528,7 @@ case $engine in
                ;;
 esac
 
-savdirs="sav/`hostname -s` sav/`uname` sav/$engine $savdirs sav/"
+savdirs="sav/`$HOSTNAME` sav/`uname` sav/$engine $savdirs sav/"
 
 # The default nitc compiler
 [ -z "$NITC" ] && find_nitc
@@ -580,8 +587,8 @@ for ii in "$@"; do
        # Sould we skip the file for this engine?
        need_skip "$f" "$f" "$pack" && continue
 
-       tmp=${ii/../AA}
-       if [ "x$tmp" = "x$ii" ]; then
+       local_tmp=${ii/../AA}
+       if [ "x$local_tmp" = "x$ii" ]; then
                includes="-I . -I ../lib/core -I ../lib/core/collection -I alt"
        else
                includes="-I alt"