+2011-05-23 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tests: tweak and improve tests on "Simple Tests" driver
+ * tests/check.test: Make grepping of generated Makefile.in
+ slightly stricter. Add trailing `:' command.
+ * tests/check2.test: Ensure verbose printing of captured make
+ output. Make grepping of generated Makefile.in and of make
+ output stricter. Add trailing `:' command.
+ * tests/check3.test: Likewise. Also, fix minor error in a
+ comment.
+ * tests/check4.test: Stricter grepping of make output. Use
+ `using_gmake' subroutine instead of copy&paste from defs.in
+ to determine whether $MAKE is GNU make. Add a trailing `:'
+ command.
+ * tests/check6.test: Add trailing `:' command.
+ * tests/check10.test: Prefer redirection `>' over `>>' when
+ creating new files. Ensure verbose printing of captured make
+ output.
+ * tests/check11.test: Likewise.
+ * tests/check7.test: Likewise. Make grepping of make output
+ stricter. Prefer "make distcheck" over a simple "make check"
+ in a VPATH build. Add trailing `:' command.
+ (a.c): Format following GNU coding standards.
+ (Makefile.am): Explicitly declare target `print-xfail-tests'
+ as PHONY. Distribute $(check_SCRIPTS), for distcheck.
+ * tests/parallel-tests.test: Prefer redirection `>' over `>>'
+ when creating new files.
+ * tests/parallel-tests2.test: Likewise.
+ * tests/parallel-tests9.test: Likewise.
+ * tests/parallel-tests8.test: Likewise. Make grepping of
+ automake stderr stricter.
+ * tests/check8.test: Likewise. Make formatting of created
+ *.c files more consistent with GNU Coding Standards.
+ * tests/check-subst-prog.test (configure.in): Break overly
+ long lines.
+ (pass-prog.c, xfail-prog.c): Format them more consistently
+ with GNU Coding Standards.
+ * tests/parallel-tests3.test: Use a shorter and clearer skip
+ message. Use the `unindent' subroutine to improve readability
+ of indented loop bodies. Simplify the hack used to please
+ maintainer-check.
+ * tests/parallel-tests5.test: Make formatting of created *.c
+ files more consistent with GNU Coding Standards. Use the
+ `unindent' subroutine to improve readability of indented loop
+ bodies.
+ * tests/parallel-tests10.test: Add blank line, for clarity.
+ Prefer trailing `:' over trailing `Exit 0', for consistency
+ with other tests.
+
2011-05-21 Stefano Lattarini <stefano.lattarini@gmail.com>
tests/README: small consistency improvement
cat >> configure.in << 'END'
AC_PROG_CC
-AC_SUBST([script_tests], ['subst-pass-script.test subst-xfail-script.test'])
-AC_SUBST([prog_tests], ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
-AC_SUBST([xfail_tests], ['xfail-script.test subst-xfail-script.test xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_SUBST([script_tests],
+ ['subst-pass-script.test subst-xfail-script.test'])
+AC_SUBST([prog_tests],
+ ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_SUBST([xfail_tests],
+ ['xfail-script.test subst-xfail-script.test]dnl
+ [ xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
AC_OUTPUT
END
cp xfail-script.test subst-xfail-script.test
cat > pass-prog.c <<'END'
-int main() { return 0; }
+int main (void) { return 0; }
END
cat > xfail-prog.c <<'END'
#include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
END
# The .test extension is removed for the default source file name:
cp pass-prog.c subst-pass-prog.c
$AUTOMAKE
grep '^check-TESTS:' Makefile.in
-grep '^check-DEJAGNU' Makefile.in && Exit 1
+grep 'check-DEJAGNU' Makefile.in && Exit 1
# check-TESTS is phony.
-sed -n '/^\.PHONY:/,/^$/p' Makefile.in | grep check-TESTS
+sed -n '/^\.PHONY:/,/^$/p' Makefile.in | $EGREP '(^| )check-TESTS($| )'
# check should depend directly on check-am (similar tests are
# in check2.test and check3.test).
-grep '^check: check-am' Makefile.in
+$EGREP '^check:.* check-am( |$)' Makefile.in
+
+:
XFAIL_TESTS = xfail xpass xfail2 xpass2
END
-cat >>pass <<'END'
+cat > pass <<'END'
#! /bin/sh
exit 0
END
-cat >>fail <<'END'
+cat > fail <<'END'
#! /bin/sh
exit 1
END
-cat >>skip <<'END'
+cat > skip <<'END'
#! /bin/sh
exit 77
END
env TESTS='pass skip xfail' $MAKE -e check
$MAKE check
:
-) >stdout
+) >stdout || { cat stdout; Exit 1; }
cat stdout
grep '1 [tT]ests' stdout && Exit 1
TESTS = skip skip2
END
-cat >>skip <<'END'
+cat > skip <<'END'
#! /bin/sh
exit 77
END
$AUTOMAKE -a
./configure
-env TESTS=skip $MAKE -e check >stdout
+env TESTS=skip $MAKE -e check >stdout || { cat stdout; Exit 1; }
cat stdout
grep '1.*passed' stdout && Exit 1
-env TESTS="skip skip2" $MAKE -e check >stdout
+env TESTS="skip skip2" $MAKE -e check >stdout || { cat stdout; Exit 1; }
cat stdout
grep '2.*passed' stdout && Exit 1
$AUTOCONF
$AUTOMAKE
./configure
-$MAKE check >stdout
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
cat stdout
-grep 'PASS: subrun.sh' stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
# check should depend directly on check-am (similar tests are
# in check.test and check3.test).
-grep 'check: check-recursive' Makefile.in
-grep 'check: check-am' dir/Makefile.in
+$EGREP '^check:.* check-recursive( |$)' Makefile.in
+$EGREP '^check:.* check-am( |$)' dir/Makefile.in
# Make sure subrun.sh is still on its line as above. This means Automake
# hasn't rewritten the TESTS line unnecessarily (we can tell, because all
# Automake variables are reformatted by VAR_PRETTY).
-grep ' subrun.sh' Makefile.in
+grep '^ subrun\.sh$' Makefile.in
+
+:
$AUTOCONF
$AUTOMAKE
./configure --prefix "`pwd`/inst"
-$MAKE check >stdout
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
cat stdout
-grep 'PASS: subrun.sh' stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
-# check should depend directly on check-am (similar tests are
-# in check.test and check2.test).
-$FGREP 'check: $(BUILT_SOURCES)' Makefile.in
-$FGREP 'check: $(BUILT_SOURCES)' dir/Makefile.in
+# check should depend directly on $(BUILT_SOURCES) (similar tests
+# are in check.test and check2.test).
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
$MAKE clean
# Sanity checks
$MAKE install
test -f command1.inc
test -f dir/command2.inc
+
+:
$AUTOCONF
$AUTOMAKE
./configure --prefix "`pwd`/inst"
+
$MAKE check >stdout && { cat stdout; Exit 1; }
cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout && Exit 1
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout && Exit 1
# The exit status of `make -k' can be anything
# (depending on the Make implementation)
$MAKE -k check >stdout || :
cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout
# should also works when -k is not in first position
$MAKE -s -k check >stdout || :
cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+grep '^FAIL: fail\.sh *' stdout
+grep '^PASS: ok\.sh *' stdout
# The rest of the test is for GNU Make.
-# Use --version AND -v, because SGI Make doesn't fail on --version.
-# Also grep for GNU because newer versions of FreeBSD make do
-# not complain about `--version' (they seem to silently ignore it).
-($MAKE --version -v | grep GNU) || Exit 0
+if using_gmake; then
+ # Try with a long-option that do not have a short option equivalent
+ # (here, --no-print-directory). That should cause all options to
+ # appear verbatim in MAKEFLAGS.
+ $MAKE --no-print-directory -k check >stdout || :
+ cat stdout
+ grep '^FAIL: fail\.sh *$' stdout
+ grep '^PASS: ok\.sh *$' stdout
+fi
-# Try with a long-option that do not have a short option equivalent
-# (here, --no-print-directory). That should cause all options to
-# appear verbatim in MAKEFLAGS.
-$MAKE --no-print-directory -k check >stdout || :
-cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+:
cd build
../configure
$MAKE check
+
+:
XFAIL_TESTS = a b c d
check_PROGRAMS = a c d
check_SCRIPTS = b
+EXTRA_DIST = $(check_SCRIPTS)
+.PHONY: print-xfail-tests
print-xfail-tests:
@echo BEG: $(XFAIL_TESTS) :END
END
-cat >>b <<'END'
+cat > b <<'END'
#! /bin/sh
exit 1
END
chmod a+x b
-cat >>a.c <<'END'
+cat > a.c <<'END'
#include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void)
+{
+ return EXIT_FAILURE;
+}
END
cp a.c c.c
./configure
$MAKE check
-EXEEXT=.bin $MAKE -e print-xfail-tests >foo
-cat foo
-grep 'BEG: a.bin b c.bin d.bin :END' foo
+EXEEXT=.bin $MAKE -e print-xfail-tests >stdout || { cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: a.bin b c.bin d.bin :END' stdout
-$MAKE distclean
-mkdir build
-cd build
-../configure
-$MAKE check
+$MAKE distcheck
+
+:
mkdir sub
-cat >>foo <<'END'
+cat > foo <<'END'
#! /bin/sh
test -f "$srcdir/Makefile.am"
END
-cat >>sub/foo <<'END'
+cat > sub/foo <<'END'
#! /bin/sh
test -f "$srcdir/Makefile.am"
END
chmod a+x foo sub/foo
-cat >>bar.c <<'END'
-int main() { return 0; }
+cat > bar.c <<'END'
+int main (void) { return 0; }
END
-cat >>sub/bar.c <<'END'
-int main() { return 0; }
+cat > sub/bar.c <<'END'
+int main (void) { return 0; }
END
-cat >>baz.c <<'END'
+cat > baz.c <<'END'
#include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
END
-cat >>sub/baz.c <<'END'
+cat > sub/baz.c <<'END'
#include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
END
$ACLOCAL
# foo.test and bar.test sleep to ensure their logs are always strictly newer
# than the logs of their prerequisites, for HP-UX make. The quoting pleases
# maintainer-check.
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
#! /bin/sh
echo "this is $0"
sleep '1'
exit 0
END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
#! /bin/sh
echo "this is $0"
sleep '1'
exit 99
END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
#! /bin/sh
echo "this is $0"
exit 1
parallel_tests=yes
. ./defs || Exit 1
+
cat >> configure.in << 'END'
AC_OUTPUT
END
./configure
$MAKE check
-Exit 0
+:
CLEANFILES = bla
END
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
#! /bin/sh
echo "this is $0"
test -f bla || exit 1
exit 0
END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
#! /bin/sh
echo "this is $0"
exit 99
END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
#! /bin/sh
echo "this is $0"
exit 1
test -f bla
test ! -f foo.log
test -f mylog.html
+
:
. ./defs || Exit 1
case $MAKE in
- *\ -j*) skip_ "this test does not work well if \$MAKE contains \`-j'";;
+ *\ -j*) skip_ "\$MAKE contains \`-j'";;
esac
cat >> configure.in << 'END'
for i in 1 2 3 4 5 6 7 8; do
echo "TESTS += foo$i.test" >> Makefile.am
- cat >foo$i.test <<'END'
-#! /bin/sh
-echo "this is $0"
-# hack around maintainer-check check:
-sleep='sleep '1
-$sleep
-exit 0
+ unindent >foo$i.test <<'END'
+ #! /bin/sh
+ echo "this is $0"
+ # FIXME: spurious quote to please maintainer-check
+ sleep '1'
+ exit 0
END
chmod a+x foo$i.test
done
$sleep
done
$sleep
+
:
for i in 1 2 3 4 5 6 7 8; do
echo "scripts += foo$i.test" >> Makefile.am
echo "programs += foo$i.prog" >> Makefile.am
- cat >foo$i.test <<'END'
-#! /bin/sh
-echo "this is $0"
-exit 0
+ unindent >foo$i.test <<'END'
+ #! /bin/sh
+ echo "this is $0"
+ exit 0
END
cat >foo$i.c <<'END'
-int main()
-{
- return 0;
-}
+ int main (void)
+ {
+ return 0;
+ }
END
chmod a+x foo$i.test
done
DISTCLEANFILES = foo.test
END
-cat >>foo.in <<'END'
+cat > foo.in <<'END'
#! /bin/sh
echo "this is $0"
exit 0
$ACLOCAL
$AUTOCONF
AUTOMAKE_fails -a
-grep '(srcdir.*bar' stderr
-grep 'top_srcdir.*baz' stderr
+grep '$(srcdir).*TESTS.*bar\.test' stderr
+grep '$(top_srcdir).*TESTS.*baz\.test' stderr
sed '/^TESTS +=.*srcdir/d' < Makefile.am > t
mv -f t Makefile.am
echo bla > $@
END
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
#! /bin/sh
echo "this is $0"
test -f bla || exit 1
exit 0
END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
#! /bin/sh
echo "this is $0"
exit 99
END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
#! /bin/sh
echo "this is $0"
exit 1
test ! -f bar.log
test ! -f baz.log
test -f mylog.log
+
: