bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

build: use Automake's new parallel-tests feature


From: Jim Meyering
Subject: build: use Automake's new parallel-tests feature
Date: Tue, 31 Mar 2009 21:24:18 +0200

FYI, here are 3 patches (just pushed) to
- enable parallel tests via automake, now that it can (thanks again Ralf!)
    (rather than by enabling the parallelization via build-aux/check.mk)
- likewise for colored "make check" FAIL/PASS (red/green) test results
- change how automake's new silent-rules option is enabled

>From f8268d3baecee552e13efb916693bfa51734862b Mon Sep 17 00:00:00 2001
From: Ralf Wildenhues <address@hidden>
Date: Sat, 14 Mar 2009 12:15:40 +0100
Subject: [PATCH 1/3] build: use Automake's new parallel-tests feature

* build-aux/check.mk: Remove, not needed any more.
* tests/Makefile.am (AUTOMAKE_OPTIONS): Add parallel-tests and
color-tests.
* tests/check.mk: Do not include build-aux/check.mk any more.
(SUFFIXES, TEST_LOGS): Remove.
(TESTS_ENVIRONMENT): Use $$f rather than $$tst in $PERL invocation.
* gnulib-tests/Makefile.am: Do not include build-aux/check.mk.
(AUTOMAKE_OPTIONS): New macro, add parallel-test and color-tests.
(TEST_LOGS): Remove.
---
 build-aux/check.mk       |  283 ----------------------------------------------
 gnulib-tests/Makefile.am |    5 +-
 tests/Makefile.am        |    2 +-
 tests/check.mk           |    8 +-
 4 files changed, 3 insertions(+), 295 deletions(-)
 delete mode 100644 build-aux/check.mk

