autoconf-patches
[Top][All Lists]
Advanced

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

22-fyi-test-without-autoconf.patch


From: Akim Demaille
Subject: 22-fyi-test-without-autoconf.patch
Date: Mon, 08 Oct 2001 10:29:47 +0200

The goal was to have a better testsuite for M4sh first, then cleaning
it up, but it worked too well and the bad m4_require in DIRNAME made
it fail (before, being used from Autoconf, SHELL_SANITIZE was run
explicitly, and therefore the failure was hidden as m4_require was
useless).

That's why DIRNAME uses AS_REQUIRE now, and not yet the others, not
checked explcitly in m4sh.at.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * lib/m4sugar/m4sh.m4 (AS_DIRNAME_EXPR): Use AS_REQUIRE.
        * tests/tools.at (AT_DATA_FORBIDDEN): Rename/move/duplicate to...
        * tests/atspecific.m4 (AT_DATA_M4SUGAR, AT_DATA_M4SH): here.
        * tests/tools.at, tests/m4sh.at: Use it.
        * tests/m4sh.at: Don't rely on Autoconf macros.
        (DIRNAME_TEST): Also exercise the expr variant.
        * tests/m4sugar.at, tests/atspecific.m4 (AT_CHECK_M4SUGAR): The
        preferred M4sugar extension is now `.4s'.
        * tests/README: Remove.

Index: lib/m4sugar/m4sh.m4
--- lib/m4sugar/m4sh.m4 Sun, 07 Oct 2001 16:25:47 +0200 akim
+++ lib/m4sugar/m4sh.m4 Sun, 07 Oct 2001 17:39:55 +0200 akim
@@ -388,13 +388,8 @@ m4_define([AS_ERROR],
 # a silly length limit that causes expr to fail if the matched
 # substring is longer than 120 bytes.  So fall back on echo|sed if
 # expr fails.
-#
-# FIXME: Please note the following m4_require is quite wrong: if the first
-# occurrence of AS_DIRNAME_EXPR is in a backquoted expression, the
-# shell will be lost.  We might have to introduce diversions for
-# setting up an M4sh script: required macros will then be expanded there.
 m4_defun([AS_DIRNAME_EXPR],
-[m4_require([_AS_EXPR_PREPARE])dnl
+[AS_REQUIRE([_AS_EXPR_PREPARE])dnl
 $as_expr X[]$1 : 'X\(.*[[^/]]\)//*[[^/][^/]]*/*$' \| \
          X[]$1 : 'X\(//\)[[^/]]' \| \
          X[]$1 : 'X\(//\)$' \| \
Index: tests/atspecific.m4
--- tests/atspecific.m4 Wed, 12 Sep 2001 16:03:50 +0200 akim
+++ tests/atspecific.m4 Sun, 07 Oct 2001 17:34:08 +0200 akim
@@ -1,5 +1,4 @@
 # M4 macros used in building Autoconf test suites.        -*- Autotest -*-
-# Copyright 2000, 2001 Free Software Foundation, Inc.

 # Copyright 2000, 2001 Free Software Foundation, Inc.

@@ -19,18 +18,43 @@
 # 02111-1307, USA.


-## ------------------------------------ ##
-## Macros specialized in testing M4sh.  ##
-## ------------------------------------ ##
+## ----------------- ##
+## Testing M4sugar.  ##
+## ----------------- ##
+
+
+# AT_DATA_M4SUGAR(FILENAME, CONTENTS)
+# --------------------------------
+# Escape the invalid tokens with @&address@hidden
+m4_define([AT_DATA_M4SUGAR],
+[AT_DATA([$1],
+[m4_patsubst(m4_patsubst([[$2]], [\(m4\)_], [\1@&address@hidden),
+                         [dnl], [d@&address@hidden)])])
+

 # AT_CHECK_M4SUGAR(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
 # ----------------------------------------------------------
 m4_define([AT_CHECK_M4SUGAR],
 [AT_CLEANUP_FILES([script.4s script autom4te.cache])dnl
-AT_CHECK([autom4te --language=m4sugar script.s4g -o script $1],
+AT_CHECK([autom4te --language=m4sugar script.4s -o script $1],
          m4_default([$2], [0]), [$3], [$4])])


+
+## -------------- ##
+## Testing M4sh.  ##
+## -------------- ##
+
+
+# AT_DATA_M4SH(FILENAME, CONTENTS)
+# --------------------------------
+# Escape the invalid tokens with @&address@hidden
+m4_define([AT_DATA_M4SH],
+[AT_DATA([$1],
+[m4_patsubst(m4_patsubst([[$2]], [\(m4\|AS\)_], [\1@&address@hidden),
+                         [dnl], [d@&address@hidden)])])
+
+
 # AT_CHECK_M4SH(FLAGS, [EXIT-STATUS = 0], STDOUT, STDERR)
 # -------------------------------------------------------
 m4_define([AT_CHECK_M4SH],
@@ -39,9 +63,10 @@ m4_define([AT_CHECK_M4SH],
          m4_default([$2], [0]), [$3], [$4])])


-## ---------------------------------------- ##
-## Macros specialized in testing Autoconf.  ##
-## ---------------------------------------- ##
+
+## ------------------ ##
+## Testing Autoconf.  ##
+## ------------------ ##


 # AT_CONFIGURE_AC(BODY)
Index: tests/m4sh.at
--- tests/m4sh.at Sun, 07 Oct 2001 14:11:51 +0200 akim
+++ tests/m4sh.at Sun, 07 Oct 2001 17:36:40 +0200 akim
@@ -42,18 +42,15 @@
 # UNSET-LINENO is a shell condition to make sure the scripts have the
 # same number of lines in the output, so that their outputs be identical.
 m4_define([AT_DATA_LINENO],
-[AT_DATA([$1],
-[[AS@&address@hidden
-m4@&address@hidden([0])d@&address@hidden
-m4@&address@hidden([m4@&address@hidden([0])[]])d@&address@hidden
-#! /bin/sh
+[AT_DATA_M4SH([$1],
+[[AS_INIT
 if $2; then
-  AS@&address@hidden([LINENO])
+  AS_UNSET([LINENO])
 fi
-AS@&address@hidden
+AS_SHELL_SANITIZE
 echo "Line: $3"
 grep 'Line: .*$4' $[0] >/dev/null ||
-  AS@&address@hidden([cannot find original script])
+  AS_ERROR([cannot find original script])
 exit 0
 ]])
 ])# AT_DATA_LINENO
@@ -89,24 +86,29 @@ m4_define([AT_DATA_LINENO],
 AT_CLEANUP(reference test test-1.lineno test-2.lineno)


-## ----------------------------- ##
-## AS_DIRNAME & AS_DIRNAME_SED.  ##
-## ----------------------------- ##
+## ------------ ##
+## AS_DIRNAME.  ##
+## ------------ ##

 # Build nested dirs.
-m4_pattern_allow([^AS_DIRNAME(_SED)?$])
-AT_SETUP([[AS_DIRNAME & AS_DIRNAME_SED]])
+AT_SETUP([[AS@&address@hidden)

-AT_DATA([configure.ac],
-[[AS@&address@hidden
-
-_AS@&address@hidden
+AT_DATA_M4SH([script.as],
+[[AS_INIT

+# The EXPR variant is allowed to fail if `expr' was considered as too
+# weak for us, in which case `as_expr=false'.
 m4_define([DIRNAME_TEST],
 [dir=`AS_DIRNAME([$1])`
 test "$dir" = "$2" ||
   echo "dirname($1) = $dir instead of $2" >&2

+if test "$as_expr" != false; then
+  dir=`AS_DIRNAME_EXPR([$1])`
+  test "$dir" = "$2" ||
+    echo "dirname_expr($1) = $dir instead of $2" >&2
+fi
+
 dir=`AS_DIRNAME_SED([$1])`
 test "$dir" = "$2" ||
   echo "dirname_sed($1) = $dir instead of $2" >&2])
