]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
coverage: parallel-tests and lazy dependencies on EXTRA_PROGRAMS
authorStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 2 Aug 2011 20:24:28 +0000 (22:24 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Tue, 2 Aug 2011 21:31:32 +0000 (23:31 +0200)
* tests/parallel-tests-extra-programs.test: New test.
* tests/Makefile.am (TESTS): Update.
* doc/automake.texi (Parallel Test Harness): Add a comment
pointing to the new test.

ChangeLog
doc/automake.texi
tests/Makefile.am
tests/Makefile.in
tests/parallel-tests-extra-programs.test [new file with mode: 0755]

index 15a223d02c97cb1fbd19d94287a3ec81729e6ad5..c61c20f0bcc1d304255350be516dd74b8de15d0b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-08-02  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       coverage: parallel-tests and lazy dependencies on EXTRA_PROGRAMS
+       * tests/parallel-tests-extra-programs.test: New test.
+       * tests/Makefile.am (TESTS): Update.
+       * doc/automake.texi (Parallel Test Harness): Add a comment
+       pointing to the new test.
+
 2011-08-02  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        docs: improve, extend and fix documentation on TAP support
index c1ee0a519d0405464f2f80195de34310c558e8cc..65a692d055dc17955b431d22a4fa2306f4565af3 100644 (file)
@@ -9186,6 +9186,7 @@ parallel @command{make -j@var{N}}, so be sure they are prepared for
 concurrent execution.
 
 @cindex Unit tests
+@c Keep in sync with 'parallel-tests-extra-programs.test'.
 The combination of lazy test execution and correct dependencies between
 tests and their sources may be exploited for efficient unit testing
 during development.  To further speed up the edit-compile-test cycle, it
index 6a45fcf74a116e54df1bdcd86fc7e56006b35a76..d7aed685780c9f4ede13c4c777c20f004b1dd1ec 100644 (file)
@@ -727,6 +727,7 @@ parallel-tests10.test \
 parallel-tests-make-n.test \
 parallel-tests-fd-redirect.test \
 parallel-tests-am_tests_environment.test \
+parallel-tests-extra-programs.test \
 parallel-tests-unreadable.test \
 parallel-tests-subdir.test \
 parallel-tests-interrupt.test \
index a0857621426e3711249706d0df02e28db8d05864..bd907b0b6b569dad63488a19345084f055af2607 100644 (file)
@@ -978,6 +978,7 @@ parallel-tests10.test \
 parallel-tests-make-n.test \
 parallel-tests-fd-redirect.test \
 parallel-tests-am_tests_environment.test \
+parallel-tests-extra-programs.test \
 parallel-tests-unreadable.test \
 parallel-tests-subdir.test \
 parallel-tests-interrupt.test \
diff --git a/tests/parallel-tests-extra-programs.test b/tests/parallel-tests-extra-programs.test
new file mode 100755 (executable)
index 0000000..f309b4c
--- /dev/null
@@ -0,0 +1,174 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Parallel test harness: check that $(TESTS) can lazily depend on
+# (or even be) $(EXTRA_PROGRAMS).
+
+required='cc native'
+parallel_tests=yes
+. ./defs || Exit 1
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+
+# Will be extended later.
+cat > Makefile.am << 'END'
+TEST_EXTENSIONS = .bin .test
+EXTRA_PROGRAMS =
+TESTS = 
+END
+
+#
+# Now try various kinds of test dependencies ...
+#
+
+# 1. A program that is also a test, and whose source files
+#    already exist.
+
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += foo.bin
+TESTS += foo.bin
+foo_bin_SOURCES = foo.c
+END
+
+cat > foo.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+  printf ("foofoofoo\n");
+  return 0;
+}
+END
+
+# 2. A program that is also a test, and whose source files
+#    are buildable by make.
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += bar.bin
+TESTS += bar.bin
+bar_bin_SOURCES = bar.c
+bar.c: foo.c
+       sed -e 's/foofoofoo/barbarbar/' foo.c > $@
+END
+
+# 3. A test script that already exists, whose execution depends
+#    on a program whose source files already exist and which is
+#    not itself a test.
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += y
+TESTS += baz.test
+baz.log: y$(EXEEXT)
+END
+
+cat > baz.test <<'END'
+#!/bin/sh
+$srcdir/y "$@" | sed 's/.*/&ep&ep&ep/'
+END
+chmod a+x baz.test
+
+cat > y.c <<'END'
+#include <stdio.h>
+int main (void)
+{
+  printf ("y\n");
+  return 0;
+}
+END
+
+# 4. A program that is also a test, but whose source files
+#    do not exit and are not buildable by make.
+
+cat >> Makefile.am <<'END'
+EXTRA_PROGRAMS += none.bin
+TESTS += none.bin
+none_bin_SOURCES = none.c
+END
+
+#
+# Setup done, go with the tests.
+#
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+# What we check now:
+#  1. even if we cannot build the `none.bin' program, all the other
+#     test programs should be built, and all the other tests should
+#     be run;
+#  2. still, since we cannot create the `none.log' file, the
+#    `test-suite.log' file shouldn't be created (as it depends
+#     on *all* the test logs).
+
+st=0
+$MAKE check >stdout 2>stderr || st=$?
+cat stdout
+cat stderr >&2
+ls -l
+test $st -gt 0 || Exit 1
+
+# Files that should have been created, with the expected content.
+cat bar.c
+grep foofoofoo foo.log
+grep barbarbar bar.log
+grep yepyepyep baz.log
+# Files that shouldn't have been created.
+test ! -f none.log
+test ! -f test-suite.log
+# Expected testsuite progress output.
+grep '^PASS: baz\.test$' stdout
+# Don't anchor the end of the next two patterns, to allow for non-empty
+# $(EXEEXT).
+grep '^PASS: foo\.bin' stdout
+grep '^PASS: bar\.bin' stdout
+# Expected error messages from make.
+$EGREP 'none\.(bin|o|c)' stderr
+
+# What we check now:
+#  1. if we make the last EXTRA_PROGRAM buildable, the failed tests
+#     pass;
+#  2. on a lazy re-run, the passed tests are not re-run, and
+#  3. their log files are not updated or touched.
+
+: > stamp
+$sleep
+
+echo 'int main (void) { return 0; }' > none.c
+
+st=0
+RECHECK_LOGS= $MAKE -e check >stdout || st=$?
+cat stdout
+ls -l
+test $st -eq 0 || Exit 1
+
+# For debugging.
+stat stamp foo.log bar.log baz.log || :
+
+# Files that shouldn't have been updated or otherwise touched.
+is_newest stamp foo.log bar.log baz.log
+# Files that should have been created now.
+test -f none.log
+test -f test-suite.log
+# Tests that shouldn't have been re-run.
+$EGREP '(foo|bar)\.bin|baz\.test$' stdout && Exit 1
+# Tests that should have been run.  Again, we don't anchor the end
+# of the next pattern, to allow for non-empty $(EXEEXT).
+grep '^PASS: none\.bin' stdout
+
+: