tests: prepare to move ./defs to t/ax/test-init.sh
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 27 Oct 2012 10:59:41 +0000 (12:59 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Sat, 27 Oct 2012 10:59:41 +0000 (12:59 +0200)
We don't do this in a sweeping passage, because that would cause
endless headaches in the synchronization between the maint, master
and ng/master branches.  Instead, we setup our framework to allow
test scripts to work by sourcing either './defs' or 'test-init.sh',
so that we'll be able to make the transition gradual and painless.

* t/ax/test-init.sh: New, copied from the previous ./defs file.
* defs: Simply work by sourcing the new file.
* Makefile.am (dist_noinst_DATA): List the new file.
* t/README: Adjust to mandate the sourcing of 'test-init.sh' rather
than of './defs'.
* t/c-demo.sh: Source 'test-init.sh' instead of ./defs.  This is
done to verify our new setup actually works.
* t/ac-output-old.tap: Likewise.

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Makefile.am
defs
t/README
t/ac-output-old.tap
t/ax/test-init.sh [new file with mode: 0644]
t/c-demo.sh

index fc37f44..a48ab82 100644 (file)
@@ -403,6 +403,7 @@ nodist_noinst_SCRIPTS = \
   t/wrap/automake-$(APIVERSION)
 
 dist_noinst_DATA = \
   t/wrap/automake-$(APIVERSION)
 
 dist_noinst_DATA = \
+  t/ax/test-init.sh \
   t/ax/test-lib.sh \
   t/ax/am-test-lib.sh \
   t/ax/tap-functions.sh
   t/ax/test-lib.sh \
   t/ax/am-test-lib.sh \
   t/ax/tap-functions.sh
diff --git a/defs b/defs
index 1ee1116..586181e 100644 (file)
--- a/defs
+++ b/defs
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# This file is here for backward-compatibility with the existing
+# tests still unconverted to the use of 'test-init.sh'.  It should
+# eventually be removed, once all the tests have been converted.
 
 
-set -e
-
-# Source the actual code for test initialization and setup.
-. test-lib.sh
-. am-test-lib.sh
-
-# Run that setup, and return control to the test script sourcing us.
-am_test_setup
+. test-init.sh
index 06f087f..02cb3a5 100644 (file)
--- a/t/README
+++ b/t/README
@@ -142,8 +142,8 @@ Writing test cases
   tools which can be taken for granted because they're listed in the
   GNU Coding Standards (for example, 'gzip').
 
   tools which can be taken for granted because they're listed in the
   GNU Coding Standards (for example, 'gzip').
 
-* Include ./defs in every test script (see existing tests for examples
-  of how to do this).
+* Include 'test-init.sh' in every test script (see existing tests for
+  examples of how to do this).
 
 * Use the 'skip_' function to skip tests, with a meaningful message if
   possible.  Where convenient, use the 'warn_' function to print generic
 
 * Use the 'skip_' function to skip tests, with a meaningful message if
   possible.  Where convenient, use the 'warn_' function to print generic
@@ -162,7 +162,7 @@ Writing test cases
   parallel one.  For those tests that are *not* meant to work with the
   parallel testsuite harness at all (these should be very very few),
   set the shell variable 'am_serial_tests' to "yes" before including
   parallel one.  For those tests that are *not* meant to work with the
   parallel testsuite harness at all (these should be very very few),
   set the shell variable 'am_serial_tests' to "yes" before including
-  ./defs.
+  test-init.sh.
 
 * Some tests in the Automake testsuite are auto-generated; those tests
   might have custom extensions, but their basename (that is, with such
 
 * Some tests in the Automake testsuite are auto-generated; those tests
   might have custom extensions, but their basename (that is, with such
@@ -173,14 +173,15 @@ Writing test cases
   to be confused with auto-generated tests; for example, 'u-v-w.sh'
   or 'option-w0.tap' are *not* valid name for hand-written tests.
 
   to be confused with auto-generated tests; for example, 'u-v-w.sh'
   or 'option-w0.tap' are *not* valid name for hand-written tests.
 
-* ./defs brings in some commonly required files, and sets a skeleton
-  configure.ac.  If possible, append to this file.  In some cases
-  you'll have to overwrite it, but this should be the exception.  Note
-  that configure.ac registers Makefile.in but do not output anything by
+* test-init.sh brings in some commonly required files, and sets a skeleton
+  configure.ac.  If possible, append to this file.  In some cases you'll
+  have to overwrite it, but this should be the exception.  Note that
+  configure.ac registers Makefile.in but do not output anything by
   default.  If you need ./configure to create Makefile, append AC_OUTPUT
   default.  If you need ./configure to create Makefile, append AC_OUTPUT
-  to configure.ac.  In case you don't want ./defs to pre-populate your
-  test directory (which is a rare occurrence), set the 'am_create_testdir'
-  shell variable to "empty" before sourcing ./defs.
+  to configure.ac.  In case you don't want your test directory to be
+  pre-populate by test-init.sh (this should be a rare occurrence), set
+  the 'am_create_testdir' shell variable to "empty" before sourcing
+  test-init.sh.
 
 * By default, the testcases are run with the errexit shell flag on,
   to make it easier to catch failures you might not have thought of.
 
 * By default, the testcases are run with the errexit shell flag on,
   to make it easier to catch failures you might not have thought of.
index be7e349..e45fb5f 100755 (executable)
@@ -18,7 +18,7 @@
 # line breaking in the use of AC_OUTPUT.  Synthesised by a bunch
 # of older tests (referenced below).
 
 # line breaking in the use of AC_OUTPUT.  Synthesised by a bunch
 # of older tests (referenced below).
 
-. ./defs || exit 1
+. test-init.sh
 
 plan_ 22
 
 
 plan_ 22
 
diff --git a/t/ax/test-init.sh b/t/ax/test-init.sh
new file mode 100644 (file)
index 0000000..1ee1116
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- shell-script -*-
+#
+# 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/>.
+
+set -e
+
+# Source the actual code for test initialization and setup.
+. test-lib.sh
+. am-test-lib.sh
+
+# Run that setup, and return control to the test script sourcing us.
+am_test_setup
index 2f51cf7..b0d1c47 100755 (executable)
@@ -19,7 +19,7 @@
 
 required=cc
 am_create_testdir=empty
 
 required=cc
 am_create_testdir=empty
-. ./defs || exit 1
+. test-init.sh
 
 cat > configure.ac << 'END'
 AC_INIT([GNU C Demo], [22.3.2], [bug-automake@gnu.org])
 
 cat > configure.ac << 'END'
 AC_INIT([GNU C Demo], [22.3.2], [bug-automake@gnu.org])