automake-patches
[Top][All Lists]
Advanced

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

[PATCH] {maint} More tests on macro `AM_WITH_REGEX'.


From: Stefano Lattarini
Subject: [PATCH] {maint} More tests on macro `AM_WITH_REGEX'.
Date: Mon, 20 Sep 2010 23:08:34 +0200
User-agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )

This patch increase coverage for a macro I'm planning to touch
soon (to make it use AS_HELP_STRING).  OK for maint?

Regards,
   Stefano

-*-*-*-

More tests on macro `AM_WITH_REGEX'.

* tests/regex.test: Extend with more configure runs.  Add
trailing `:' command.
* tests/regex2.test: New test.
* tests/regex3.test: Likewise.
* tests/Makefile.am (TESTS): Updated
---
 ChangeLog         |    9 +++++
 tests/Makefile.am |    2 +
 tests/Makefile.in |    2 +
 tests/regex.test  |    6 +++
 tests/regex2.test |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/regex3.test |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 199 insertions(+), 0 deletions(-)
 create mode 100755 tests/regex2.test
 create mode 100755 tests/regex3.test

From 94a164b710baf0672e41eb4e38cd2041e1c9776d Mon Sep 17 00:00:00 2001
From: Stefano Lattarini <address@hidden>
Date: Mon, 20 Sep 2010 22:57:15 +0200
Subject: [PATCH] More tests on macro `AM_WITH_REGEX'.

* tests/regex.test: Extend with more configure runs.  Add
trailing `:' command.
* tests/regex2.test: New test.
* tests/regex3.test: Likewise.
* tests/Makefile.am (TESTS): Updated
---
 ChangeLog         |    9 +++++
 tests/Makefile.am |    2 +
 tests/Makefile.in |    2 +
 tests/regex.test  |    6 +++
 tests/regex2.test |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/regex3.test |   95 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 199 insertions(+), 0 deletions(-)
 create mode 100755 tests/regex2.test
 create mode 100755 tests/regex3.test

diff --git a/ChangeLog b/ChangeLog
index 0328c5a..bb608e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-20  Stefano Lattarini  <address@hidden>
+
+       More tests on macro `AM_WITH_REGEX'.
+       * tests/regex.test: Extend with more configure runs.  Add
+       trailing `:' command.
+       * tests/regex2.test: New test.
+       * tests/regex3.test: Likewise.
+       * tests/Makefile.am (TESTS): Updated
+
 2010-09-15  Stefano Lattarini  <address@hidden>
 
        Test automake-generated portions of configure help screen.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ba695f5..ae7f940 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -614,6 +614,8 @@ remake5.test \
 remake6.test \
 remake7.test \
 regex.test \
+regex2.test \
+regex3.test \
 req.test \
 reqd.test \
 reqd2.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 9ea9d74..f5ec13c 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -852,6 +852,8 @@ remake5.test \
 remake6.test \
 remake7.test \
 regex.test \
+regex2.test \
+regex3.test \
 req.test \
 reqd.test \
 reqd2.test \
diff --git a/tests/regex.test b/tests/regex.test
index babd92a..9b14a54 100755
--- a/tests/regex.test
+++ b/tests/regex.test
@@ -15,6 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Make sure AM_WITH_REGEX compiles and runs.
+# See also related tests `regex2.test' and `regex3.test'
 
 . ./defs || Exit 1
 
@@ -28,3 +29,8 @@ $ACLOCAL
 $AUTOCONF
 ./configure
 ./configure --without-regex