diff --git a/build-aux/check.mk b/build-aux/check.mk
deleted file mode 100644
index 5bfcc90..0000000
--- a/build-aux/check.mk
+++ /dev/null
@@ -1,283 +0,0 @@
-## Vaucanson, a generic library for finite state machines.
-## Copyright (C) 2006, 2007 The Vaucanson Group.
-##
-## 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
-## of the License, or (at your option) any later version.
-##
-## The complete GNU General Public Licence Notice can be found as the
-## `COPYING' file in the root directory.
-
-## Override the definition from Automake to generate a log file with
-## failed tests.  It also supports parallel make checks.
-##
-## This file provides special support for "unit tests", that is to
-## say, tests that (once run) no longer need to be re-compiled and
-## re-run at each "make check", unless their sources changed.  To
-## enable unit-test supports, define LAZY_TEST_SUITE.  In such a
-## setting, that heavily relies on correct dependencies, its users may
-## prefer to define EXTRA_PROGRAMS instead of check_PROGRAMS, because
-## it allows intertwined compilation and execution of the tests.
-## Sometimes this helps catching errors earlier (you don't have to
-## wait for all the tests to be compiled).
-##
-## Define TEST_SUITE_LOG to be the name of the global log to create.
-## Define TEST_LOGS to the set of logs to include in it.  One possibility
-## is $(TESTS:.test=.log).
-##
-## In addition to the magic "exit 77 means SKIP" feature (which was
-## imported from automake), there is a magic "exit 177 means FAIL" feature
-## which is useful if you need to issue a hard error no matter whether the
-## test is XFAIL or not.
-
-# Use a POSIX-compatible shell if available, as this file uses
-# features of the POSIX shell that are not supported by some standard
-# shell implementations (e.g., Solaris 10 /bin/sh).
-SHELL = $(PREFERABLY_POSIX_SHELL)
-
-# Set this to `false' to disable hard errors.
-ENABLE_HARD_ERRORS = :
-
-## We use GNU Make extensions (%-rules) inside GNU_MAKE checks,
-## and we override check-TESTS.
-AUTOMAKE_OPTIONS += -Wno-portability -Wno-override
-
-# Restructured Text title and section.
-am__rst_title   = sed 's/.*/   &   /;h;s/./=/g;p;x;p;g;p;s/.*//'
-am__rst_section = sed 'p;s/./=/g;p;g'
-
-# Put stdin (possibly several lines separated by ".  ") in a box.
-am__text_box = $(AWK) '{gsub ("\\.  ", "\n"); print $$0; }' |  \
-$(AWK) '                                                       \
-max < length($$0) {                                            \
-  final= final (final ? "\n" : "") " " $$0;                    \
-  max = length($$0);                                           \
-}                                                              \
-END {                                                          \
-  for (i = 0; i < max + 2 ; ++i)                               \
-    line = line "=";                                           \
-  print line;                                                  \
-  print final;                                                 \
-  print line;                                                  \
-}'
-
-# If stdout is a tty and TERM is smart then use colors.  If test -t or
-# tput are not supported then this fails; a conservative approach.  Of
-# course do not redirect stdout here, just stderr...
-am__tty_colors =                               \
-red=;                                          \
-grn=;                                          \
-lgn=;                                          \
-blu=;                                          \
-std=;                                          \
-test "X$$TERM" != Xdumb &&                     \
-test -t 1 2>/dev/null &&                       \
-tput bold 1 >/dev/null 2>&1 &&                 \
-tput setaf 1 >/dev/null 2>&1 &&                        \
-tput sgr0 >/dev/null 2>&1 &&                   \
-{                                              \
-    red=$$(tput setaf 1);                      \
-    grn=$$(tput setaf 2);                      \
-    lgn=$$(tput bold)$$(tput setaf 2);         \
-    blu=$$(tput setaf 4);                      \
-    std=$$(tput sgr0);                         \
-}
-
-# Solaris 10 'make', and several other traditional 'make' implementations,
-# pass "-e" to $(SHELL).  This contradicts POSIX.  Work around the problem
-# by disabling -e (using the XSI extension "set +e") if it's set.
-SH_E_WORKAROUND = case $$- in *e*) set +e;; esac
-
-# Emulate dirname with sed.
-_d_no_slash       = s,^[^/]*$$,.,
-_d_strip_trailing = s,\([^/]\)//*$$,\1,
-_d_abs_trivial    = s,^//*[^/]*$$,/,
-_d_rm_basename    = s,\([^/]\)//*[^/]*$$,\1,
-_dirname = \
-  sed '$(_d_no_slash);$(_d_strip_trailing);$(_d_abs_trivial);$(_d_rm_basename)'
-
-# To be inserted before the command running the test.  Creates the
-# directory for the log if needed.  Stores in $dir the directory
-# containing $src, and passes TESTS_ENVIRONMENT.
-# Save and restore TERM around use of TESTS_ENVIRONMENT,
-# in case that unsets it.
-am__check_pre =                                        \
-$(SH_E_WORKAROUND);                            \
-tst=`echo "$$src" | sed 's|^.*/||'`;           \
-rm -f address@hidden;                                  \
-trap 'st=$$?; rm -f '\''$(abs_builddir)/address@hidden'\''; (exit $$st); exit 
$$st' \
-  1 2 13 15;                                   \
-$(mkdir_p) "$$(echo '$@'|$(_dirname))" || exit;        \
-if test -f "./$$src"; then dir=./;             \
-elif test -f "$$src"; then dir=;               \
-else dir="$(srcdir)/"; fi;                     \
-__SAVED_TERM=$$TERM;                           \
-$(TESTS_ENVIRONMENT)
-
-# To be appended to the command running the test.  Handles the stdout
-# and stderr redirection, and catch the exit status.
-am__check_post =                                       \
->address@hidden 2>&1;                                          \
-estatus=$$?;                                           \
-if test $$estatus -eq 177; then                                \
-  $(ENABLE_HARD_ERRORS) || estatus=1;                  \
-fi;                                                    \
-TERM=$$__SAVED_TERM; export TERM;                      \
-$(am__tty_colors);                                     \
-xfailed=PASS;                                          \
-for xfail in : $(XFAIL_TESTS); do                      \
-  case $$src in                                                \
-    $$xfail | */$$xfail) xfailed=XFAIL; break;         \
-  esac;                                                        \
-done;                                                  \
-case $$estatus:$$xfailed in                            \
-    0:XFAIL) col=$$red; res=XPASS;;                    \
-    0:*)     col=$$grn; res=PASS ;;                    \
-    77:*)    col=$$blu; res=SKIP ;;                    \
-    177:*)   col=$$red; res=FAIL ;;                    \
-    *:XFAIL) col=$$lgn; res=XFAIL;;                    \
-    *:*)     col=$$red; res=FAIL ;;                    \
-esac;                                                  \
-echo "$${col}$$res$${std}: $@";                                \
-echo "$$res: $@ (exit: $$estatus)" |                   \
-  $(am__rst_section) >$@;                              \
-cat address@hidden >>$@;                                               \
-rm address@hidden
-
-SUFFIXES += .html .log
-
-# From a test (with no extension) to a log file.
-if GNU_MAKE
-%.log: %
-       @src='$<'; $(am__check_pre) "$$dir$$src" $(am__check_post)
-else
-# With POSIX 'make', inference rules cannot have FOO.log depend on FOO.
-# Work around the problem by calculating the dependency dynamically, and
-# then invoking a submake with the calculated dependency.
-CHECK-FORCE:
-DEPENDENCY = CHECK-FORCE
-$(TEST_LOGS): $(DEPENDENCY)
-       @if test '$(DEPENDENCY)' = CHECK-FORCE; then                    \
-         dst=$@; src=$${dst%.log};                                     \
-         test -x "$$src" || src='$(srcdir)'/$$src;                     \
-         exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY="$$src" $@;           \
-       else                                                            \
-         src='$(DEPENDENCY)';                                          \
-         $(am__check_pre) "$$dir$$src" $(am__check_post);              \
-       fi
-endif
-
-#TEST_LOGS = $(TESTS:.test=.log)
-TEST_SUITE_LOG = test-suite.log
-
-$(TEST_SUITE_LOG): $(TEST_LOGS)
-       @$(SH_E_WORKAROUND);                                            \
-       results=$$(for f in $(TEST_LOGS); do sed 1q $$f; done);         \
-       all=$$(echo "$$results" | wc -l | sed -e 's/^[ \t]*//');        \
-       fail=$$(echo "$$results" | grep -c '^FAIL');                    \
-       pass=$$(echo "$$results" | grep -c '^PASS');                    \
-       skip=$$(echo "$$results" | grep -c '^SKIP');                    \
-       xfail=$$(echo "$$results" | grep -c '^XFAIL');                  \
-       xpass=$$(echo "$$results" | grep -c '^XPASS');                  \
-       failures=$$(expr $$fail + $$xpass);                             \
-       case fail=$$fail:xpass=$$xpass:xfail=$$xfail in                 \
-         fail=0:xpass=0:xfail=0)                                       \
-           msg="All $$all tests passed.  ";                            \
-           exit=true;;                                                 \
-         fail=0:xpass=0:xfail=*)                                       \
-           msg="All $$all tests behaved as expected";                  \
-           msg="$$msg ($$xfail expected failures).  ";                 \
-           exit=true;;                                                 \
-         fail=*:xpass=0:xfail=*)                                       \
-           msg="$$fail of $$all tests failed.  ";                      \
-           exit=false;;                                                \
-         fail=*:xpass=*:xfail=*)                                       \
-           msg="$$failures of $$all tests did not behave as expected"; \
-           msg="$$msg ($$xpass unexpected passes).  ";                 \
-           exit=false;;                                                \
-         *)                                                            \
-            echo >&2 "incorrect case"; exit 4;;                                
\
-       esac;                                                           \
-       if test "$$skip" -ne 0; then                                    \
-         msg="$$msg($$skip tests were not run).  ";                    \
-       fi;                                                             \
-       if test "$$failures" -ne 0; then                                \
-         {                                                             \
-           echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" |     \
-             $(am__rst_title);                                         \
-           echo "$$msg";                                               \
-           echo;                                                       \
-           echo ".. contents:: :depth: 2";                             \
-           echo;                                                       \
-           for f in $(TEST_LOGS);                                      \
-           do                                                          \
-             case $$(sed 1q $$f) in                                    \
-               SKIP:*|PASS:*|XFAIL:*);;                                \
-               *) echo; cat $$f;;                                      \
-             esac;                                                     \
-           done;                                                       \
-         } >$(TEST_SUITE_LOG).tmp;                                     \
-         mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);                   \
-         msg="$${msg}See $(subdir)/$(TEST_SUITE_LOG).  ";              \
-         if test -n "$(PACKAGE_BUGREPORT)"; then                       \
-           msg="$${msg}Please report it to $(PACKAGE_BUGREPORT).  ";   \
-         fi;                                                           \
-       fi;                                                             \
-       $(am__tty_colors);                                              \
-       if $$exit; then echo $$grn; else echo $$red; fi;                \
-         echo "$$msg" | $(am__text_box);                               \
-       echo $$std;                                                     \
-       test x"$$VERBOSE" = x || $$exit || cat $(TEST_SUITE_LOG);       \
-       $$exit
-
-# if test x"$$VERBOSE" != x && ! $exit; then
-
-# Run all the tests.
-check-TESTS:
-       @if test -z '$(LAZY_TEST_SUITE)'; then  \
-         rm -f $(TEST_SUITE_LOG) $(TEST_LOGS); \
-       fi
-       @$(MAKE) $(TEST_SUITE_LOG)
-
-
-## -------------- ##
-## Produce HTML.  ##
-## -------------- ##
-
-TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
-
-.log.html:
-       @for r2h in $(RST2HTML) $$RST2HTML rst2html rst2html.py;        \
-       do                                                              \
-         if ($$r2h --version) >/dev/null 2>&1; then                    \
-           R2H=$$r2h;                                                  \
-         fi;                                                           \
-       done;                                                           \
-       if test -z "$$R2H"; then                                        \
-         echo >&2 "cannot find rst2html, cannot create $@";            \
-         exit 2;                                                       \
-       fi;                                                             \
-       $$R2H $< >address@hidden
-       @mv address@hidden $@
-
-# Be sure to run check-TESTS first, and then to convert the result.
-# Beware of concurrent executions.  And expect check-TESTS to fail.
-check-html:
-       @if $(MAKE) $(AM_MAKEFLAGS) check-TESTS; then :; else   \
-         rv=$$?;                                               \
-         $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_HTML);           \
-         exit $$rv;                                            \
-       fi
-
-.PHONY: check-html
-
-
-## ------- ##
-## Clean.  ##
-## ------- ##
-
-check-clean:
-       rm -f $(CHECK_CLEANFILES) $(TEST_SUITE_LOG) $(TEST_SUITE_HTML) 
$(TEST_LOGS)
-.PHONY: check-clean
-clean-local: check-clean
diff --git a/gnulib-tests/Makefile.am b/gnulib-tests/Makefile.am
index 7523e0d..1693c3b 100644
--- a/gnulib-tests/Makefile.am
+++ b/gnulib-tests/Makefile.am
@@ -1,6 +1,3 @@
 include gnulib.mk

