autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix AT_SETUP formatting


From: Eric Blake
Subject: Fix AT_SETUP formatting
Date: Wed, 26 Sep 2007 21:41:07 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This bugged me:

$ cd autoconf
$ make check TESTSUITEFLAGS='-k templates'
...
101: Missing templates                               ok
103: #define header templates                      ok

Note how the output is unaligned.  The problem is that we calculated the
length of the unexpanded description, then output an expanded description.
  I first tried a simpler hack for autoconf alone - use a quadrigraph so
that all uses of AT_SETUP within autoconf used single quoting:
http://git.sv.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=1e9958d#patch3

But I decided that was too hackish, so here's a better fix.  In the
process, I also managed to avoid some current XFAILs, now that we are no
longer trying to pass mismatched ` and ", or even worse \, through AS_ECHO_N.

I had particular fun writing the resulting sed script that checks both
content and alignment in a single pass.

However, there is a slight caveat that I could not work around.  This used
to "work" (albeit, not necessarily with the right alignment):
AT_SETUP([name, with comma])

Now, to avoid losing whitespace after a single-quoted comma, you must do:
AT_SETUP([[name, with comma]])
or
AT_SETUP([name,@&t@ with comma])

or any other trick that will not lose whitespace to m4_dquote.

Also, this patch does not try to tackle the issue that 'testsuite -l'
won't work if any AT_SETUP description contains a ;, based on the way the
test list is currently constructed via awk -F;.

I'll apply this in a couple of days unless I get a review first.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+yZS84KuGfSFAYARAs4iAJ93jVJIxNd/7xbgDlof3RKAt0WsjQCgz7+5
yFTzOyNpDiZjB/aFGp26PdE=
=9Nj5
-----END PGP SIGNATURE-----
>From ac9d6eefe2b898d39fae606efd16e81153b865c2 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 26 Sep 2007 21:36:14 -0600
Subject: [PATCH] Remove some XFAILs, and make AT_SETUP output line up.

* lib/autotest/general.m4 (AT_SETUP): Only expand description
once; thereafter, use its expansion, properly quoted.
* tests/autotest.at (AT_CHECK_AT_TITLE): Also check macro
expansion with arguments, and check for aligned output.
(AT_CHECK_AT_TITLE_CHAR): Remove XFAILs for tests that now pass.
Add a test for macros with parameters.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog               |    8 ++++++++
 lib/autotest/general.m4 |   10 +++++-----
 tests/autotest.at       |   32 ++++++++++++++++++++------------
 3 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3f7ffbe..113ed21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2007-09-26  Eric Blake  <address@hidden>
 
+       Remove some XFAILs, and make AT_SETUP output line up.
+       * lib/autotest/general.m4 (AT_SETUP): Only expand description
+       once; thereafter, use its expansion, properly quoted.
+       * tests/autotest.at (AT_CHECK_AT_TITLE): Also check macro
+       expansion with arguments, and check for aligned output.
+       (AT_CHECK_AT_TITLE_CHAR): Remove XFAILs for tests that now pass.
+       Add a test for macros with parameters.
+
        Fix testsuite breakage in last patch.
        * tests/autotest.at (AT_CHECK_AT_TITLE): Properly quote the
        font-lock fix.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index f2a6f38..2dc135c 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -1175,15 +1175,15 @@ m4_define([AT_SETUP],
 m4_ifdef([AT_capture_files], [m4_undefine([AT_capture_files])])
 m4_define([AT_line], AT_LINE)
 m4_define([AT_xfail], [at_xfail=no])
-m4_define([AT_description], [$1])
+m4_define([AT_description], m4_dquote($1))
 m4_define([AT_ordinal], m4_incr(AT_ordinal))
 m4_append([AT_groups_all], [ ]m4_defn([AT_ordinal]))
 m4_divert_push([TESTS])dnl
-  AT_ordinal ) @%:@ AT_ordinal. m4_defn([AT_line]): $1
+  AT_ordinal ) @%:@ AT_ordinal. m4_defn([AT_line]): m4_defn([AT_description])
     at_setup_line='m4_defn([AT_line])'
-    at_desc="AS_ESCAPE([$1])"
-    $at_quiet AS_ECHO_N(["m4_format([%3d: %-]m4_eval(47 - m4_qdelta([$1]))[s],
-                      AT_ordinal, AS_ESCAPE([[$1]]))[]"])
+    at_desc="AS_ESCAPE(m4_defn([AT_description]))"
+    $at_quiet AS_ECHO_N(["m4_format([%3d: ], AT_ordinal)$at_desc"]dnl
+["m4_format(%-m4_eval(49 - m4_qlen(m4_defn([AT_description])))[s], [ ])"])
 m4_divert_push([TEST_SCRIPT])dnl
 ])
 
diff --git a/tests/autotest.at b/tests/autotest.at
index 61481f3..2479be4 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -250,15 +250,24 @@ m4@&address@hidden([macro_backquote],    [`])
 m4@&address@hidden([macro_single_quote], ['])
 m4@&address@hidden([macro_double_quote], ["])
 ]]dnl restore font-lock: "
-[[m4@&address@hidden([macro_backslash],   [\\])
+[[m4@&address@hidden([macro_backslash],   [\])
+m4@&address@hidden([macro_echo], [$][1])
 AT_INIT([artificial test suite])
 AT_SETUP([$2])
 AT_CHECK([:])
 AT_CLEANUP
 ]], [$4], [], [], [],
-[AT_CHECK([[$CONFIG_SHELL ./micro-suite |
-           sed -n 's/[^:]*: \(.*[^      ]\)[    ]*ok.*/\1/p']],,
+[dnl This sed script checks for two things - that the output is properly
+dnl expanded, and that the 'ok' starts on column 53.
+AT_CHECK([[$CONFIG_SHELL ./micro-suite |
+           sed -n '/^  1:/{
+h
+s/[^:]*: \(.*[^         ]\)[    ]*ok.*/\1/p
+x
+s/^.\{53\}ok.*/ok/p
+}']],,
 [[$3
+ok
 ]])
 AT_CHECK([[$CONFIG_SHELL ./micro-suite -l |
           sed -n 's/.*[0-9]: [^         ][^     ]*[     ][      ]*\(.*[^       
 ]\)[    ]*/\1/p']],,
@@ -277,24 +286,23 @@ AT_CHECK_AT_TITLE_CHAR([Backquote],    [`])
 AT_CHECK_AT_TITLE_CHAR([Single-quote], ['])
 AT_CHECK_AT_TITLE_CHAR([Double-quote], ["])
 dnl restore font-lock: "
-AT_CHECK_AT_TITLE_CHAR([Backslash],   [\\])
+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([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 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 double-quote], [macro_double_quote], ["])
 dnl restore font-lock: "
-# This test neither fails nor passes reliably.
-# AT_CHECK_AT_TITLE_CHAR([Macro with backslash],       [macro_backslash],
-#                                                                  [\\], [:])
+AT_CHECK_AT_TITLE_CHAR([Macro with backslash],       [macro_backslash], [\])
+AT_CHECK_AT_TITLE_CHAR([Macro echoing a macro], [macro_echo([macro_name])],
+                       [macro_expanded])
+AT_CHECK_AT_TITLE_CHAR([Macro echoing a single-quote], [macro_echo(['])], ['])
 
 
 ## ----------------- ##
-- 
1.5.3.2


reply via email to

[Prev in Thread] Current Thread [Next in Thread]