+./configure --with-regex
+./configure --with-regex=no
+./configure --with-regex=yes
+
+:
diff --git a/tests/regex2.test b/tests/regex2.test
new file mode 100755
index 0000000..d997068
--- /dev/null
+++ b/tests/regex2.test
@@ -0,0 +1,85 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Make sure AM_WITH_REGEX compiles and runs as advertised in
+# documentation.
+# See also sister test `regex3.test'
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_HEADERS([config.h])
+AM_WITH_REGEX
+AC_OUTPUT
+END
+
+cat > config.h.in <<'END'
+#undef WITH_REGEX
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+check-local:
+       @echo "with_regex='$$with_regex'"
+       grep '#.*WITH_REGEX' config.h
+       output=`./foo`; \
+       echo "output='$$output'"; \
+       if test x"$$with_regex" = x"yes"; then \
+         test x"$$output" = x'WITH_REGEX=1'; \
+       else \
+         test x"$$output" = x'undef WITH_REGEX'; \
+       fi
+END
+
+cat > foo.c <<'END'
+#include <config.h>
+#include <stdio.h>
+int main(void)
+{
+#ifndef WITH_REGEX
+  printf("undef WITH_REGEX\n");
+#else
+  printf("WITH_REGEX=%d\n", (WITH_REGEX));
+#endif
+  return 0;
+}
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+for result_option in \
+  'yes' \
+  'no --without-regex' \
+  'yes --with-regex' \
+  'no --with-regex=no' \
+  'yes --with-regex=yes' \
+; do
+  set x $result_option
+  result=$2
+  option=$3
+  # For systems lacking both `regex' and `rx' libraries.
+  config_args="$option am_cv_gnu_regex=yes ac_cv_func_re_rx_search=yes"
+  ./configure $config_args
+  with_regex="$result" $MAKE check
+  with_regex="$result" $MAKE distcheck \
+                             "DISTCHECK_CONFIGURE_FLAGS=$config_args"
+done
+
+:
diff --git a/tests/regex3.test b/tests/regex3.test
new file mode 100755
index 0000000..e2967b1
--- /dev/null
+++ b/tests/regex3.test
@@ -0,0 +1,95 @@
+#! /bin/sh
+# Copyright (C) 2010 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/>.
+
+# Make sure AM_WITH_REGEX works even when both `rx' and `regex'
+# libraries are absent on the system.
+# See also sister test `regex2.test'
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_HEADERS([config.h])
+AM_WITH_REGEX
+AC_SUBST([am_cv_gnu_regex])
+AC_SUBST([ac_cv_func_re_rx_search])
+AC_OUTPUT
+END
+
+cat > config.h.in <<'END'
+#undef WITH_REGEX
+END
+
+cat > Makefile.am <<'END'
+bin_PROGRAMS = foo
+foo_LDADD = $(LIBOBJS)
+check-local:
+       @echo "with_regex='$$with_regex'"
+       @echo 'am_cv_gnu_regex=$(am_cv_gnu_regex)'
+       @echo 'ac_cv_func_re_rx_search=$(ac_cv_func_re_rx_search)'
+       grep '#.*WITH_REGEX' config.h # sanity check
+       output=`./foo`; \
+       echo "output='$$output'"; \
+       if test x"$$with_regex" = x"yes"; then \
+         test x"$$output" = x'regex, WITH_REGEX=1'; \
+       else \
+         test x"$$output" = x'rx, undef WITH_REGEX'; \
+       fi
+END
+
+cat > foo.c <<'END'
+#include <config.h>
+#include <stdio.h>
+#include "regex.h"
+int main(void)
+{
+  printf("%s, ", foo);
+#ifndef WITH_REGEX
+  printf("undef WITH_REGEX\n");
+#else
+  printf("WITH_REGEX=%d\n", (WITH_REGEX));
+#endif
+  return 0;
+}
+END
+
+echo 'char *foo = "regex";' > regex.c
+echo 'char *foo = "rx";'    > rx.c
+echo 'extern char *foo;'    > regex.h
+echo 'extern char *foo;'    > rx.h
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+# Use less options than in test `regex2.test', otherwise the
+# test takes too long.
+for result_option in \
+  'no --without-regex' \
+  'yes --with-regex' \
+; do
+  set x $result_option
+  result=$2
+  option=$3
+  config_args="$option am_cv_gnu_regex=no ac_cv_func_re_rx_search=no"
+  ./configure $config_args
+  with_regex="$result" $MAKE check
+  with_regex="$result" $MAKE distcheck \
+                             "DISTCHECK_CONFIGURE_FLAGS=$config_args"
+done
+
+:
-- 
1.7.1


reply via email to

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