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".
# 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
# Test case-insensitive literal matches
-cat > $TMP <<EOT
+cat > expected <<EOT
foo: 0
foo*: 1
bar: 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
# 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