From: Paul Eggert Date: Fri, 27 Oct 2006 23:05:33 +0000 (+0000) Subject: Handle special characters in test case titles correctly. X-Git-Tag: AUTOCONF-2.61~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45cd8714aa542ea850a0a9542bec87b1622ec31b;p=thirdparty%2Fautoconf.git Handle special characters in test case titles correctly. * lib/autotest/general.m4 (AT_INIT): M4-quote and AS_ESCAPE AT_help_all properly. (AT_SETUP): M4-quote and AS_ESCAPE the title properly everywhere. * tests/autotest.at (AT_CHECK_AT_TITLE): Add EXPANDED-TITLE-TO-TEST argument. Extend to check titles printed by ./micro-suite and ./micro-suite -l and the title in micro-suite.log. (Backquote in a test title, Single-quote in a test title, Double-quote in a test title): Don't expect failure anymore. (Backslash in a test title): Put a non-whitespace character after the backslash so that Bourne shells might actually see it as an escape sequence. (Brackets in a test title, Pound in a test title, Comma in a test title, Quoted Macro in a test title, Macro in a test title, Macro with single-quote in a test title): New tests. (Macro with backquote in a test title, Macro with double-quote in a test title, Macro with backslash in a test title): New tests expected to fail. * tests/torture.at (#define header templates): M4-quote this title in AT_SETUP call so that no M4 code is commented inadvertently somewhere. The visible effect was a stray [] in the testsuite output. --- diff --git a/ChangeLog b/ChangeLog index 959ca7f98..fe3c4d5b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2006-10-26 Joel E. Denny + and Stepan Kasal + + Handle special characters in test case titles correctly. + * lib/autotest/general.m4 (AT_INIT): M4-quote and AS_ESCAPE AT_help_all + properly. + (AT_SETUP): M4-quote and AS_ESCAPE the title properly everywhere. + * tests/autotest.at (AT_CHECK_AT_TITLE): Add EXPANDED-TITLE-TO-TEST + argument. Extend to check titles printed by ./micro-suite and + ./micro-suite -l and the title in micro-suite.log. + (Backquote in a test title, + Single-quote in a test title, + Double-quote in a test title): Don't expect failure anymore. + (Backslash in a test title): Put a non-whitespace character after the + backslash so that Bourne shells might actually see it as an escape + sequence. + (Brackets in a test title, + Pound in a test title, + Comma in a test title, + Quoted Macro in a test title, + Macro in a test title, + Macro with single-quote in a test title): New tests. + (Macro with backquote in a test title, + Macro with double-quote in a test title, + Macro with backslash in a test title): New tests expected to fail. + * tests/torture.at (#define header templates): M4-quote this title in + AT_SETUP call so that no M4 code is commented inadvertently somewhere. + The visible effect was a stray [] in the testsuite output. + 2006-10-27 Ralf Wildenhues * doc/autoconf.texi (Limitations of Builtins): Do not invoke diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index 6ce6dfa21..9510d484e 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -279,7 +279,7 @@ at_groups_all='AT_groups_all' # numerical order. at_format='m4_bpatsubst(m4_defn([AT_ordinal]), [.], [?])' # Description of all the test groups. -at_help_all='AT_help_all'])])dnl +at_help_all="AS_ESCAPE(m4_defn([AT_help_all]))"])])dnl m4_divert_push([PARSE_ARGS])dnl at_prev= @@ -1176,9 +1176,9 @@ m4_append([AT_groups_all], [ ]m4_defn([AT_ordinal])) m4_divert_push([TESTS])dnl AT_ordinal ) @%:@ AT_ordinal. m4_defn([AT_line]): $1 at_setup_line='m4_defn([AT_line])' - at_desc='$1' + at_desc="AS_ESCAPE([$1])" $at_quiet $ECHO_N "m4_format([%3d: %-]m4_eval(47 - m4_qdelta([$1]))[s], - AT_ordinal, [[$1]])[]$ECHO_C" + AT_ordinal, AS_ESCAPE([[$1]]))[]$ECHO_C" m4_divert_push([TEST_SCRIPT])dnl ]) diff --git a/tests/autotest.at b/tests/autotest.at index 0bdb7a436..0ffe972a9 100644 --- a/tests/autotest.at +++ b/tests/autotest.at @@ -236,27 +236,62 @@ conf ## Funny characters in test names. ## ## ------------------------------- ## -# AT_CHECK_AT_TITLE(TITLE, TITLE-TO-TEST, [XFAIL-CONDITION]) -# ---------------------------------------------------------- +# AT_CHECK_AT_TITLE(TITLE, TITLE-TO-TEST, EXPANDED-TITLE-TO-TEST +# [XFAIL-CONDITION]) +# --------------------------------------------------------------- # Create a new test named TITLE that runs an Autotest test suite -# comprised of a trivial test named TITLE-TO-TEST. XFAIL-CONDITION -# passes verbatim to AT_CHECK_AT. +# comprised of a trivial test named TITLE-TO-TEST, which expands +# to EXPANDED-TITLE-TO-TEST. XFAIL-CONDITION passes verbatim to +# AT_CHECK_AT. m4_define([AT_CHECK_AT_TITLE], [AT_CHECK_AT([$1], [[ +m4@&t@_define([macro_name], [[macro_expanded]]) +m4@&t@_define([macro_expanded], [[macro_overexpanded]]) +m4@&t@_define([macro_backquote], [`]) +m4@&t@_define([macro_single_quote], [']) +m4@&t@_define([macro_double_quote], ["]) +m4@&t@_define([macro_backslash], [\\]) AT_INIT([artificial test suite]) AT_SETUP([$2]) AT_CHECK([:]) AT_CLEANUP -]], [$3])]) +]], [$4], [], [], [], +[AT_CHECK([[./micro-suite | sed -n "s/[^:]*: \(.*[^ \t]\)[ \t]*ok.*/\1/p"]],, +[[$3 +]]) +AT_CHECK([[./micro-suite -l \ + | sed -n "s/.*[0-9]\+: [^ \t]\+[ \t]\+\(.*[^ \t]\)[ \t]*/\1/p"]],, +[[$3 +]]) +AT_CHECK([[sed -n "s/[^.]*\. \(.*\) ([^)]*): ok.*/\1/p" micro-suite.log]],, +[[$3 +]]) +])]) m4_define([AT_CHECK_AT_TITLE_CHAR], -[AT_CHECK_AT_TITLE([$1 in a test title], [A $2 in my name], $3)]) - -AT_CHECK_AT_TITLE_CHAR([Backquote], [`], [:]) -AT_CHECK_AT_TITLE_CHAR([Single-quote], ['], [:]) -AT_CHECK_AT_TITLE_CHAR([Double-quote], ["], [:]) -AT_CHECK_AT_TITLE_CHAR([Backslash], [\]) +[AT_CHECK_AT_TITLE([$1 in a test title], [A $2 in my name], + [A ]m4_ifval([$3], [[$3]], [[$2]])[ in my name], $4)]) + +AT_CHECK_AT_TITLE_CHAR([Backquote], [`]) +AT_CHECK_AT_TITLE_CHAR([Single-quote], [']) +AT_CHECK_AT_TITLE_CHAR([Double-quote], ["]) +AT_CHECK_AT_TITLE_CHAR([Backslash], [\\]) +AT_CHECK_AT_TITLE_CHAR([Brackets], [[[]]], [[]]) +AT_CHECK_AT_TITLE_CHAR([Pound], [[#]], [#]) +AT_CHECK_AT_TITLE_CHAR([Comma], [,]) + +AT_CHECK_AT_TITLE_CHAR([Quoted Macro], [[macro_name]], + [macro_name]) +AT_CHECK_AT_TITLE_CHAR([Macro], [macro_name], + [macro_expanded]) +AT_CHECK_AT_TITLE_CHAR([Macro with backquote], [macro_backquote], + [`], [:]) +AT_CHECK_AT_TITLE_CHAR([Macro with single-quote], [macro_single_quote], [']) +AT_CHECK_AT_TITLE_CHAR([Macro with double-quote], [macro_double_quote], + ["], [:]) +AT_CHECK_AT_TITLE_CHAR([Macro with backslash], [macro_backslash], + [\\], [:]) ## ----------------- ## diff --git a/tests/torture.at b/tests/torture.at index 436842f6c..4990c9b52 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -319,7 +319,7 @@ AT_CLEANUP # Use various forms of `#define' templates, and make sure there are no # problems when a symbol is prefix of another. -AT_SETUP([#define header templates]) +AT_SETUP([[#define header templates]]) AT_DATA([configure.ac], [[AC_INIT