@@ -137,25 +139,22 @@ m4_define([DIRNAME_TEST],
 AS_EXIT(0)
 ]])

-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE
+AT_CHECK_M4SH
+AT_CHECK([script])

-AT_CLEANUP(configure)
+AT_CLEANUP



-## ------------------------------- ##
-## AS_BASENAME & AS_BASENAME_SED.  ##
-## ------------------------------- ##
+## ------------- ##
+## AS_BASENAME.  ##
+## ------------- ##

 # Build nested dirs.
-m4_pattern_allow([^AS_BASENAME(_SED)?$])
-AT_SETUP([[AS_BASENAME & AS_BASENAME_SED]])
-
-AT_DATA([configure.ac],
-[[AS@&address@hidden
+AT_SETUP([[AS@&address@hidden)

-_AS@&address@hidden
+AT_DATA_M4SH([script.as],
+[[AS_INIT

 m4_define([BASENAME_TEST],
 [base=`AS_BASENAME([$1])`
@@ -197,10 +196,10 @@ m4_define([BASENAME_TEST],
 AS_EXIT(0)
 ]])

-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE
+AT_CHECK_M4SH
+AT_CHECK([script])

-AT_CLEANUP(configure)
+AT_CLEANUP



@@ -209,29 +208,28 @@ m4_define([BASENAME_TEST],
 ## ------------ ##

 # Build nested dirs.
-m4_pattern_allow([^AS_MKDIR_P$])
-AT_SETUP([[AS_MKDIR_P]])
+AT_SETUP([[AS@&address@hidden)

-AT_DATA([configure.ac],
-[[AS@&address@hidden
+AT_DATA_M4SH([script.as],
+[[AS_INIT

 pwd=`pwd`
 set -e
 # Absolute
 AS_MKDIR_P(["$pwd/1/2/3/4/5/6"])
 test -d "$pwd/1/2/3/4/5/6" ||
-  AC_MSG_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
+  AS_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
 # Relative
 AS_MKDIR_P(["a/b/c/d/e/f"])
 test -d a/b/c/d/e/f ||
-  AC_MSG_ERROR([a/b/c/d/e/f has not been properly created])
+  AS_ERROR([a/b/c/d/e/f has not been properly created])
 AS_EXIT(0)
 ]])

-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE
+AT_CHECK_M4SH
+AT_CHECK([script])

-AT_CLEANUP(configure 1 a)
+AT_CLEANUP(1 a)



@@ -245,20 +243,20 @@ m4_define([BASENAME_TEST],

 AT_SETUP([Negated classes in globbing])

-AT_DATA([configure.ac],
-[[AS@&address@hidden
+AT_DATA_M4SH([script.as],
+[[AS_INIT

 case 'with!two!bangs' in
   *[[!a-z]]*) ;;
-           *) AC_MSG_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
+           *) AS_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
 esac

 case without in
-  *[[!a-z]]*) AC_MSG_ERROR([[`*[!a-z]*' matched `without']]);;
+  *[[!a-z]]*) AS_ERROR([[`*[!a-z]*' matched `without']]);;
 esac
 ]])

-AT_CHECK_AUTOCONF
-AT_CHECK_CONFIGURE
+AT_CHECK_M4SH
+AT_CHECK([script])

 AT_CLEANUP
Index: tests/m4sugar.at
--- tests/m4sugar.at Thu, 30 Aug 2001 16:11:54 +0200 akim
+++ tests/m4sugar.at Sun, 07 Oct 2001 17:30:33 +0200 akim
@@ -32,8 +32,7 @@
 ## m4_warn.  ##
 ## --------- ##

-m4_pattern_allow([^m4_warn$])
-AT_SETUP([[m4_warn]])
+AT_SETUP([[m4@&address@hidden)

 # m4_text_wrap is used to display the help strings.  Also, check that
 # commas are not swallowed.  This can easily happen because of
@@ -42,29 +41,29 @@
 # FIXME: For the time being we use -f to make sure we do issue the
 # warnings.  But maybe autom4te should handle that by itself?

-AT_DATA([script.s4g],
+AT_DATA_M4SUGAR([script.4s],
 [[m4_warn([foo],  [foo])
 m4_warn([bar],    [bar])
 m4_warn([syntax], [syntax])
 ]])

 AT_CHECK_M4SUGAR([-o-], 0, [],
-[script.s4g:3: warning: syntax
+[script.4s:3: warning: syntax
 ])

 AT_CHECK_M4SUGAR([-o- -Wall -f], 0, [],
-[script.s4g:1: warning: foo
-script.s4g:2: warning: bar
-script.s4g:3: warning: syntax
+[script.4s:1: warning: foo
+script.4s:2: warning: bar
+script.4s:3: warning: syntax
 ])

 AT_CHECK_M4SUGAR([-o- -Wnone,bar -f], 0, [],
-[script.s4g:2: warning: bar
+[script.4s:2: warning: bar
 ])

 AT_CHECK_M4SUGAR([-o- -Wnone,bar,error -f], 1, [],
-[script.s4g:2: error: bar
-script.s4g:2: the top level
+[script.4s:2: error: bar
+script.4s:2: the top level
 ])

 AT_CLEANUP
@@ -74,14 +73,13 @@ script.s4g:2: the top level
 ## m4_require: circular dependencies.  ##
 ## ----------------------------------- ##

-m4_pattern_allow([^m4_(require|defun|init)$])
-AT_SETUP([[m4_require: circular dependencies]])
+AT_SETUP([[m4@&address@hidden: circular dependencies]])

 # m4_text_wrap is used to display the help strings.  Also, check that
 # commas are not swallowed.  This can easily happen because of
 # m4-listification.

-AT_DATA([script.s4g],
+AT_DATA_M4SUGAR([script.4s],
 [[m4_defun([foo],
 [m4_require([bar])])

@@ -95,17 +93,18 @@ script.s4g:2: the top level
 baz
 ]])

-AT_CHECK_M4SUGAR([], 1, [],
-[[script.s4g:11: error: m4_require: circular dependency of foo
-script.s4g:11: foo is required by...
-script.s4g:5: bar is expanded from...
-script.s4g:11: bar is required by...
-script.s4g:2: foo is expanded from...
-script.s4g:11: foo is required by...
-script.s4g:8: baz is expanded from...
-script.s4g:11: the top level
+AT_DATA_M4SUGAR([experr],
+[[script.4s:11: error: m4_require: circular dependency of foo
+script.4s:11: foo is required by...
+script.4s:5: bar is expanded from...
+script.4s:11: bar is required by...
+script.4s:2: foo is expanded from...
+script.4s:11: foo is required by...
+script.4s:8: baz is expanded from...
+script.4s:11: the top level
 ]])

+AT_CHECK_M4SUGAR([], 1, [], experr)
 AT_CLEANUP


@@ -113,15 +112,14 @@ script.s4g:11: the top level
 ## m4_text_wrap.  ##
 ## -------------- ##

-m4_pattern_allow([^m4_text_wrap$])
-AT_SETUP([[m4_text_wrap]])
+AT_SETUP([[m4@&address@hidden)

 # m4_text_wrap is used to display the help strings.  Also, check that
 # commas are not swallowed.  This can easily happen because of
 # m4-listification.

-AT_DATA([script.s4g],
-[[m4@&address@hidden([0])m4@&address@hidden([m4@&address@hidden([0])])d@&address@hidden
+AT_DATA_M4SUGAR([script.4s],
+[[m4_divert_push([0])m4_wrap([m4_divert_pop([0])])dnl
 m4_text_wrap([Short string */], [   ], [/* ], 20)

 m4_text_wrap([Much longer string */], [   ], [/* ], 20)
Index: tests/tools.at
--- tests/tools.at Sun, 07 Oct 2001 14:11:51 +0200 akim
+++ tests/tools.at Sun, 07 Oct 2001 16:46:43 +0200 akim
@@ -236,17 +236,12 @@ configure.ac:19:TRACE2:bar foo
 ## autoconf: forbidden tokens.  ##
 ## ---------------------------- ##

-# AT_DATA_FORBIDDEN(FILENAME, CONTENTS)
-# -------------------------------------
-# Escape the invalid tokens with @&address@hidden
-m4_define([AT_DATA_FORBIDDEN],
-[AT_DATA([$1], [m4_patsubst([$2], [\(m4\|AS\)_], [\1@&address@hidden)])])

 # autoconf: forbidden tokens, basic
 # ---------------------------------
 AT_SETUP([autoconf: forbidden tokens, basic])

-AT_DATA_FORBIDDEN([configure.ac],
+AT_DATA_M4SH([configure.ac],
 [[AS_INIT
 m4_foo
 _m4_bar
@@ -255,7 +250,7 @@ m4_define([AT_DATA_FORBIDDEN],
 [d@&address@hidden
 ]])

-AT_DATA_FORBIDDEN([experr],
+AT_DATA_M4SH([experr],
 [[configure.ac:2: error: possibly undefined macro: m4_foo
 configure.ac:3: error: possibly undefined macro: _m4_bar
 configure.ac:4: error: possibly undefined macro: AS_FOO
@@ -272,7 +267,7 @@ configure.ac:6: error: possibly undefine
 # --------------------------------------
 AT_SETUP([autoconf: forbidden tokens, exceptions])

-AT_DATA_FORBIDDEN([configure.ac],
+AT_DATA_M4SH([configure.ac],
 [[AS_INIT

 # This is allowed in spite of the name.
@@ -294,7 +289,7 @@ configure.ac:6: error: possibly undefine
 It would be very bad if Autoconf forgot to expand [AS_]INIT!
 ]])

-AT_DATA_FORBIDDEN([experr],
+AT_DATA_M4SH([experr],
 [[configure.ac:1: error: possibly undefined macro: AS_INIT
 configure.ac:7: error: possibly undefined macro: AS_ALLOWED_NOT
 configure.ac:10: error: possibly undefined macro: FORBIDDEN
Index: tests/README
--- tests/README Mon, 20 Aug 2001 09:04:59 +0200 akim
+++ tests/README Sun, 07 Oct 2001 17:44:29 +0200 akim
@@ -1,78 +0,0 @@
-                                                       -*- outline -*-
-
-This directory holds the M4sugar, M4sh and Autoconf test suites.
-
-
-Here are a few rules on how to write tests.
-
-* Order of the tests
-
-It is extremely important to pay attention to the order of the tests.
-There are basically two philosophies: (i) test earlier the most
-critical features (hence hurried users will at least check those), or
-(ii) test earlier the primitives.
-
-For having tried both, I definitely recommend (ii).  In practice users
-will run the whole test suite even if it's long.  And if they don't,
-there will be enough other users who will do the job.
-
-But also in practice some problems in the core of project can be
-responsible for an incredible number of failures.  Then the problems
-at the origin will be hidden by the consequences.  If dependencies are
-properly ordered in the test suite (test features which depend upon
-other features *after* having checked the latter), basically you'll
-just have to pay attention to the first failures.  BTW, it also makes
-`./testsuite -e' much more useful.
-
-
-* Write tests!
-
-Don't let you be bitten three times by the same dog!  When you spent a
-significant amount of time tracking the failure of feature in some
-more primitive problem, immediately write a test for the latter.
-
-If you track down several bugs down to the same origin, write a test
-especially for it.
-
-Of course in both cases, more primitive tests will be run beforehand.
-Write your test and have it failed before your fixing, and succeeding
-after.  This usually means having at hand two copies of the source
-tree, one running the test suite to have it fail, and the other to
-have the same testsuite succeed.
-
-
-* Autoconf
-
-** Use of `exit'
-Don't directly `exit 1' or `exit 77', rather use `AC_MSG_ERROR'.
-First of all because when we have to read the test suite logs we are
-happy to know why `configure' exited thanks to the error
-message. Secondly, because `configure' traps the `exit' and pretty
-many shells fail to set $? to 77 when trapping `exit 77'.  This
-results in the test suite not being able to check the exit status.
-
-** AC_MSG_ERROR
-Of course, since macro names are forbidden in `configure', if you
-really want to mention the macro name, you'll have to do without
-including `A?_' in the output.
-
------
-
-Copyright 2000 Free Software Foundation, Inc.
-
-This file is part of GNU Autoconf.
-
-GNU Autoconf 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.
-
-GNU Autoconf 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 autoconf; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.



reply via email to

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