-TEST_LOGS = $(TESTS:=.log)
-
-# Parallel replacement of Automake's check-TESTS target.
-include $(top_srcdir)/build-aux/check.mk
+AUTOMAKE_OPTIONS += parallel-tests color-tests
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6356eaa..54b07ba 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -587,5 +587,5 @@ pr_data =                                   \
   pr/ttb3-FF                                   \
   pr/w72l24f-ll

-AUTOMAKE_OPTIONS =
+AUTOMAKE_OPTIONS = parallel-tests color-tests
 include $(srcdir)/check.mk
diff --git a/tests/check.mk b/tests/check.mk
index db5f900..a000eaa 100644
--- a/tests/check.mk
+++ b/tests/check.mk
@@ -58,7 +58,7 @@ TESTS_ENVIRONMENT =                           \
       if $(PERL) -e 'use warnings' > /dev/null 2>&1; then              \
        grep '^\#!/usr/bin/perl -T' "$$1" > /dev/null && T_=T || T_=;   \
         $(PERL) -w$$T_ -I$(srcdir) -MCoreutils                         \
-             -M"CuTmpdir qw($$tst)" -- "$$1";  \
+             -M"CuTmpdir qw($$f)" -- "$$1";    \
       else                                     \
        echo 1>&2 "$$tst: configure did not find a usable version of Perl," \
          "so skipping this test";              \
