]> git.draconx.ca Git - liblbx.git/commitdiff
tests: Source image header in a subshell.
authorNick Bowler <nbowler@draconx.ca>
Thu, 23 Jan 2014 01:50:33 +0000 (20:50 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 23 Jan 2014 03:13:44 +0000 (22:13 -0500)
Use a subshell when sourcing the image header in pam-formats so that
the shell variables do not persist past the end of the test.  While
unlikely, a value left over from an earlier test might result in
false positives in later tests.

tests/pam-formats.tap

index 42f38927522ae352bdab5bbca67227487b806470..76c018520d86493a6e1c64f9110d6071b803af73 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # 2ooM: The Master of Orion II Reverse Engineering Project
 # Test that the PAM writer emits the smallest output format.
-# Copyright © 2013 Nick Bowler
+# Copyright © 2013-2014 Nick Bowler
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 
 . "$srcdir/tests/util/test-init.sh" || exit 99
 
-plan_ 8
 dx_create_testdir
+plan_ 8
 
-check_image()
-{
+check_image() {
        dx_pam_header "$1" > "$1.sh" || return
-       . "./$1.sh" || return
-
-       test x"$WIDTH"  = x"1"  || return
-       test x"$HEIGHT" = x"1"  || return
-       test x"$DEPTH"  = x"$2" || return
-
-       case $DEPTH in
-       1) test x"$TUPLTYPE" = x"GRAYSCALE" ;;
-       2) test x"$TUPLTYPE" = x"GRAYSCALE_ALPHA" ;;
-       3) test x"$TUPLTYPE" = x"RGB" ;;
-       4) test x"$TUPLTYPE" = x"RGB_ALPHA" ;;
-       *) false
-       esac
+       ( . "./$1.sh" || exit
+
+               test x"$WIDTH"  = x"1"  || exit
+               test x"$HEIGHT" = x"1"  || exit
+               test x"$DEPTH"  = x"$2" || exit
+
+               case $DEPTH in
+               1) test x"$TUPLTYPE" = x"GRAYSCALE" ;;
+               2) test x"$TUPLTYPE" = x"GRAYSCALE_ALPHA" ;;
+               3) test x"$TUPLTYPE" = x"RGB" ;;
+               4) test x"$TUPLTYPE" = x"RGB_ALPHA" ;;
+               *) false
+               esac
+       )
 }
 
 command_ok_ "decoding image-1x1 (no palette)" \