diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-08-30 14:13:13 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-08-30 18:55:59 +0200 |
commit | 4af32c62fa58570a97d705fc0340704e9faa1a1f (patch) | |
tree | 92185cce051fef767028af7b8cc9a7f9298b83f5 | |
parent | 9eb4c31eb78c28dd9f72d1cbb940270311be343c (diff) | |
download | coreutils-4af32c62fa58570a97d705fc0340704e9faa1a1f.tar.xz |
tests: get rid of the 'shell-or-perl' auxiliary script
It's now easier and faster to simply run the perl ans shell test
scripts directly with the appropriate interpreter and options.
* tests/shell-or-perl: Delete.
* tests/Makefile.am (EXTRA_DIST): Remove it.
(SH_LOG_COMPILER): Re-define to invoke the correct shell.
(PL_LOG_COMPILER): Re-define to invoke the correct perl
interpreter ...
(TESTSUITE_PERL_OPTIONS): ... with the correct options.
(XPL_LOG_COMPILER): Use those options instead of inlining
their expansion.
(LOG_COMPILER): Delete, no longer needed.
-rw-r--r-- | tests/Makefile.am | 22 | ||||
-rw-r--r-- | tests/shell-or-perl | 109 |
2 files changed, 9 insertions, 122 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index a547b1181..bc3d30892 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -53,22 +53,19 @@ else TESTSUITE_PERL = $(SHELL) $(srcdir)/no-perl endif +# Options passed to the perl invocations running the perl test scripts. +TESTSUITE_PERL_OPTIONS = -w -I$(srcdir) -MCoreutils -MCuSkip # '$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 -# used. Note that $f is a shell variable, not a make macro, so the use of -# '$$f' below is correct, and not a typo. -LOG_COMPILER = \ - $(SHELL) $(srcdir)/shell-or-perl \ - --test-name "$$f" --srcdir '$(srcdir)' \ - --shell '$(SHELL)' --perl '$(TESTSUITE_PERL)' -- - -PL_LOG_COMPILER = $(LOG_COMPILER) -SH_LOG_COMPILER = $(LOG_COMPILER) +# CuTmpdir module to determine the name of the temporary files to be +# used. Note that $f is a shell variable, not a make macro, so the use +# of '$$f' below is correct, and not a typo. +TESTSUITE_PERL_OPTIONS += -M"CuTmpdir qw($$f)" +SH_LOG_COMPILER = $(SHELL) +PL_LOG_COMPILER = $(TESTSUITE_PERL) $(TESTSUITE_PERL_OPTIONS) # Perl scripts that must be run in tainted mode. -XPL_LOG_COMPILER = \ - $(TESTSUITE_PERL) -wT -I$(srcdir) -MCoreutils -MCuSkip -M"CuTmpdir qw($$f)" +XPL_LOG_COMPILER = $(TESTSUITE_PERL) -T $(TESTSUITE_PERL_OPTIONS) # Note that the first lines are statements. They ensure that environment # variables that can perturb tests are unset or set to expected values. @@ -130,7 +127,6 @@ EXTRA_DIST = \ no-perl \ other-fs-tmpdir \ sample-test \ - shell-or-perl \ $(pr_data) root_tests = \ diff --git a/tests/shell-or-perl b/tests/shell-or-perl deleted file mode 100644 index 409db0ee7..000000000 --- a/tests/shell-or-perl +++ /dev/null @@ -1,109 +0,0 @@ -#! /bin/sh -# Run a test script of the coreutils test scripts, picking up the right -# interpreter (i.e., perl or the shell) and the right flags for it. -# -# Copyright (C) 2011-2012 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 3 of the License, 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/>. -# - -# ---------------------------------- # -# Readonly variables and functions # -# ---------------------------------- # - -# Help to avoid typo-related bugs. -set -u - -me=shell-or-perl - -fatal_ () -{ - echo "$me: $*" >&2 - # Exit with status '99' to inform the testsuite harness that an - # hard error occurred. - exit 99 -} - -print_help_ () -{ - cat <<EOH -Usage: $me [--help] [--srcdir DIR] [--shell SHELL-CMD] [--perl PERL-CMD] - [--test-name NAME-WITHOUT-VPATH] TEST-SCRIPT [ARGS..] -EOH -} - -# ---------------- # -# Option parsing # -# ---------------- # - -assign_optarg_to_var=' - test $# -gt 1 || fatal_ "option '\''$1'\'' requires an argument" - eval "$var=\$2" - shift' - -srcdir=${srcdir-.} -cu_PERL=${PERL-perl} -cu_SHELL=/bin/sh # Getting $SHELL from the environment is dangerous. -test_name= -while test $# -gt 0; do - var= - case $1 in - --help) print_help_; exit $?;; - --shell) var=cu_SHELL;; - --perl) var=cu_PERL;; - --srcdir) var=srcdir;; - --test-name) var=test_name;; - --) shift; break;; - -*) fatal_ "unknown option '$1'";; - *) break;; - esac - test -z "$var" || eval "$assign_optarg_to_var" - shift -done - -unset assign_optarg_to_var var - -case $# in - 0) fatal_ "missing argument";; - *) test_script=$1; shift;; -esac - -test -z "$test_name" && test_name=$test_script - -# --------------------- # -# Run the test script # -# --------------------- # - -test -f "$test_script" && test -r "$test_script" \ - || fatal_ "test script '$test_script' does not exist, or isn't readable" - -read shebang_line < "$test_script" \ - || fatal_ "cannot read from the test script '$test_script'" - -case $shebang_line in -'#!/usr/bin/perl'*) - # The test is a perl script. - exec $cu_PERL -w -I"$srcdir" -MCoreutils -MCuSkip \ - -M"CuTmpdir qw($test_name)" -- "$test_script" ${1+"$@"} - ;; -*) - # Assume the test is a shell script. - exec $cu_SHELL "$test_script" ${1+"$@"} -esac - -# ------------- # -# Not reached # -# ------------- # - -fatal_ "dead code reached" |