@@ -94,10 +94,4 @@ TESTS_ENVIRONMENT =                          \
   PATH='$(abs_top_builddir)/src$(PATH_SEPARATOR)'"$$PATH" \
   ; shell_or_perl_

-TEST_LOGS = $(TESTS:=.log)
-
-# Parallel replacement of Automake's check-TESTS target.
-SUFFIXES =
-include $(top_srcdir)/build-aux/check.mk
-
 VERBOSE = yes
--
1.6.2.rc1.285.gc5f54


>From 30071248c9e1132b4d5d9559f97b6199cc91556e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 30 Mar 2009 09:47:07 +0200
Subject: [PATCH 2/3] tests: enable automake's color-tests and parallel-tests 
via configure.ac

* gnulib-tests/Makefile.am (AUTOMAKE_OPTIONS): Don't define here.
* tests/Makefile.am (AUTOMAKE_OPTIONS): Likewise.
* configure.ac (AM_INIT_AUTOMAKE): Instead, add color-tests and
parallel-tests here.
---
 configure.ac             |    2 +-
 gnulib-tests/Makefile.am |    2 --
 tests/Makefile.am        |    1 -
 3 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index f3172ad..71f29e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ AC_CONFIG_SRCDIR([src/ls.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])

-AM_INIT_AUTOMAKE([1.10a dist-xz])
+AM_INIT_AUTOMAKE([1.10a dist-xz color-tests parallel-tests])

 AC_PROG_CC_STDC
 AM_PROG_CC_C_O
