diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-07-25 18:14:23 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-07-26 14:11:33 +0200 |
commit | ecbceb3e4cb88019e490c4814ca7a7382e4e2299 (patch) | |
tree | 428f75bf2d28fe5bac8f1d06d46e2d596ed0824f /t | |
parent | 69f0f0a143dd9e8ddf45da1b0db2a99f305f2202 (diff) | |
download | automake-ecbceb3e4cb88019e490c4814ca7a7382e4e2299.tar.gz |
test defs: move in 't/ax/test-defs.sh'
We can do so with minimal churn, now that the early setup of $PATH in
both 'runtest' and AM_TESTS_ENVIRONMENT allow the '.' built-in to find
to-be-sourced shell scripts in 't/ax' automatically, both in in-tree
and VPATH builds.
With this change, we take another step forward a more rational and
"segregated" organization of our testsuite framework.
* defs-static.in: Rename ...
* t/ax/test-defs.in: ... like this, and adjust.
* Makefile.am, syntax-checks.mk, t/README, gen-testsuite-part,
t/tests-init.sh, t/ax/tap-setup.sh, t/tap-summary.sh, .gitignore,
t/testsuite-summary-color.sh, t/testsuite-summary-count.sh,
t/self-check-tap.sh, defs: Adjust.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't')
-rw-r--r-- | t/README | 2 | ||||
-rw-r--r-- | t/ax/tap-setup.sh | 2 | ||||
-rw-r--r-- | t/ax/test-defs.in | 246 | ||||
-rw-r--r-- | t/ax/test-init.sh | 8 | ||||
-rwxr-xr-x | t/self-check-tap.sh | 26 | ||||
-rwxr-xr-x | t/tap-summary-color.sh | 2 | ||||
-rwxr-xr-x | t/tap-summary.sh | 2 | ||||
-rwxr-xr-x | t/testsuite-summary-color.sh | 2 | ||||
-rwxr-xr-x | t/testsuite-summary-count.sh | 2 |
9 files changed, 269 insertions, 23 deletions
@@ -234,7 +234,7 @@ Writing test cases example, if you need to copy or grep an automake-provided script, do not assume that they can be found in the '$top_srcdir/lib' directory, but use '$am_scriptdir' instead. The complete list of - such "$am_...dir" variables can be found in the 'defs-static.in' + such "$am_...dir" variables can be found in the 't/ax/test-defs.in' file. * When writing input for lex, include the following in the definitions diff --git a/t/ax/tap-setup.sh b/t/ax/tap-setup.sh index 70487c3e5..952a49dfa 100644 --- a/t/ax/tap-setup.sh +++ b/t/ax/tap-setup.sh @@ -22,7 +22,7 @@ # Check that we are running from a proper directory: last thing we want # is to overwrite some random user files. -test -f ../../defs-static && test -f ../../defs && test -d ../../t \ +test -f ../../automake && test -f ../../defs && test -d ../../t \ || fatal_ "running from a wrong directory" test ! -f Makefile.am || mv Makefile.am Makefile.am~ \ diff --git a/t/ax/test-defs.in b/t/ax/test-defs.in new file mode 100644 index 000000000..c5b0a5483 --- /dev/null +++ b/t/ax/test-defs.in @@ -0,0 +1,246 @@ +# -*- shell-script -*- +# @configure_input@ +# +# Copyright (C) 1996-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 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/>. + +# Defines and minimal setup for Automake testing environment. + +# IMPORTANT NOTES AND REQUIREMENTS +# - Multiple inclusions of this file should be idempotent. +# - This code has to be 'set -e' clean. + +# CDPATH is evil if used in non-interactive scripts (and even more +# evil if exported in the environment). +CDPATH=; unset CDPATH + +# Be more Bourne compatible. +# (Snippet inspired to configure's initialization in Autoconf 2.64) +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + setopt NO_GLOB_SUBST + # If Zsh is not started directly in POSIX-compatibility mode, it has some + # incompatibilities in the handling of $0 that conflict with our usage; + # i.e., $0 inside a file sourced with the '.' builtin is temporarily set + # to the name of the sourced file. Work around that. + # Note that a bug in some versions of Zsh prevents us from resetting $0 + # in a sourced script, so the use of $argv0. For more info see: + # <http://www.zsh.org/mla/workers/2009/msg01140.html> + # The apparently useless 'eval' here is needed by at least dash 0.5.2, + # to prevent it from bailing out with an error like: + # "Syntax error: Bad substitution". + eval 'argv0=${functrace[-1]%:*}' && test -f "$argv0" || { + echo "Cannot determine the path of running test script." >&2 + echo "Your Zsh (version $ZSH_VERSION) is probably too old." >&2 + exit 99 + } +else + argv0=$0 + # Avoid command substitution failure, for Tru64 sh -e and instspc*.test. + case `(set -o) 2>/dev/null || :` in *posix*) set -o posix;; esac +fi + +# The name of the current test (without the '.sh' or '.tap' suffix). +me=${argv0##*/} # Strip all directory components. +case $me in # Strip test suffix. + *.tap) me=${me%.tap};; + *.sh) me=${me%.sh} ;; + esac + +# Check that the environment is properly sanitized. +# Having variables exported to the empty string is OK, since our code +# treats such variables as if they were unset. +for var in \ + required \ + am_using_tap \ + am_serial_tests \ + am_create_testdir \ + am_tap_implementation \ + am_test_prefer_config_shell \ + am_original_AUTOMAKE \ + am_original_ACLOCAL \ +; do + if eval "test x\"\$$var\" != x" && env | grep "^$var=" >/dev/null; then + echo "$me: variable '$var' is set in the environment:" \ + "this is unsafe" >&2 + exit 99 + fi +done +unset var + +# See whether the current test script is expected to use TAP or not. +# Use a sensible default, while allowing the scripts to override this +# check. +if test -z "$am_using_tap"; then + case $argv0 in *.tap) am_using_tap=yes;; *) am_using_tap=no;; esac +fi + +am_rel_srcdir='@srcdir@' +am_top_srcdir='@abs_srcdir@' +am_top_builddir='@abs_builddir@' + +# Where testsuite-related helper scripts, data files and shell libraries +# are placed. +am_testauxdir=$am_top_srcdir/t/ax + +# Support for the "installcheck" target. +case ${am_running_installcheck:=no} in + yes) + am_amdir='@amdir@' + am_automake_acdir='@automake_acdir@' + am_bindir='@bindir@' + am_datadir='@datadir@' + am_docdir='@docdir@' + am_pkgvdatadir='@pkgvdatadir@' + am_scriptdir='@scriptdir@' + am_system_acdir='@system_acdir@' + ;; + no) + am_amdir=$am_top_srcdir/lib/am + am_automake_acdir=$am_top_srcdir/m4 + am_bindir=$am_top_builddir/t/wrap + am_datadir=$am_top_srcdir + am_docdir=$am_top_srcdir/doc + am_pkgvdatadir=$am_top_srcdir/lib + am_scriptdir=$am_top_srcdir/lib + am_system_acdir=$am_top_srcdir/m4/acdir + ;; + *) + echo "$me: variable 'am_running_installcheck' has invalid" + "value '$am_running_installcheck'" >&2 + exit 99 + ;; +esac + +APIVERSION='@APIVERSION@' +PATH_SEPARATOR='@PATH_SEPARATOR@' + +host_alias=${host_alias-'@host_alias@'}; export host_alias +build_alias=${build_alias-'@build_alias@'}; export build_alias + +# A concurrency-safe "mkdir -p" implementation. +MKDIR_P=${AM_TESTSUITE_MKDIR_P-'@MKDIR_P@'} + +# The shell we use to run our own test scripts, determined at configure +# time. It is required in the self tests, and most importantly for the +# automatic re-execution of test scripts. +AM_TEST_RUNNER_SHELL=${AM_TEST_RUNNER_SHELL-'@AM_TEST_RUNNER_SHELL@'} + +# Make sure we override the user shell. And do not read the value of +# $SHELL from the environment (think to the non-uncommon situation where +# e.g., $SHELL=/bin/tcsh). +SHELL=${AM_TESTSUITE_SHELL-'@SHELL@'}; export SHELL + +# User can override various tools used. Prefer overriding specific for +# that automake testsuite, if they are available. +AWK=${AM_TESTSUITE_AWK-${AWK-'@AWK@'}} +PERL=${AM_TESTSUITE_PERL-${PERL-'@PERL@'}} +MAKE=${AM_TESTSUITE_MAKE-${MAKE-'make'}} +YACC=${AM_TESTSUITE_YACC-${YACC-'@YACC@'}} +LEX=${AM_TESTSUITE_LEX-${LEX-'@LEX@'}} +AUTOCONF=${AM_TESTSUITE_AUTOCONF-${AUTOCONF-'@am_AUTOCONF@'}} +AUTOM4TE=${AM_TESTSUITE_AUTOM4TE-${AUTOM4TE-'@am_AUTOM4TE@'}} +AUTORECONF=${AM_TESTSUITE_AUTORECONF-${AUTORECONF-'@am_AUTORECONF@'}} +AUTOHEADER=${AM_TESTSUITE_AUTOHEADER-${AUTOHEADER-'@am_AUTOHEADER@'}} +AUTOUPDATE=${AM_TESTSUITE_AUTOUPDATE-${AUTOUPDATE-'@am_AUTOUPDATE@'}} + +# Tests who want complete control over aclocal or automake command-line +# options should use $am_original_ACLOCAL or $am_original_AUTOMAKE. The +# "test -z" tests take care not to re-initialize them if 'test-defs.sh' +# is re-sourced, as we want that file to remain really idempotent. +if test -z "$am_original_AUTOMAKE"; then + am_original_AUTOMAKE=${AM_TESTSUITE_AUTOMAKE-${AUTOMAKE-"automake-$APIVERSION"}} +fi +if test -z "$am_original_ACLOCAL"; then + am_original_ACLOCAL=${AM_TESTSUITE_ACLOCAL-${ACLOCAL-"aclocal-$APIVERSION"}} +fi + +# Use -Werror because this also turns some Perl warnings into error. +# Tests for which this is inappropriate should use -Wno-error. +# Tests who want complete control over aclocal command-line options +# should use $am_original_ACLOCAL instead. +ACLOCAL="$am_original_ACLOCAL -Werror" + +# See how Automake should be run. We put --foreign as the default +# strictness to avoid having to create lots and lots of files. A test +# can override this by specifying a different strictness. Use -Wall +# -Werror by default. Tests for which this is inappropriate (e.g. when +# testing that a warning is enabled by a specific switch) should use +# -Wnone or/and -Wno-error. +# Tests who want complete control over automake command-line options +# should use $am_original_AUTOMAKE instead. +AUTOMAKE="$am_original_AUTOMAKE --foreign -Werror -Wall" + +# POSIX no longer requires 'egrep' and 'fgrep', +# but some hosts lack 'grep -E' and 'grep -F'. +EGREP=${AM_TESTSUITE_EGREP-'@EGREP@'} +FGREP=${AM_TESTSUITE_FGREP-'@FGREP@'} + +# Compilers and their flags. These can point to non-GNU compilers (and +# on non-Linux and non-BSD systems, they probably will). +CC=${AM_TESTSUITE_CC-${CC-'@CC@'}} +CXX=${AM_TESTSUITE_CXX-${CXX-'@CXX@'}} +F77=${AM_TESTSUITE_F77-${F77-'@F77@'}} +FC=${AM_TESTSUITE_FC-${FC-'@FC@'}} +CFLAGS=${AM_TESTSUITE_CFLAGS-${CFLAGS-'@CFLAGS@'}} +CXXFLAGS=${AM_TESTSUITE_CXXFLAGS-${CXXFLAGS-'@CXXFLAGS@'}} +FCFLAGS=${AM_TESTSUITE_FCFLAGS-${FCFLAGS-'@FCFLAGS@'}} +FFLAGS=${AM_TESTSUITE_FFLAGS-${FFLAGS-'@FFLAGS@'}} +CPPFLAGS=${AM_TESTSUITE_CPPFLAGS-${CPPFLAGS-'@CPPFLAGS@'}} + +# GNU compilers and their flags. +GNU_CC=${AM_TESTSUITE_GNU_CC-${GNU_CC-'@GNU_CC@'}} +GNU_CXX=${AM_TESTSUITE_GNU_CXX-${GNU_CXX-'@GNU_CXX@'}} +GNU_F77=${AM_TESTSUITE_GNU_F77-${GNU_F77-'@GNU_F77@'}} +GNU_FC=${AM_TESTSUITE_GNU_FC-${GNU_FC-'@GNU_FC@'}} +GNU_FFLAGS=${AM_TESTSUITE_GNU_FFLAGS-${GNU_FFLAGS-'@GNU_FFLAGS@'}} +GNU_FCFLAGS=${AM_TESTSUITE_GNU_FCFLAGS-${GNU_FCFLAGS-'@GNU_FCFLAGS@'}} +GNU_CXXFLAGS=${AM_TESTSUITE_GNU_CXXFLAGS-${GNU_CXXFLAGS-'@GNU_CXXFLAGS@'}} +GNU_CFLAGS=${AM_TESTSUITE_GNU_CFLAGS-${GNU_CFLAGS-'@GNU_CFLAGS@'}} +GNU_GCJ=${AM_TESTSUITE_GNU_GCJ-${GNU_GCJ-'@GNU_GCJ@'}} +GNU_GCJFLAGS=${AM_TESTSUITE_GNU_GCJFLAGS-${GNU_GCJFLAGS-'@GNU_GCJFLAGS@'}} + +# No all versions of Tex support '--version', so we use a configure +# check to decide if tex is available. This decision is embodied in +# this variable. +TEX=${AM_TESTSUITE_TEX-'@TEX@'} + +# The amount we should wait after modifying files depends on the platform. +# For instance, Windows '95, '98 and ME have 2-second granularity +# and can be up to 3 seconds in the future w.r.t. the system clock. +sleep='sleep @MODIFICATION_DELAY@' + +# An old timestamp that can be given to a file, in "touch -t" format. +# The time stamp should be portable to all file systems of interest. +# Just for fun, choose the exact time of the announcement of the GNU project +# in UTC; see <http://www.gnu.org/gnu/initial-announcement.html>. +old_timestamp=198309271735.59 + +# Make our wrapper script (or installed scripts, if running under +# "installcheck") accessible by default. And avoid to uselessly +# extend $PATH multiple times if this file is sourced multiple times. +case $PATH in + $am_bindir$PATH_SEPARATOR*) ;; + *) PATH=$am_bindir$PATH_SEPARATOR$PATH;; +esac + +# Make our helper script accessible by default. +# The '$am_testauxdir' should be defined in the environment of +# our testsuite. +PATH=$am_testauxdir$PATH_SEPARATOR$PATH + +export PATH diff --git a/t/ax/test-init.sh b/t/ax/test-init.sh index a1130e355..5376b4700 100644 --- a/t/ax/test-init.sh +++ b/t/ax/test-init.sh @@ -28,15 +28,15 @@ set -e ## --------------------- ## # Ensure $am_top_srcdir is set correctly. -test -f "$am_top_srcdir/defs-static.in" || { - echo "$me: $am_top_srcdir/defs-static.in not found," \ +test -f "$am_top_srcdir/automake.in" || { + echo "$me: $am_top_srcdir/automake.in not found," \ "check \$am_top_srcdir" >&2 exit 99 } # Ensure $am_top_builddir is set correctly. -test -f "$am_top_builddir/defs-static" || { - echo "$me: $am_top_builddir/defs-static not found," \ +test -f "$am_top_builddir/automake" || { + echo "$me: $am_top_builddir/automake not found," \ "check \$am_top_builddir" >&2 exit 99 } diff --git a/t/self-check-tap.sh b/t/self-check-tap.sh index d7f788c6b..8d846213f 100755 --- a/t/self-check-tap.sh +++ b/t/self-check-tap.sh @@ -15,31 +15,31 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # Sanity check for the automake testsuite. -# Make sure that $am_using_tap gets automatically defined by -# './defs-static', but can be overridden by the individual tests. +# Make sure that '$am_using_tap' gets automatically defined by +# 'test-defs.sh', but can be overridden by the individual tests. -. ./defs-static || exit 1 +. test-defs.sh set -ex $AM_TEST_RUNNER_SHELL -c \ - '. ./defs-static && test $am_using_tap = yes' foo.tap + ". test-defs.sh && test \$am_using_tap = yes" foo.tap for name in foo.test tap tap.test foo-tap; do $AM_TEST_RUNNER_SHELL -c \ - '. ./defs-static && test $am_using_tap = no' $name + ". test-defs.sh && test \$am_using_tap = no" $name done -$AM_TEST_RUNNER_SHELL -c ' +$AM_TEST_RUNNER_SHELL -c " am_using_tap=no - . ./defs-static - test $am_using_tap = no -' foo.tap + . test-defs.sh + test \$am_using_tap = no +" foo.tap -$AM_TEST_RUNNER_SHELL -c ' +$AM_TEST_RUNNER_SHELL -c " am_using_tap=yes - . ./defs-static - test $am_using_tap = yes -' foo.test + . test-defs.sh + test \$am_using_tap = yes +" foo.test : diff --git a/t/tap-summary-color.sh b/t/tap-summary-color.sh index a28512b69..8f533b4d1 100755 --- a/t/tap-summary-color.sh +++ b/t/tap-summary-color.sh @@ -17,7 +17,7 @@ # TAP support: # - colorized testsuite summary -. ./defs-static +. test-defs.sh use_colors=yes . "$am_testauxdir"/tap-summary-aux.sh diff --git a/t/tap-summary.sh b/t/tap-summary.sh index deee09984..846239cfe 100755 --- a/t/tap-summary.sh +++ b/t/tap-summary.sh @@ -17,7 +17,7 @@ # TAP support: # - colorized testsuite summary -. ./defs-static +. test-defs.sh use_colors=no . "$am_testauxdir"/tap-summary-aux.sh diff --git a/t/testsuite-summary-color.sh b/t/testsuite-summary-color.sh index c73ca45f8..e1a747154 100755 --- a/t/testsuite-summary-color.sh +++ b/t/testsuite-summary-color.sh @@ -16,7 +16,7 @@ # Check coloring of the testsuite summary. -. ./defs-static || exit 1 +. test-defs.sh use_colors=yes use_vpath=no diff --git a/t/testsuite-summary-count.sh b/t/testsuite-summary-count.sh index 265eebfa4..a6e546299 100755 --- a/t/testsuite-summary-count.sh +++ b/t/testsuite-summary-count.sh @@ -16,7 +16,7 @@ # Check test counts in the testsuite summary. -. ./defs-static || exit 1 +. test-defs.sh use_colors=no use_vpath=no |