bison-patches
[Top][All Lists]
Advanced

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

[PATCH] Fix portability issue in the test suite.


From: Akim Demaille
Subject: [PATCH] Fix portability issue in the test suite.
Date: Mon, 8 Dec 2008 10:26:38 +0100

        * tests/local.at (AT_MATCHES_CHECK): New.
        Based on Perl instead of Sed.  Sed has too many portability
        pitfalls, not ever Sed is GNU Sed.
        * tests/actions.at (Fix user actions without a trailing semicolon):
        Use it.
---
 ChangeLog        |    9 +++++++++
 tests/actions.at |   21 ++++++---------------
 tests/local.at   |   16 ++++++++++++++++
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 58ff6d8..719437a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-12-08  Akim Demaille  <address@hidden>
 
+       Fix portability issue in the test suite.
+       * tests/local.at (AT_MATCHES_CHECK): New.
+       Based on Perl instead of Sed.  Sed has too many portability
+       pitfalls, not ever Sed is GNU Sed.
+       * tests/actions.at (Fix user actions without a trailing semicolon):
+       Use it.
+
+2008-12-08  Akim Demaille  <address@hidden>
+
        Update data/README.
        * data/README: Document glr.cc, lalr1.java, m4sugar and xslt.
 
diff --git a/tests/actions.at b/tests/actions.at
index 32bfc34..841ae39 100644
--- a/tests/actions.at
+++ b/tests/actions.at
@@ -1400,20 +1400,11 @@ input.y:35.1: warning: future versions of Bison will 
not add the `;'
 input.y:36.1: warning: a `;' might be needed at the end of action code
 input.y:36.1: warning: future versions of Bison will not add the `;'
 ]])
-AT_CHECK([[grep -c '/\* TEST:N:2 \*/ }$' input.c]], [0], [[3
-]])
-AT_CHECK([[grep -c '/\* TEST:Y:2 \*/ ;}$' input.c]], [0], [[6
-]])
-AT_CHECK([[sed -n '/TEST:N:1/{N
-s/\n/<NL>/gp}' input.c | grep -c '// TEST:N:1 [;{}]*<NL>}$']], [0], [[6
-]])
-AT_CHECK([[sed -n '/TEST:Y:1/{N
-s/\n/<NL>/gp}' input.c | grep -c '// TEST:Y:1 [;{}]*<NL>;}$']], [0], [[12
-]])
-AT_CHECK([[sed -n '/^#define TEST_MACRO_N/{N
-N
-s/\n/<NL>/gp}' input.c | grep -F -xc '#define TEST_MACRO_N \<NL>[]"broken\" $ 
@ $$ @$ [];\<NL>string;"}']],
-       [0], [[2
-]])
+
+AT_MATCHES_CHECK([input.c], [[/\* TEST:N:2 \*/ \}$]],       [[3]])
+AT_MATCHES_CHECK([input.c], [[/\* TEST:Y:2 \*/ ;\}$]],      [[6]])
+AT_MATCHES_CHECK([input.c], [[// TEST:N:1 [;{}]*\n\}$]],    [[6]])
+AT_MATCHES_CHECK([input.c], [[// TEST:Y:1 [;{}]*\n;\}$]],  [[12]])
+AT_MATCHES_CHECK([input.c], [[#define TEST_MACRO_N \\\n\[\]"broken\\" \$ \@ 
\$\$ address@hidden \[\];\\\nstring;"\}]], [[2]])
 
 AT_CLEANUP
diff --git a/tests/local.at b/tests/local.at
index 19f53ce..086ff75 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -20,6 +20,22 @@
 m4_version_prereq([2.58])
 
 
+## ------------- ##
+## Basic tests.  ##
+## ------------- ##
+
+# AT_MATCHES_CHECK(FILE, PERL-REGEXP, COUNT)
+# ------------------------------------------
+# Expect COUNT matches of the PERL-REGEXP in FILE.  The file is
+# taken in "slurp" mode, i.e., one can match end-of-lines.
+m4_define([AT_MATCHES_CHECK],
+[AT_CHECK([perl -0777 -ne '
+my $count = 0;
+s{$2}{ ++$count; "" }gem;
+printf "$count\n";' $1], [0], [$3
+])])
+
+
 ## ------------------------------- ##
 ## Macros decoding Bison options.  ##
 ## ------------------------------- ##
-- 
1.6.0.4.790.gaa14a





reply via email to

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