From df04f5357a0c7146d7ec1c4fcd8c11a42feb5e01 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Fri, 25 Aug 2023 18:00:27 -0500 Subject: [PATCH] Switch to the preferred parallel automake test harness Automake "strongly discourages" use of the serial driver, and switching to the preferred parallel driver allows make -j4 check to run in about half the time on a four core (not thread) host. * Makefile.am (TESTS, TESTS_ENVIRONMENT): run ./check-guile from test-suite/, not here. * check-guile.in: let test harness handle progress output. * configure.ac (AM_INIT_AUTOMAKE): allow parallel testing. * test-suite/Makefile.am (SCM_TESTS): remove non-tests. (EXTRA_DIST): move non-tests here. (TESTS): include SCM_TESTS (now driven from here). (TEST_EXTENSIONS): allow customization for .scm and .test. (TESTS_ENVIRONMENT): stop defining (user only). (AM_TESTS_ENVIRONMENT): replaces TESTS_ENVIRONMENT; drop guile. (SCM_LOG_COMPILER): run .scm tests via meta/guile. (AM_SCM_LOG_FLAGS): keep --no-auto-compile for .scm tests. (TEST_LOG_DRIVER): run .test tests via custom automake ./driver. * test-suite/driver: add automake test driver. --- Makefile.am | 3 --- check-guile.in | 5 +--- configure.ac | 5 +--- test-suite/Makefile.am | 21 ++++++++++----- test-suite/driver | 58 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 18 deletions(-) create mode 100755 test-suite/driver diff --git a/Makefile.am b/Makefile.am index eb3541c34..b2ac5539e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -85,9 +85,6 @@ EXTRA_DIST = LICENSE HACKING GUILE-VERSION \ .guix/modules/guile-package.scm \ .guix/manifest.scm -TESTS = check-guile -TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@ - ACLOCAL_AMFLAGS = -I m4 CLEANFILES = libguile/guile-procedures.txt diff --git a/check-guile.in b/check-guile.in index 5a7beee8a..8e5b526a5 100644 --- a/check-guile.in +++ b/check-guile.in @@ -26,10 +26,7 @@ fi export GUILE_LOAD_PATH="$TEST_SUITE_DIR" -if [ -f "$guile" -a -x "$guile" ] ; then - echo "Testing $guile ..." "$@" - echo "with GUILE_LOAD_PATH=$GUILE_LOAD_PATH" -else +if ! [ -f "$guile" -a -x "$guile" ] ; then echo "ERROR: Cannot execute $guile" 1>&2 exit 2 fi diff --git a/configure.ac b/configure.ac index 7dad1af7a..0dcb71cce 100644 --- a/configure.ac +++ b/configure.ac @@ -33,11 +33,8 @@ AC_CONFIG_SRCDIR(GUILE-VERSION) AC_CANONICAL_TARGET -dnl Use `serial-tests' so the output `check-guile' is not hidden -dnl (`parallel-tests' is the default in Automake 1.13.) -dnl `serial-tests' was introduced in Automake 1.12. AM_INIT_AUTOMAKE([1.12 gnu no-define -Wall -Wno-override \ - serial-tests color-tests dist-lzip dist-xz]) + color-tests dist-lzip dist-xz]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],1)]) AC_COPYRIGHT(GUILE_CONFIGURE_COPYRIGHT) diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index 247d97746..f5d7471c7 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -77,9 +77,7 @@ SCM_TESTS = tests/00-initial-env.test \ tests/list.test \ tests/load.test \ tests/match.test \ - tests/match.test.upstream \ tests/modules.test \ - tests/multilingual.nottest \ tests/net-db.test \ tests/numbers.test \ tests/optargs.test \ @@ -93,7 +91,6 @@ SCM_TESTS = tests/00-initial-env.test \ tests/procs.test \ tests/poe.test \ tests/popen.test \ - tests/popen-child.scm \ tests/ports.test \ tests/posix.test \ tests/q.test \ @@ -207,6 +204,9 @@ EXTRA_DIST = \ guile-test \ test-suite/lib.scm \ $(SCM_TESTS) \ + tests/match.test.upstream \ + tests/multilingual.nottest \ + tests/popen-child.scm \ tests/rnrs-test-a.scm \ tests/srfi-64-test.scm \ ChangeLog-2008 @@ -249,9 +249,16 @@ LALR_EXTRA += \ lalr/glr-test.scm \ lalr/run-guile-test.sh -TESTS = $(LALR_TESTS) -TESTS_ENVIRONMENT = \ - @LOCALCHARSET_TESTS_ENVIRONMENT@ \ - $(top_builddir)/meta/guile --no-auto-compile +TESTS = $(LALR_TESTS) $(SCM_TESTS) +TEST_EXTENSIONS = .scm .test +AM_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@ + +# Run *.scm tests with meta/guile +SCM_LOG_COMPILER = $(top_builddir)/meta/guile +AM_SCM_LOG_FLAGS = --no-auto-compile + +# Use a custom driver for *.test (assume they use (test-suite lib)). +# See the automake info pages regarding "Custom Test Drivers". +TEST_LOG_DRIVER = ./driver EXTRA_DIST += $(LALR_EXTRA) $(LALR_TESTS) tests/sxml-match-tests.ss diff --git a/test-suite/driver b/test-suite/driver new file mode 100755 index 000000000..0f2710cd5 --- /dev/null +++ b/test-suite/driver @@ -0,0 +1,58 @@ +#!/bin/sh + +set -ue + +script_home="$(cd "$(dirname "$0")" && pwd)" + +usage() +{ + cat <<-EOF + Usage: driver [OPTION ...] -- TEST [ARG ...] + This is a test + Options: + --log-file PATH + --trs-file PATH + --color-tests (yes|no) currently ignored + --expect-failure (yes|no) currently ignored + --enable-hard-errors (yes|no) currently ignored + --test-name NAME currently ignored + + This command provides an Automake parallel test harness + compatible driver for running TEST with Guile. This is + essentially an adapter for check-guile and it currently + assumes that check-guile is in the parent directory. + + EOF +} + +misuse() { usage 1>&2; exit 2; } + +test_name='' +log_file='' +trs_file='' + +while test $# -gt 0; do + case "$1" in + --test-name) test $# -gt 1 || misuse; test_name="$2"; shift 2 ;; + --log-file) test $# -gt 1 || misuse; log_file="$2"; shift 2 ;; + --trs-file) test $# -gt 1 || misuse; trs_file="$2"; shift 2 ;; + --color-tests|--expect-failure|--enable-hard-errors) shift 2 ;; + --) shift; break ;; + *) break ;; + esac +done + +test "$test_name" || misuse +test "$log_file" || misuse +test "$trs_file" || misuse + +test $# -gt 0 || misuse +program="$1" +shift + +cd .. + +exec ./check-guile \ + --log-file "test-suite/$log_file" \ + --trs-file "test-suite/$trs_file" \ + "$(basename "$program")"