bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] tests: portability fix.


From: Joel E. Denny
Subject: Re: [PATCH] tests: portability fix.
Date: Thu, 27 Aug 2009 04:12:08 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

On Wed, 26 Aug 2009, Akim Demaille wrote:

> > Maybe we need to skip this test if od shows that input.y doesn't look
> > right.
> 
> I would rather use Perl, which is widely available and it's easy to skip if it
> is not, to generate the input.

Perfect for me!  Thanks.  I'll do that from now on.  I pushed this to 
master and branch-2.5, and I pushed the relevant parts to branch-2.4.2.

>From b70c7fb4e1db54e78d4f3d4a0f110a81118ffc60 Mon Sep 17 00:00:00 2001
From: Joel E. Denny <address@hidden>
Date: Thu, 27 Aug 2009 03:52:53 -0400
Subject: [PATCH] tests: use perl for printing special sequences to files.

And skip tests if perl is not available.  This is better than
playing tricks with shell portability.  Suggested by Akim
Demaille.
* tests/input.at (Bad character literals): Use it here for
omitting final newlines.
(Bad escapes in literals): Use it here for special characters.
---
 ChangeLog      |   10 ++++++++++
 tests/input.at |   19 ++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 44f27ff..aaeb444 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-08-27  Joel E. Denny  <address@hidden>
+
+       tests: use perl for printing special sequences to files.
+       And skip tests if perl is not available.  This is better than
+       playing tricks with shell portability.  Suggested by Akim
+       Demaille.
+       * tests/input.at (Bad character literals): Use it here for
+       omitting final newlines.
+       (Bad escapes in literals): Use it here for special characters.
+
 2009-08-26  Joel E. Denny  <address@hidden>
 
        tests: show a use of %define lr.default-reductions "consistent"
diff --git a/tests/input.at b/tests/input.at
index 36a6d40..3d82159 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -1166,10 +1166,8 @@ AT_CLEANUP
 # Bison used to accept character literals that were empty or contained
 # too many characters.
 
-# FIXME: $ECHO_N and $ECHO_C are not very portable according to the
-# Autoconf manual.  Switch to AS_ECHO_N when Autoconf 2.64 is released?
-# Even better, AT_DATA or some variant of AT_DATA may eventually permit
-# a trailing newline.  See the threads starting at
+# FIXME: AT_DATA or some variant of AT_DATA may eventually permit
+# the final newline to be omitted.  See the threads starting at
 # <http://lists.gnu.org/archive/html/bison-patches/2009-07/msg00019.html>.
 
 AT_SETUP([[Bad character literals]])
@@ -1179,7 +1177,7 @@ AT_DATA([empty.y],
 start: '';
 start: '
 ]])
-echo $ECHO_N "start: '$ECHO_C" >> empty.y
+AT_CHECK([[perl -e "print 'start: \'';" >> empty.y || exit 77]])
 
 AT_BISON_CHECK([empty.y], [1], [],
 [[empty.y:2.8-9: warning: empty character literal
@@ -1194,7 +1192,7 @@ AT_DATA([two.y],
 start: 'ab';
 start: 'ab
 ]])
-echo $ECHO_N "start: 'ab$ECHO_C" >> two.y
+AT_CHECK([[perl -e "print 'start: \'ab';" >> two.y || exit 77]])
 
 AT_BISON_CHECK([two.y], [1], [],
 [[two.y:2.8-11: warning: extra characters in character literal
@@ -1209,7 +1207,7 @@ AT_DATA([three.y],
 start: 'abc';
 start: 'abc
 ]])
-echo $ECHO_N "start: 'abc$ECHO_C" >> three.y
+AT_CHECK([[perl -e "print 'start: \'abc';" >> three.y || exit 77]])
 
 AT_BISON_CHECK([three.y], [1], [],
 [[three.y:2.8-12: warning: extra characters in character literal
@@ -1234,13 +1232,12 @@ start: '\777' '\0' '\xfff' '\x0'
        '\ ' '\A';
 ]])
 
-# It is not easy to create special characters, we can only trust tr.
+# It is not easy to create special characters, we cannot even trust tr.
 # Beside we cannot even expect "echo '\0'" to output two characters
 # (well three with \n): at least Bash 3.2 converts the two-character
 # sequence "\0" into a single NUL character.
-#
-# Z for 0, O for 1.
-echo 'start: "\T\F\Z\O" ;' | tr 'TFZO' '\011\014\0\1' >> input.y
+AT_CHECK([[perl -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \
+           || exit 77]])
 
 AT_BISON_CHECK([input.y], [1], [],
 [[input.y:2.9-12: invalid number after \-escape: 777
-- 
1.5.4.3





reply via email to

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