diff --git a/gnulib-tests/Makefile.am b/gnulib-tests/Makefile.am
index 1693c3b..6635f70 100644
--- a/gnulib-tests/Makefile.am
+++ b/gnulib-tests/Makefile.am
@@ -1,3 +1 @@
 include gnulib.mk
-
-AUTOMAKE_OPTIONS += parallel-tests color-tests
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 54b07ba..2e2a5f0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -587,5 +587,4 @@ pr_data =                                   \
   pr/ttb3-FF                                   \
   pr/w72l24f-ll

-AUTOMAKE_OPTIONS = parallel-tests color-tests
 include $(srcdir)/check.mk
--
1.6.2.rc1.285.gc5f54


>From 1417251e296226e34d25d8ca8c2b99d12c2c21f0 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 31 Mar 2009 20:43:35 +0200
Subject: [PATCH 3/3] build: set automake's silent-rules option via configure.ac

* bootstrap: Revert commit 9f39fa855, 2009-03-28,
"build: use automake's --silent-rules option when possible".
* configure.ac (AM_INIT_AUTOMAKE): Instead, set it here.
Require the just-released version of automake: 1.10b.
---
 bootstrap    |    8 +-------
 configure.ac |    2 +-
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/bootstrap b/bootstrap
index e834a2b..27e4ec2 100755
--- a/bootstrap
+++ b/bootstrap
@@ -686,12 +686,6 @@ find "$m4_base" "$source_base" \
   -depth \( -name '*.m4' -o -name '*.[ch]' \) \
   -type l -xtype l -delete > /dev/null 2>&1

-# Use automake's --silent-rules option, if possible.
-automake="${AUTOMAKE-automake} --add-missing --copy --force-missing"
-(${AUTOMAKE-automake} --help) 2>&1 \
-    | grep -e '^  *--silent-rules' > /dev/null \
-  && automake="$automake --silent-rules"
-
 # Reconfigure, getting other files.

 for command in \
@@ -699,7 +693,7 @@ for command in \
   "${ACLOCAL-aclocal} --force -I m4" \
   "${AUTOCONF-autoconf} --force" \
   "${AUTOHEADER-autoheader} --force" \
-  "$automake"
+  "${AUTOMAKE-automake} --add-missing --copy --force-missing"
 do
   if test "$command" = libtool; then
     use_libtool=0
diff --git a/configure.ac b/configure.ac
index 71f29e9..8d9bcaf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,7 @@ AC_CONFIG_SRCDIR([src/ls.c])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_HEADERS([lib/config.h:lib/config.hin])

-AM_INIT_AUTOMAKE([1.10a dist-xz color-tests parallel-tests])
+AM_INIT_AUTOMAKE([1.10b dist-xz color-tests parallel-tests silent-rules])

 AC_PROG_CC_STDC
 AM_PROG_CC_C_O
--
1.6.2.rc1.285.gc5f54




reply via email to

[Prev in Thread] Current Thread [Next in Thread]