bug-grep
[Top][All Lists]
Advanced

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

Re: [PATCH 10/17] tests: add more UTF-8 test cases


From: Jim Meyering
Subject: Re: [PATCH 10/17] tests: add more UTF-8 test cases
Date: Sat, 13 Mar 2010 11:32:57 +0100

Paolo Bonzini wrote:
> * tests/Makefile.am (TESTS): Add spencer1-locale.sh.
> (EXTRA_DIST): Add spencer1-locale.awk.
> * tests/spencer1-locale.awk: New.
> * tests/spencer1-locale.sh: New.
...
> +     printf ("status=`echo '%s'| { LC_ALL=%s ${GREP} -E -e '%s' >/dev/null 
> 2>&1 ; echo $?; }`\n",$3, locale, $2);
> +     printf ("if test $status -ne %s ; then\n", $1);
> +     printf ("\techo Spencer test \\#%d failed \\(%s\\)\n", ++n, locale);
> +     printf ("\tfailures=1\n");
> +     printf ("fi\n");
> +}
> +
> +END { printf ("exit $failures\n"); }
> diff --git a/tests/spencer1-locale.sh b/tests/spencer1-locale.sh
> new file mode 100755
> index 0000000..62df29d
> --- /dev/null
> +++ b/tests/spencer1-locale.sh
> @@ -0,0 +1,20 @@
> +#! /bin/sh
> +# Regression test for GNU grep.
> +#
> +# Copyright (C) 1988 Henry Spencer.
> +# Copyright (C) 2009-2010 Free Software Foundation, Inc.
> +#
> +# Copying and distribution of this file, with or without modification,
> +# are permitted in any medium without royalty provided the copyright
> +# notice and this notice are preserved.
> +
> +: ${srcdir=.}
> +
> +failures=0
> +
> +# . . . and the following by Henry Spencer.
> +
> +${AWK-awk} -vextra_locale=$LOCALE_FR_UTF8 -f $srcdir/spencer1-locale.awk 
> $srcdir/spencer1.tests > spencer1-locale.script
> +
> +sh spencer1-locale.script && exit $failures
> +exit 1

The above is ok, but runs in the tests/ directory.
That forces us to choose local file names that won't collide
with any other test, which does not scale well (tests can now run
in parallel).  So let's use the new framework that runs each test
in its very own directory.

To do that, I had to make a few small adjustments.

 - use "grep", not "${GREP}", since the latter was a relative name
     that became invalid when invoked from a different (lower) level
     in the hierarchy.
 - specify tests/-relative input file names via $abs_srcdir
 - also, if running the awk script fails, and creates an empty
     spencer1-locale.script file, we don't want to mistakenly pass the test.
 - avoid longer-than-80-col lines (though I missed one in spencer1-locale.awk)

You're welcome to fold these changes into yours.
Don't bother with attribution.

diff --git a/tests/spencer1-locale.awk b/tests/spencer1-locale.awk
index e5d3a7b..b22de30 100644
--- a/tests/spencer1-locale.awk
+++ b/tests/spencer1-locale.awk
@@ -20,7 +20,7 @@ $0 !~ /^#/  && NF == 3 {

 function test(locale)
 {
-       printf ("status=`echo '%s'| { LC_ALL=%s ${GREP} -E -e '%s' >/dev/null 
2>&1 ; echo $?; }`\n",$3, locale, $2);
+       printf ("status=`echo '%s'| { LC_ALL=%s grep -E -e '%s' >/dev/null 2>&1 
; echo $?; }`\n",$3, locale, $2);
        printf ("if test $status -ne %s ; then\n", $1);
        printf ("\techo Spencer test \\#%d failed \\(%s\\)\n", ++n, locale);
        printf ("\tfailures=1\n");
diff --git a/tests/spencer1-locale.sh b/tests/spencer1-locale.sh
index 62df29d..f0b2011 100755
--- a/tests/spencer1-locale.sh
+++ b/tests/spencer1-locale.sh
@@ -9,12 +9,16 @@
 # notice and this notice are preserved.

 : ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ ../src

-failures=0
+fail=0

 # . . . and the following by Henry Spencer.

-${AWK-awk} -vextra_locale=$LOCALE_FR_UTF8 -f $srcdir/spencer1-locale.awk 
$srcdir/spencer1.tests > spencer1-locale.script
+${AWK-awk} -vextra_locale=$LOCALE_FR_UTF8 \
+    -f "$abs_srcdir/spencer1-locale.awk" "$abs_srcdir/spencer1.tests" \
+  > spencer1-locale.script || fail=1

-sh spencer1-locale.script && exit $failures
-exit 1
+sh spencer1-locale.script || fail=1
+
+Exit $fail




reply via email to

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