From ff5bd81012bba4202487c9a5bf7649bd63ca4bae Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Wed, 3 Feb 2010 15:13:06 -0500 Subject: [PATCH] test: Fix up regression test script. 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.sh => regress.zsh} | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) rename tests/{regress.sh => regress.zsh} (83%) diff --git a/tests/regress.sh b/tests/regress.zsh similarity index 83% rename from tests/regress.sh rename to tests/regress.zsh index a752bac..20239b5 100755 --- a/tests/regress.sh +++ b/tests/regress.zsh @@ -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 -- 2.43.2