]> git.draconx.ca Git - liblbx.git/commitdiff
test: Fix up regression test script.
authorNick Bowler <nbowler@elliptictech.com>
Wed, 3 Feb 2010 20:13:06 +0000 (15:13 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 4 Feb 2010 01:29:41 +0000 (20:29 -0500)
The script uses a hodge-podge of portable and non-portable constructs
and declares the interpreter as /bin/sh.  Change it to use my favourite
shell and exploit its features.

tests/regress.zsh [moved from tests/regress.sh with 83% similarity]

similarity index 83%
rename from tests/regress.sh
rename to tests/regress.zsh
index a752bac3488cbd71037cb33e82f779a1de569882..20239b5087fb4c7024cfb467815ad0657c2670fa 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env zsh
 # Simple test which decodes some images from LBX archives and compares against
 # known md5sums to find regressions.  Unforuntately depends on the output
 # format of lbximg; this may change in the future.
@@ -6,17 +6,17 @@
 # Image/tool paths.  Adjust to taste.  The DATADIR must contain the original
 # Moo2 LBX archives, with filenames in lower case.
 DATADIR=$HOME/.2oom/game
-LBXTOOL="`readlink -f ../lbxtool`"
-LBXIMG="`readlink -f ../lbximg`"
+LBXTOOL=`readlink -f ../lbxtool`
+LBXIMG=`readlink -f ../lbximg`
 
 # Status vars
 FAILED=0
 
-if ! SCRATCH="`mktemp -d`"; then
+if ! SCRATCH=`mktemp -d`; then
        exit 1
 fi
 
-cd "$SCRATCH"
+cd $SCRATCH || exit 1
 echo "Working in $SCRATCH"
 
 # Palettes
@@ -25,13 +25,15 @@ $LBXTOOL -xf $DATADIR/fonts.lbx
 compare()
 {
        echo -n "  Frame $1 "
-       FILE="$(printf 'out.%03d.png' $1)"
-       MD5="$(md5sum "$FILE" | cut -d ' ' -f 1)"
-       if [ "$MD5" = "$2" ]; then
-               echo "OK"
-               rm -f "$FILE"
+
+       FILE=`printf 'out.%03d.png' $1`
+       MD5=`md5sum $FILE | cut -d ' ' -f 1`
+
+       if [[ $MD5 == $2 ]]; then
+               echo OK
+               rm -f $FILE
        else
-               echo "FAILED"
+               echo FAILED
                FAILED=`expr $FAILED + 1`
        fi
 }
@@ -54,7 +56,7 @@ compare 15 cad158da9a015adfcea7809a8a3b6f4b
 compare 49 390c49cfd1fe5e2ac0490be976f20936
 
 # Logos
-$LBXTOOL -xf $DATADIR/logo.lbx 
+$LBXTOOL -xf $DATADIR/logo.lbx
 
 echo "logo.lbx.000: single frame, embedded palette, transparency:"
 $LBXIMG -df logo.lbx.000
@@ -74,9 +76,9 @@ $LBXIMG -df ships.lbx.042 -p fonts.lbx.012 -O ships.lbx.049
 compare 0 bd643736d46ef387bcffcc8803aabb83
 
 # Clean up
-if [ $FAILED -eq 0 ]; then
+if [[ $FAILED -eq 0 ]]; then
        echo "All tests completed successfully."
-       rm -rf -- "$SCRATCH"
+       rm -rf -- $SCRATCH
 else
        echo "$FAILED test(s) FAILED"
 fi