From 0286308c4923e9b1547811587988fbec73aabf00 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sun, 7 Aug 2011 09:42:48 +0200 Subject: [PATCH] testsuite: TAP tests can have early plan now * tests/defs: When using TAP, allow the user to specify the number of tests through the `$planned' variable. (trap): Do not print the auto-generated plan if an explicit one has already been printed. * tests/defs-static.in: Complain and bail out if the `$planned' variable is exported in the environment. Reformat the code to facilitate future additions. * tests/Makefile.am (TESTS_ENVIRONMENT): Neutralize `$planned'. * tests/self-check-env-sanitize.test: Update. * tests/ac-output-old.tap: Give an explicit TAP plan, by defining `$planned' just before including `./defs'. * tests/depmode.tap: Likewise. * tests/automake-cmdline.tap: Likewise. * tests/tap-bad-prog.tap: Likewise. * tests/instspc.tap: Likewise, and related adjustments. * tests/add-missing.tap: Make it explicit that we have no a-priori plan, and tell why. --- ChangeLog | 21 +++++++++++++++++++++ tests/Makefile.am | 1 + tests/Makefile.in | 7 ++++--- tests/ac-output-old.tap | 1 + tests/add-missing.tap | 1 + tests/automake-cmdline.tap | 2 ++ tests/defs | 9 ++++++++- tests/defs-static.in | 13 ++++++++++--- tests/depmod.tap | 4 ++++ tests/instspc.tap | 3 ++- tests/self-check-env-sanitize.test | 1 + tests/tap-bad-prog.tap | 1 + 12 files changed, 56 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0776f51..aa71382 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2011-08-07 Stefano Lattarini + testsuite: TAP tests can have early plan now + * tests/defs: When using TAP, allow the user to specify the number + of tests through the `$planned' variable. + (trap): Do not print the auto-generated plan if an explicit one + has already been printed. + * tests/defs-static.in: Complain and bail out if the `$planned' + variable is exported in the environment. Reformat the code to + facilitate future additions. + * tests/Makefile.am (TESTS_ENVIRONMENT): Neutralize `$planned'. + * tests/self-check-env-sanitize.test: Update. + * tests/ac-output-old.tap: Give an explicit TAP plan, by defining + `$planned' just before including `./defs'. + * tests/depmode.tap: Likewise. + * tests/automake-cmdline.tap: Likewise. + * tests/tap-bad-prog.tap: Likewise. + * tests/instspc.tap: Likewise, and related adjustments. + * tests/add-missing.tap: Make it explicit that we have no a-priori + plan, and tell why. + +2011-08-07 Stefano Lattarini + testsuite: run autogenerated tests with $(LOG_COMPILER) too This change enhances consistency in the testsuite. * tests/Makefile.am: Some cosmetic reordering, to keep the diff --git a/tests/Makefile.am b/tests/Makefile.am index 2369c90..76d14fd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -91,6 +91,7 @@ $(config_shell_tests): AM_TESTS_ENVIRONMENT = \ test x"$$me" = x || unset me; \ test x"$$required" = x || unset required; \ + test x"$$planned" = x || unset planned; \ test x"$$use_tap" = x || unset use_tap; \ test x"$$parallel_tests" = x || unset parallel_tests; \ test x"$$test_prefer_config_shell" || unset test_prefer_config_shell; \ diff --git a/tests/Makefile.in b/tests/Makefile.in index f5a2208..cd30b56 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -341,9 +341,10 @@ SHTST_LOG_COMPILER = $(LOG_COMPILER) $(srcdir)/config-shell-tests.sh # we are already running them under it explicitly in our setup (see e.g. # the definition of TEST_LOG_COMPILER above). AM_TESTS_ENVIRONMENT = test x"$$me" = x || unset me; test \ - x"$$required" = x || unset required; test x"$$use_tap" = x || \ - unset use_tap; test x"$$parallel_tests" = x || unset \ - parallel_tests; test x"$$test_prefer_config_shell" || unset \ + x"$$required" = x || unset required; test x"$$planned" = x || \ + unset planned; test x"$$use_tap" = x || unset use_tap; test \ + x"$$parallel_tests" = x || unset parallel_tests; test \ + x"$$test_prefer_config_shell" || unset \ test_prefer_config_shell; test x"$$original_AUTOMAKE" = x || \ unset original_AUTOMAKE; test x"$$original_ACLOCAL" = x || \ unset original_ACLOCAL; AM_TESTS_REEXEC=no; export \ diff --git a/tests/ac-output-old.tap b/tests/ac-output-old.tap index 74bbba3..201e517 100755 --- a/tests/ac-output-old.tap +++ b/tests/ac-output-old.tap @@ -19,6 +19,7 @@ # line breaking in the use of AC_OUTPUT. Synthesised by a bunch # of older tests (referenced below). +planned=22 . ./defs || Exit 1 rm -f configure.in depcomp # Not required. diff --git a/tests/add-missing.tap b/tests/add-missing.tap index 4c6a624..cbf6e57 100755 --- a/tests/add-missing.tap +++ b/tests/add-missing.tap @@ -19,6 +19,7 @@ # the files) it's supposed to, and that these files are symlinked by # default, but copied if the `--copy' option is used. +planned=unknown # Counting it would be too much data-dependent. . ./defs || Exit 1 build_aux=build-aux diff --git a/tests/automake-cmdline.tap b/tests/automake-cmdline.tap index 592c73b..1c53a6d 100755 --- a/tests/automake-cmdline.tap +++ b/tests/automake-cmdline.tap @@ -15,6 +15,8 @@ # along with this program. If not, see . # Test Automake's command-line options. + +planned=17 . ./defs || Exit 1 # Usage: bad_cmdline DESCRIPTION REGEX-FOR-STDERR [ARGS-FOR-AUTOMAKE...] diff --git a/tests/defs b/tests/defs index c468d5f..e9e241e 100644 --- a/tests/defs +++ b/tests/defs @@ -430,6 +430,11 @@ xsi_shell_code=' ## required by them. ## ## ----------------------------------------------------------- ## +# The TAP plan must be either the fist or last line of output. +if test $using_tap = yes && test ${planned-unknown} != unknown; then + plan_ "$planned" +fi + # Print it here, so that the user will see it also if the test # will be skipped due to some tool missing in $PATH itself. echo "$PATH" @@ -831,7 +836,9 @@ if test "$sh_errexit_works" = yes; then set +x test "$signal" != 0 && echo "$me: caught signal $signal" echo "$me: exit $exit_status" - test $using_tap = yes && late_plan_ + if test $using_tap = yes && test $have_tap_plan_ != yes; then + late_plan_ + fi exit $exit_status ' 0 for signal in 1 2 13 15; do diff --git a/tests/defs-static.in b/tests/defs-static.in index 407060d..73eaad1 100644 --- a/tests/defs-static.in +++ b/tests/defs-static.in @@ -70,9 +70,16 @@ fi # 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 me required use_tap parallel_tests test_prefer_config_shell \ - original_AUTOMAKE original_ACLOCAL; -do +for var in \ + me \ + required \ + planned \ + use_tap \ + parallel_tests \ + test_prefer_config_shell \ + original_AUTOMAKE \ + original_ACLOCAL \ +; do if eval "test x\"\$$var\" != x" && env | grep "^$var=" >/dev/null; then echo "$argv0: variable \`$var' is set in the environment:" \ "this is unsafe" >&2 diff --git a/tests/depmod.tap b/tests/depmod.tap index 4470fdd..85bd972 100755 --- a/tests/depmod.tap +++ b/tests/depmod.tap @@ -51,6 +51,10 @@ # which caused make to die with an error like: # "sub/.deps/subfoo.Po:3: *** missing separator. Stop." +# Per each valid depmode three kinds of VPATH, and per each of them +# a test on "./configure" and one on "make & remake"; so there are +# 17 * 3 * 2 = 102. +planned=102 required=cc . ./defs || Exit 99 diff --git a/tests/instspc.tap b/tests/instspc.tap index 64540d8..4c81151 100755 --- a/tests/instspc.tap +++ b/tests/instspc.tap @@ -19,6 +19,7 @@ # Original report from James Amundson about file names with spaces. # Other characters added by Paul Eggert. +planned=94 # Two tests per "problematic string". . ./defs || Exit 99 # Usage: is_in_list ITEM [LIST...] @@ -222,7 +223,7 @@ for test_name in $test_names_list; do # characters in file names. mkdir "./$test_string" || \ - skip_row_ 2 -r "mkdir failed" "$test_name" + skip_ -r "mkdir failed" "$test_name" # Where are the "weird" characters going to be used, in $(builddir) # or in $(DESTDIR)? They are always going to be used in $(prefix) diff --git a/tests/self-check-env-sanitize.test b/tests/self-check-env-sanitize.test index e2d8f2a..84c6b9f 100755 --- a/tests/self-check-env-sanitize.test +++ b/tests/self-check-env-sanitize.test @@ -27,6 +27,7 @@ vars=' me parallel_tests required + planned use_tap test_prefer_config_shell original_AUTOMAKE diff --git a/tests/tap-bad-prog.tap b/tests/tap-bad-prog.tap index 2dee975..0cc3a11 100755 --- a/tests/tap-bad-prog.tap +++ b/tests/tap-bad-prog.tap @@ -18,6 +18,7 @@ # - missing, unreadable, or not-executable test scripts cause proper # error reports +planned=5 parallel_tests=yes . ./defs || Exit 1 -- 2.7.4