[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/7] tests: detect missing perl at configure runtime
From: |
Stefano Lattarini |
Subject: |
[PATCH 5/7] tests: detect missing perl at configure runtime |
Date: |
Thu, 30 Aug 2012 14:13:11 +0200 |
* configure.ac (AM_CONDITIONAL): Se the conditional 'HAVE_PERL' to
true if the configure-time checks (as run by gl_PERL) have been able
to find a working perl.
* tests/no-perl: New script, report a diagnostic about "missing perl"
and exit with status 77.
* tests/Makefile.am (EXTRA_DIST): Distribute it.
(TESTSUITE_PERL): New, define to '$(PERL)' if a perl interpreter has
been found at configure time (i.e., if the 'HAVE_PERL' automake
conditional is true), and to '$(srcdir)/no-perl' otherwise.
(LOG_COMPILER): Use $(TESTSUITE_PERL) instead of $(PERL).
(XPL_LOG_COMPILER): Likewise.
* tests/shell-of-perl: Simplify: no need to actually check whether
perl is working.
---
configure.ac | 7 +++++++
tests/Makefile.am | 11 +++++++++--
tests/no-perl | 6 ++++++
tests/shell-or-perl | 11 ++---------
4 files changed, 24 insertions(+), 11 deletions(-)
create mode 100644 tests/no-perl
diff --git a/configure.ac b/configure.ac
index 11c84f5..a12b4c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,13 @@ gl_EARLY
gl_INIT
coreutils_MACROS
+# The testsuite need to know if we have a working perl.
+# FIXME: this is suboptimal. Ideally, we should be able to call gl_PERL
+# with a ACTION-IF-NOT-FOUND argument ...
+cu_have_perl=yes
+case $PERL in *"/missing ") cu_have_perl=no;; esac
+AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes])
+
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on lots of GCC warnings (for developers)])],
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 581f803..ff0af84 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,6 +47,12 @@ check_DATA = .built-programs
TEST_EXTENSIONS = .xpl
+if HAVE_PERL
+TESTSUITE_PERL = $(PERL)
+else
+TESTSUITE_PERL = $(SHELL) $(srcdir)/no-perl
+endif
+
# '$f' is set by the Automake-generated test harness to the path of the
# current test script stripped of VPATH components, and is used by the
# shell-or-perl script to determine the name of the temporary files to be
@@ -55,11 +61,11 @@ TEST_EXTENSIONS = .xpl
LOG_COMPILER = \
$(SHELL) $(srcdir)/shell-or-perl \
--test-name "$$f" --srcdir '$(srcdir)' \
- --shell '$(SHELL)' --perl '$(PERL)' --
+ --shell '$(SHELL)' --perl '$(TESTSUITE_PERL)' --
# Perl scripts that must be run in tainted mode.
XPL_LOG_COMPILER = \
- $(PERL) -wT -I$(srcdir) -MCoreutils -MCuSkip -M"CuTmpdir qw($$f)"
+ $(TESTSUITE_PERL) -wT -I$(srcdir) -MCoreutils -MCuSkip -M"CuTmpdir qw($$f)"
# Note that the first lines are statements. They ensure that environment
# variables that can perturb tests are unset or set to expected values.
@@ -118,6 +124,7 @@ EXTRA_DIST = \
init.cfg \
init.sh \
lang-default \
+ no-perl \
other-fs-tmpdir \
sample-test \
shell-or-perl \
diff --git a/tests/no-perl b/tests/no-perl
new file mode 100644
index 0000000..110cf51
--- /dev/null
+++ b/tests/no-perl
@@ -0,0 +1,6 @@
+#! /bin/sh
+# Perl is not available, the test should be considered skipped.
+# The FD 9 should have been opened the testsuite harness, pointing
+# to the original stderr (usually, the user's terminal).
+echo "test skipped: no usable version of Perl found" >&9
+exit 77
diff --git a/tests/shell-or-perl b/tests/shell-or-perl
index cb80edf..409db0e 100644
--- a/tests/shell-or-perl
+++ b/tests/shell-or-perl
@@ -94,15 +94,8 @@ read shebang_line < "$test_script" \
case $shebang_line in
'#!/usr/bin/perl'*)
# The test is a perl script.
- if $cu_PERL -e 'use warnings' > /dev/null 2>&1; then
- exec $cu_PERL -w -I"$srcdir" -MCoreutils -MCuSkip \
- -M"CuTmpdir qw($test_name)" \
- -- "$test_script" ${1+"$@"}
- else
- # Perl is not available, skip the test.
- echo "$test_name: skip: no usable version of Perl found"
- exit 77
- fi
+ exec $cu_PERL -w -I"$srcdir" -MCoreutils -MCuSkip \
+ -M"CuTmpdir qw($test_name)" -- "$test_script" ${1+"$@"}
;;
*)
# Assume the test is a shell script.
--
1.7.12
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, (continued)
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Bernhard Voelker, 2012/08/30
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Jim Meyering, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Bernhard Voelker, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Stefano Lattarini, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Jim Meyering, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Bernhard Voelker, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Jim Meyering, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Bernhard Voelker, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Erik Auerswald, 2012/08/31
- Re: [PATCH 3/7] build: require Automake >= 1.11.6, Jim Meyering, 2012/08/31
[PATCH 5/7] tests: detect missing perl at configure runtime,
Stefano Lattarini <=
[PATCH 6/7] tests: add .sh and .pl suffixes to shell and perl tests, respectively, Stefano Lattarini, 2012/08/30