From 372769ca9eb0c5db10aac8173906116b5a260356 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 28 Jan 2008 22:42:17 -0700 Subject: [PATCH] Fix regression in handling VAR=VALUE arguments to testsuite. * lib/autotest/general.m4 (AT_INIT) : Detect leading = as invalid. Defer use of command-line variable assignments... : ...here, after atconfig has been sourced. Fix regression in sourcing files. * tests/autotest.at (Using atlocal): New test to catch this. (Debugging a successful test, Choosing where testsuite is run): Use correct shell. Reported by Ralf Wildenhues. Signed-off-by: Eric Blake --- ChangeLog | 11 +++++++++ lib/autotest/general.m4 | 13 +++++++---- tests/autotest.at | 51 ++++++++++++++++++++++++++++++++++------- 3 files changed, 62 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3f52fe1..42da03c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2008-01-28 Eric Blake + Fix regression in handling VAR=VALUE arguments to testsuite. + * lib/autotest/general.m4 (AT_INIT) : Detect + leading = as invalid. Defer use of command-line variable + assignments... + : ...here, after atconfig has been sourced. Fix + regression in sourcing files. + * tests/autotest.at (Using atlocal): New test to catch this. + (Debugging a successful test, Choosing where testsuite is run): + Use correct shell. + Reported by Ralf Wildenhues. + Document grep peculiarity. * doc/autoconf.texi (Limitations of Usual Tools) : Document BSD behavior on binary input. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index 662f2cbb..25b2d36d 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -569,12 +569,12 @@ m4_divert_push([PARSE_ARGS_END])dnl *=*) at_envvar=`expr "x$at_option" : 'x\([[^=]]*\)='` # Reject names that are not valid shell variable names. - expr "x$at_envvar" : "[.*[^_$as_cr_alnum]]" >/dev/null && + test "x$at_envvar" = "x" || + expr "x$at_envvar" : "[.*[^_$as_cr_alnum]]" >/dev/null && AS_ERROR([invalid variable name: $at_envvar]) at_value=`AS_ECHO(["$at_optarg"]) | sed "s/'/'\\\\\\\\''/g"` - eval "$at_envvar='$at_value'" + # Export now, but save eval for later and for debug scripts. export $at_envvar - # Propagate to debug scripts. at_debug_args="$at_debug_args $at_envvar='$at_value'" ;; @@ -708,16 +708,19 @@ if $at_change_dir ; then at_dir=`pwd` fi -# Load the config file. +# Load the config files for any default variable assignments. for at_file in atconfig atlocal do test -r $at_file || continue - . $at_file || AS_ERROR([invalid content: $at_file]) + . ./$at_file || AS_ERROR([invalid content: $at_file]) done # Autoconf <=2.59b set at_top_builddir instead of at_top_build_prefix: : ${at_top_build_prefix=$at_top_builddir} +# Perform any assignments requested during argument parsing. +eval $at_debug_args + # atconfig delivers names relative to the directory the test suite is # in, but the groups themselves are run in testsuite-dir/group-dir. if test -n "$at_top_srcdir"; then diff --git a/tests/autotest.at b/tests/autotest.at index 4fbdba2f..2fb36e50 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -359,7 +359,7 @@ AT_CHECK_AT_TEST([Debugging a successful test], [AT_CHECK([:])], [], [], [], [ignore], [# Without options, when all tests pass, no test directory should exist. AT_CHECK([test -d micro-suite.dir/1 && exit 42 - ./micro-suite -d 1], [], [ignore], [ignore]) + $CONFIG_SHELL ./micro-suite -d 1], [], [ignore], [ignore]) # Running with -d should leave a reproducible test group. # Also, running the test script from the test group locks the # directory from removal on some platforms; the script should still be @@ -396,26 +396,61 @@ AT_CHECK([(cd micro-suite.dir/1 && ./run MY_VAR='one space')], ]) +# Setting default variable values via atlocal. +AT_CHECK_AT_TEST([Using atlocal], + [AT_CHECK([test "x$MY_VAR" = xset || exit 42])], + [], [1], [ignore], [ignore], [ +dnl check that command line can set variable +AT_CHECK([$CONFIG_SHELL ./micro-suite MY_VAR=set], [0], [ignore]) +dnl check that command line overrides environment +AT_CHECK([MY_VAR=set $CONFIG_SHELL ./micro-suite MY_VAR=unset], + [1], [ignore], [ignore]) +dnl check that atlocal can give it a default +AT_CHECK([cat <atlocal +MY_VAR=set +export MY_VAR +dnl Also populate enough of atlocal to do what atconfig normally does. +at_testdir=. +abs_builddir=`pwd` +at_srcdir=. +abs_srcdir=`pwd` +at_top_srcdir=. +abs_top_srcdir=`pwd` +at_top_build_prefix= +abs_top_builddir=`pwd` +EOF +]) +AT_CHECK([$CONFIG_SHELL ./micro-suite], [0], [ignore]) +dnl check that atlocal overrides environment +AT_CHECK([MY_VAR=unset $CONFIG_SHELL ./micro-suite], [0], [ignore]) +dnl check that command line overrides atlocal +AT_CHECK([$CONFIG_SHELL ./micro-suite MY_VAR=], [1], [ignore], [ignore]) +dnl check that syntax error is detected +AT_CHECK([$CONFIG_SHELL ./micro-suite =], [1], [], [ignore], [ignore]) +]) + + # Controlling where the testsuite is run. AT_CHECK_AT_TEST([Choosing where testsuite is run], [AT_CHECK([:])], [], [], [], [], [ dnl AT_CHECK_AT_TEST tests the default of running in `.'. AT_CHECK([rm micro-suite.log && mkdir sub1 sub2]) dnl check specifying a different relative path to run in. -AT_CHECK([./micro-suite -C sub1], [0], [ignore], []) +AT_CHECK([$CONFIG_SHELL ./micro-suite -C sub1], [0], [ignore], []) AT_CHECK([test -f micro-suite.log], [1]) AT_CHECK([test -f sub1/micro-suite.log], [0]) dnl check specifying an absolute path to run in. -AT_CHECK([./micro-suite --directory="`pwd`/sub2"], [0], [ignore], []) +AT_CHECK([$CONFIG_SHELL ./micro-suite --directory="`pwd`/sub2"], + [0], [ignore], []) AT_CHECK([test -f micro-suite.log], [1]) AT_CHECK([test -f sub2/micro-suite.log], [0]) dnl check for failure detection with bad, missing, or empty directory. -AT_CHECK([./micro-suite -C nonesuch], [1], [ignore], [ignore]) -AT_CHECK([./micro-suite -C ''], [1], [ignore], [ignore]) -AT_CHECK([./micro-suite -C -], [1], [ignore], [ignore]) -AT_CHECK([./micro-suite -C], [1], [ignore], [ignore]) +AT_CHECK([$CONFIG_SHELL ./micro-suite -C nonesuch], [1], [ignore], [ignore]) +AT_CHECK([$CONFIG_SHELL ./micro-suite -C ''], [1], [ignore], [ignore]) +AT_CHECK([$CONFIG_SHELL ./micro-suite -C -], [1], [ignore], [ignore]) +AT_CHECK([$CONFIG_SHELL ./micro-suite -C], [1], [ignore], [ignore]) dnl check that --help overrides bad directory selection. -AT_CHECK([./micro-suite -C nonesuch --help], [0], [ignore], []) +AT_CHECK([$CONFIG_SHELL ./micro-suite -C nonesuch --help], [0], [ignore], []) ]) -- 2.47.2