]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Fix regression in handling VAR=VALUE arguments to testsuite.
authorEric Blake <ebb9@byu.net>
Tue, 29 Jan 2008 05:42:17 +0000 (22:42 -0700)
committerEric Blake <ebb9@byu.net>
Tue, 29 Jan 2008 05:49:22 +0000 (22:49 -0700)
* lib/autotest/general.m4 (AT_INIT) <PARSE_ARGS_END>: Detect
leading = as invalid.  Defer use of command-line variable
assignments...
<PREPARE_TESTS>: ...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 <ebb9@byu.net>
ChangeLog
lib/autotest/general.m4
tests/autotest.at

index a3f52fe181611cbc77fcf193dafdd196432b4844..42da03c4c0d7d3fc4d7c7d9a32aaf02cf12f0622 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2008-01-28  Eric Blake  <ebb9@byu.net>
 
+       Fix regression in handling VAR=VALUE arguments to testsuite.
+       * lib/autotest/general.m4 (AT_INIT) <PARSE_ARGS_END>: Detect
+       leading = as invalid.  Defer use of command-line variable
+       assignments...
+       <PREPARE_TESTS>: ...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) <grep>: Document
        BSD behavior on binary input.
index 662f2cbbaeba20ac0793338ea71d9515a16bf26e..25b2d36d918277e05fe68f61425ae4aa54e90fb7 100644 (file)
@@ -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
index 4fbdba2fe2e4720ba7688802b611735c63fef041..2fb36e501c37fdfda2f0b49389dd4c3b9a3f7891 100644 (file)
@@ -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 <<EOF >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], [])
 ])