test-exclude2.sh, test-exclude5.sh: fail if test-exclude fails
authorJim Meyering <meyering@redhat.com>
Sat, 12 Nov 2011 15:48:09 +0000 (16:48 +0100)
committerJim Meyering <meyering@redhat.com>
Sat, 12 Nov 2011 15:48:09 +0000 (16:48 +0100)
These shell scripts ignored failure of the binary test-exclude,
so making the latter return 77 didn't cause them to be skipped.
* tests/test-exclude5.sh: Exit with test-exclude's error status
when that program fails.  Revamp to use init.sh.
* tests/test-exclude2.sh: Likewise.

ChangeLog
tests/test-exclude2.sh
tests/test-exclude5.sh

index 4a29566..d265d75 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-11-12  Jim Meyering  <meyering@redhat.com>
 
+       test-exclude2.sh, test-exclude5.sh: fail if test-exclude fails
+       These shell scripts ignored failure of the binary test-exclude,
+       so making the latter return 77 didn't cause them to be skipped.
+       * tests/test-exclude5.sh: Exit with test-exclude's error status
+       when that program fails.  Revamp to use init.sh.
+       * tests/test-exclude2.sh: Likewise.
+
        test-exclude: fix a typo
        * tests/test-exclude.c (main): Test for "leading_dir", not "leading-dir".
 
index 7011754..b38bb7f 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-TMP=excltmp.$$
-LIST=flist.$$
-ERR=0
+. "${srcdir=.}/init.sh"; path_prepend_ .
 
-cat > $LIST <<EOT
+fail=0
+
+cat > in <<EOT
 foo*
 bar
 Baz
@@ -28,7 +28,7 @@ EOT
 
 # Test case-insensitive literal matches
 
-cat > $TMP <<EOT
+cat > expected <<EOT
 foo: 0
 foo*: 1
 bar: 1
@@ -37,9 +37,17 @@ baz: 1
 bar/qux: 0
 EOT
 
-./test-exclude$EXEEXT -casefold $LIST -- foo 'foo*' bar foobar baz bar/qux |
- tr -d '\015' |
- diff -c $TMP - || ERR=1
+test-exclude -casefold in -- foo 'foo*' bar foobar baz bar/qux > out \
+  || exit $?
+
+# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
+# does not understand '\r'.
+case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac
+
+# normalize output
+LC_ALL=C tr -d "$cr" < out > k
+mv k out
+
+compare expected out || fail=1
 
-rm -f $TMP $LIST
-exit $ERR
+Exit $fail
index 7f95ea7..3257963 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-TMP=excltmp.$$
-LIST=flist.$$
-ERR=0
+. "${srcdir=.}/init.sh"; path_prepend_ .
+
+fail=0
 
 # Test FNM_LEADING_DIR
 
-cat > $LIST <<EOT
+cat > in <<EOT
 foo*
 bar
 Baz
 EOT
 
-cat > $TMP <<EOT
+cat > expected <<EOT
 bar: 1
 bar/qux: 1
 barz: 0
 foo/bar: 1
 EOT
 
-./test-exclude$EXEEXT -leading_dir $LIST -- bar bar/qux barz foo/bar |
- tr -d '\015' |
- diff -c $TMP - || ERR=1
+test-exclude -leading_dir in -- bar bar/qux barz foo/bar > out \
+  || exit $?
+
+# Find out how to remove carriage returns from output. Solaris /usr/ucb/tr
+# does not understand '\r'.
+case $(echo r | tr -d '\r') in '') cr='\015';; *) cr='\r';; esac
+
+# normalize output
+LC_ALL=C tr -d "$cr" < out > k
+mv k out
+
+compare expected out || fail=1
 
-rm -f $TMP $LIST
-exit $ERR
+Exit $fail