[Pcre-svn] [1018] code/trunk/RunGrepTest: Fix RunGrepTest so…

Góra strony
Delete this message
Autor: Subversion repository
Data:  
Dla: pcre-svn
Temat: [Pcre-svn] [1018] code/trunk/RunGrepTest: Fix RunGrepTest so that it runs in a non-source build directory.
Revision: 1018
          http://vcs.pcre.org/viewvc?view=rev&revision=1018
Author:   ph10
Date:     2012-08-27 12:20:22 +0100 (Mon, 27 Aug 2012)


Log Message:
-----------
Fix RunGrepTest so that it runs in a non-source build directory. Recent changes
broke it.

Modified Paths:
--------------
    code/trunk/RunGrepTest


Modified: code/trunk/RunGrepTest
===================================================================
--- code/trunk/RunGrepTest    2012-08-26 16:30:50 UTC (rev 1017)
+++ code/trunk/RunGrepTest    2012-08-27 11:20:22 UTC (rev 1018)
@@ -2,7 +2,7 @@


# Run pcregrep tests. The assumption is that the PCRE tests check the library
# itself. What we are checking here is the file handling and options that are
-# supported by pcregrep.
+# supported by pcregrep. This script must be run in the build directory.

# Set the C locale, so that sort(1) behaves predictably.

@@ -14,9 +14,11 @@
unset PCREGREP_COLOUR PCREGREP_COLOR
unset cp ls mv rm

-# Set the program to be tested, and valgrind settings when requested.
+# Remember the current (build) directory, set the program to be tested, and
+# valgrind settings when requested.

-pcregrep=`pwd`/pcregrep
+builddir=`pwd`
+pcregrep=$builddir/pcregrep

valgrind=
while [ $# -gt 0 ] ; do
@@ -28,14 +30,13 @@
done

echo " "
+pcregrep_version=`$pcregrep -V`
if [ "$valgrind" = "" ] ; then
- echo "Testing pcregrep"
+ echo "Testing $pcregrep_version"
else
- echo "Testing pcregrep using valgrind"
+ echo "Testing $pcregrep_version using valgrind"
fi

-$pcregrep -V
-
# Set up a suitable "diff" command for comparison. Some systems have a diff
# that lacks a -u option. Try to deal with this; better do the test for the -b
# option as well.
@@ -45,12 +46,10 @@
diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
diff -ub /dev/null /dev/null 2>/dev/null && cf="diff -ub"

-# If PCRE has been built in a directory other than the source directory, and
-# this test is being run from "make check" as usual, then $srcdir will be
-# set. If not, set it to the current or parent directory, whichever one
-# contains the test data. We then arrange to run the pcregrep command in the
-# source directory so that the file names that appear in the output are always
-# the same.
+# If this test is being run from "make check", $srcdir will be set. If not, set
+# it to the current or parent directory, whichever one contains the test data.
+# Subsequently, we run most of the pcregrep tests in the source directory so
+# that the file names in the output are always the same.

if [ -z "$srcdir" -o ! -d "$srcdir/testdata" ] ; then
if [ -d "./testdata" ] ; then
@@ -68,6 +67,8 @@
./pcretest -C utf >/dev/null
utf8=$?

+echo "Testing pcregrep main features"
+
echo "---------------------------- Test 1 ------------------------------" >testtry
(cd $srcdir; $valgrind $pcregrep PATTERN ./testdata/grepinput) >>testtry
echo "RC=$?" >>testtry
@@ -118,7 +119,7 @@

echo "---------------------------- Test 13 -----------------------------" >>testtry
echo seventeen >testtemp1
-(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist -f testtemp1 ./testdata/grepinputx) >>testtry
+(cd $srcdir; $valgrind $pcregrep -f./testdata/greplist -f $builddir/testtemp1 ./testdata/grepinputx) >>testtry
echo "RC=$?" >>testtry

echo "---------------------------- Test 14 -----------------------------" >>testtry
@@ -408,7 +409,7 @@

echo "---------------------------- Test 84 -----------------------------" >>testtry
echo testdata/grepinput3 >testtemp1
-(cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --file-list testtemp1 "fox|complete|t7") >>testtry 2>&1
+(cd $srcdir; $valgrind $pcregrep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1 "fox|complete|t7") >>testtry 2>&1
echo "RC=$?" >>testtry

echo "---------------------------- Test 85 -----------------------------" >>testtry
@@ -462,19 +463,19 @@
echo "---------------------------- Test 97 -----------------------------" >>testtry
echo "grepinput$" >testtemp1
echo "grepinput8" >>testtemp1
-(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude-from testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
+(cd $srcdir; $valgrind $pcregrep -L -r --include=grepinput --exclude-from $builddir/testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
echo "RC=$?" >>testtry

echo "---------------------------- Test 98 -----------------------------" >>testtry
echo "grepinput$" >testtemp1
echo "grepinput8" >>testtemp1
-(cd $srcdir; $valgrind $pcregrep -L -r --exclude=grepinput3 --include=grepinput --exclude-from testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
+(cd $srcdir; $valgrind $pcregrep -L -r --exclude=grepinput3 --include=grepinput --exclude-from $builddir/testtemp1 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
echo "RC=$?" >>testtry

echo "---------------------------- Test 99 -----------------------------" >>testtry
echo "grepinput$" >testtemp1
echo "grepinput8" >testtemp2
-(cd $srcdir; $valgrind $pcregrep -L -r --include grepinput --exclude-from testtemp1 --exclude-from=testtemp2 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
+(cd $srcdir; $valgrind $pcregrep -L -r --include grepinput --exclude-from $builddir/testtemp1 --exclude-from=$builddir/testtemp2 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtry
echo "RC=$?" >>testtry

# Now compare the results.
@@ -509,7 +510,7 @@
# is not \n. Do not use exported files, whose line endings might be changed.
# Instead, create an input file using printf so that its contents are exactly
# what we want. Note the messy fudge to get printf to write a string that
-# starts with a hyphen.
+# starts with a hyphen. These tests are run in the build directory.

echo "Testing pcregrep newline settings"
printf "abc\rdef\r\nghi\njkl" >testNinput