* tests/defs.in: Sanity check: abort if $me is in the environment.
* tests/self-check-me-in-env.test: New test.
* tests/Makefile.am (TESTS_ENVIRONMENT): Unset variable `me'.
(TESTS): Update.
Suggestion by Ralf Wildenhues.
+2011-04-18 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ tests: don't allow `$me' to be overridden from the environment
+ * tests/defs.in: Sanity check: abort if $me is in the environment.
+ * tests/self-check-me-in-env.test: New test.
+ * tests/Makefile.am (TESTS_ENVIRONMENT): Unset variable `me'.
+ (TESTS): Update.
+ Suggestion by Ralf Wildenhues.
+
2011-04-17 Stefano Lattarini <stefano.lattarini@gmail.com>
test defs: allow overriding of `$me'
MAINTAINERCLEANFILES = $(parallel_tests)
+# The testsuite variable `$me' should be overridable from the
+# test scripts, but not from the environment.
+TESTS_ENVIRONMENT = test x"$$me" = x || unset me;
+
TESTS = \
+self-check-me-in-env.test \
aclibobj.test \
aclocal.test \
aclocal3.test \
pr401c-p.test
MAINTAINERCLEANFILES = $(parallel_tests)
+
+# The testsuite variable `$me' should be overridable from the
+# test scripts, but not from the environment.
+TESTS_ENVIRONMENT = test x"$$me" = x || unset me;
TESTS = \
+self-check-me-in-env.test \
aclibobj.test \
aclocal.test \
aclocal3.test \
# be done carefully, and *before* including ./defs).
if test -z "$me"; then
me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`
+elif env | grep '^me=' >/dev/null; then
+ echo "$0: variable \`me' is set in the environment: this is unsafe" >&2
+ exit 99
fi
# This might be used in testcases checking distribution-related features.
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that the testsuite initialization code complains when
+# $me is set in the environment.
+
+set -x
+
+exec 5>&1
+env me=foo /bin/sh -c '. ./defs' foo.test && exit 1
+env me=foo /bin/sh -c '. ./defs' foo.test 2>&1 1>&5 \
+ | grep "variable \`me' is set in the environment.*unsafe" || exit 1
+
+: