mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 07:59:05 +08:00
d83ef07ca7
This adds the new builtin 'string' which supports various string manipulation and matching algorithms, including PCRE based regular expressions. Fixes #2296 Squashed commit of the following: commit 4c3eaeb6e57d76463e9683c327142b0aeafb92b8 Author: ridiculousfish <corydoras@ridiculousfish.com> Date: Sat Sep 12 12:51:30 2015 -0700 Remove testdata and doc dirs from pcre2 source commit b2a8b4b50f2398b204fb72cfe4b5ba77ece2e1ab Merge:11c8a47
7974aab
Author: ridiculousfish <corydoras@ridiculousfish.com> Date: Sat Sep 12 12:32:40 2015 -0700 Merge branch 'string' of git://github.com/msteed/fish-shell into string-test commit7974aab6d3
Author: Michael Steed <msteed@saltstack.com> Date: Fri Sep 11 13:00:02 2015 -0600 build pcre2 lib only, no docs commiteb20b43d2d
Merge:1a09e70
5f519cb
Author: Michael Steed <msteed68@gmail.com> Date: Thu Sep 10 20:00:47 2015 -0600 Merge branch 'string' of github.com:msteed/fish-shell into string commit1a09e709d0
Author: Michael Steed <msteed68@gmail.com> Date: Thu Sep 10 19:58:24 2015 -0600 rebase on master & address the fallout commita0ec9772cd
Author: Michael Steed <msteed68@gmail.com> Date: Thu Sep 10 19:26:45 2015 -0600 use fish's wildcard_match() for glob matching commit64c25a01e3
Author: Michael Steed <msteed68@gmail.com> Date: Thu Aug 27 08:19:23 2015 -0600 some fixes from review - string_get_arg_stdin(): simplify and don't discard the argument when the trailing newline is absent - fix calls to pcre2 for e.g. string match -r -a 'a*' 'b' - correct test for args coming from stdin commitece7f35ec5
Author: Michael Steed <msteed68@gmail.com> Date: Sat Aug 22 19:35:56 2015 -0600 fixes from review - Makefile.in: restore iwyu target - regex_replacer_t::replace_matches(): correct size passed to realloc() commit9ff7477a92
Author: Michael Steed <msteed68@gmail.com> Date: Thu Aug 20 13:08:33 2015 -0600 Minor doc improvements commitbaf4e096b2
Author: Michael Steed <msteed68@gmail.com> Date: Wed Aug 19 18:29:02 2015 -0600 another attempt to fix the ci build commit896a2c2b27
Author: Michael Steed <msteed68@gmail.com> Date: Wed Aug 19 18:03:49 2015 -0600 Updates after review comments - make match/replace without -a operate on the first match on each argument - use different exit codes for "no operation performed" and errors, as grep does - refactor regex compile code - use human-friendly error messages from pcre2 - improve error handling & reporting elsewhere - add a few tests - make some doc fixes - some simplification & cleanup - fix ci build failure (I hope) commitefd47dcbda
Author: Michael Steed <msteed68@gmail.com> Date: Wed Aug 12 00:26:07 2015 -0600 fix dependencies for parallel make commited0850e2db
Author: Michael Steed <msteed68@gmail.com> Date: Tue Aug 11 23:37:22 2015 -0600 Add missing pcre2 files + .gitignore commit9492e7a7e9
Author: Michael Steed <msteed68@gmail.com> Date: Tue Aug 11 22:44:05 2015 -0600 add pcre2-10.20 and update license.hdr commit1a60b93371
Author: Michael Steed <msteed68@gmail.com> Date: Tue Aug 11 22:41:19 2015 -0600 add string builtin files - string builtin source, tests, & docs - changes to configure.ac & Makefile.in commit5f519cb2a2
Author: Michael Steed <msteed68@gmail.com> Date: Thu Sep 10 19:26:45 2015 -0600 use fish's wildcard_match() for glob matching commit2ecd24f795
Author: Michael Steed <msteed68@gmail.com> Date: Thu Aug 27 08:19:23 2015 -0600 some fixes from review - string_get_arg_stdin(): simplify and don't discard the argument when the trailing newline is absent - fix calls to pcre2 for e.g. string match -r -a 'a*' 'b' - correct test for args coming from stdin commit45b777e4dc
Author: Michael Steed <msteed68@gmail.com> Date: Sat Aug 22 19:35:56 2015 -0600 fixes from review - Makefile.in: restore iwyu target - regex_replacer_t::replace_matches(): correct size passed to realloc() commit981cbb6ddf
Author: Michael Steed <msteed68@gmail.com> Date: Thu Aug 20 13:08:33 2015 -0600 Minor doc improvements commitddb6a2a8fd
Author: Michael Steed <msteed68@gmail.com> Date: Wed Aug 19 18:29:02 2015 -0600 another attempt to fix the ci build commit1e34e3191b
Author: Michael Steed <msteed68@gmail.com> Date: Wed Aug 19 18:03:49 2015 -0600 Updates after review comments - make match/replace without -a operate on the first match on each argument - use different exit codes for "no operation performed" and errors, as grep does - refactor regex compile code - use human-friendly error messages from pcre2 - improve error handling & reporting elsewhere - add a few tests - make some doc fixes - some simplification & cleanup - fix ci build failure (I hope) commit34232e152d
Author: Michael Steed <msteed68@gmail.com> Date: Wed Aug 12 00:26:07 2015 -0600 fix dependencies for parallel make commit00d7e78169
Author: Michael Steed <msteed68@gmail.com> Date: Tue Aug 11 23:37:22 2015 -0600 Add missing pcre2 files + .gitignore commit4498aa5f57
Author: Michael Steed <msteed68@gmail.com> Date: Tue Aug 11 22:44:05 2015 -0600 add pcre2-10.20 and update license.hdr commit290c58c72e
Author: Michael Steed <msteed68@gmail.com> Date: Tue Aug 11 22:41:19 2015 -0600 add string builtin files - string builtin source, tests, & docs - changes to configure.ac & Makefile.in
613 lines
29 KiB
Bash
Executable File
613 lines
29 KiB
Bash
Executable File
#! /bin/sh
|
|
|
|
# Run pcre2grep tests. The assumption is that the PCRE2 tests check the library
|
|
# itself. What we are checking here is the file handling and options that are
|
|
# supported by pcre2grep. This script must be run in the build directory.
|
|
|
|
# Set the C locale, so that sort(1) behaves predictably.
|
|
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
|
|
# Remove any non-default colouring and aliases that the caller may have set.
|
|
|
|
unset PCRE2GREP_COLOUR PCRE2GREP_COLOR
|
|
unset cp ls mv rm
|
|
|
|
# Remember the current (build) directory, set the program to be tested, and
|
|
# valgrind settings when requested.
|
|
|
|
builddir=`pwd`
|
|
pcre2grep=$builddir/pcre2grep
|
|
|
|
if [ ! -x $pcre2grep ] ; then
|
|
echo "** $pcre2grep does not exist or is not execuatble."
|
|
exit 1
|
|
fi
|
|
|
|
valgrind=
|
|
while [ $# -gt 0 ] ; do
|
|
case $1 in
|
|
valgrind) valgrind="valgrind -q --leak-check=no --smc-check=all";;
|
|
*) echo "RunGrepTest: Unknown argument $1"; exit 1;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
echo " "
|
|
pcre2grep_version=`$pcre2grep -V`
|
|
if [ "$valgrind" = "" ] ; then
|
|
echo "Testing $pcre2grep_version"
|
|
else
|
|
echo "Testing $pcre2grep_version using valgrind"
|
|
fi
|
|
|
|
# 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.
|
|
|
|
cf="diff"
|
|
diff -b /dev/null /dev/null 2>/dev/null && cf="diff -b"
|
|
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 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 pcre2grep 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
|
|
srcdir=.
|
|
elif [ -d "../testdata" ] ; then
|
|
srcdir=..
|
|
else
|
|
echo "Cannot find the testdata directory"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Check for the availability of UTF-8 support
|
|
|
|
./pcre2test -C unicode >/dev/null
|
|
utf8=$?
|
|
|
|
# ------ Function to run and check a special pcre2grep arguments test -------
|
|
|
|
checkspecial()
|
|
{
|
|
$valgrind ./pcre2grep $1 >>testtrygrep 2>&1
|
|
if [ $? -ne $2 ] ; then
|
|
echo "** pcre2grep $1 failed - check testtrygrep"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# ------ Normal tests ------
|
|
|
|
echo "Testing pcre2grep main features"
|
|
|
|
echo "---------------------------- Test 1 ------------------------------" >testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep PATTERN ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 2 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep '^PATTERN' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 3 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -in PATTERN ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 4 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -ic PATTERN ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 5 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -in PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 6 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -inh PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 7 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -il PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 8 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -l PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 9 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -q PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 10 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -q NEVER-PATTERN ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 11 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -vn pattern ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 12 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -ix pattern ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 13 -----------------------------" >>testtrygrep
|
|
echo seventeen >testtemp1grep
|
|
(cd $srcdir; $valgrind $pcre2grep -f./testdata/greplist -f $builddir/testtemp1grep ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 14 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -w pat ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 15 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep 'abc^*' ./testdata/grepinput) 2>>testtrygrep >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 16 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep abc ./testdata/grepinput ./testdata/nonexistfile) 2>>testtrygrep >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 17 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -M 'the\noutput' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 18 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -Mn '(the\noutput|dog\.\n--)' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 19 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -Mix 'Pattern' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 20 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -Mixn 'complete pair\nof lines' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 21 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -nA3 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 22 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -nB3 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 23 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -C3 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 24 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -A9 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 25 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -nB9 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 26 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -A9 -B9 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 27 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -A10 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 28 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -nB10 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 29 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -C12 -B10 'four' ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 30 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -inB3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 31 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -inA3 'pattern' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 32 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -L 'fox' ./testdata/grepinput ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 33 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 34 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -s 'fox' ./testdata/grepnonexist) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 35 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -L -r --include=grepinputx --include grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 36 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -L -r --include=grepinput --exclude 'grepinput$' --exclude=grepinput8 --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 37 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep '^(a+)*\d' ./testdata/grepinput) >>testtrygrep 2>teststderrgrep
|
|
echo "RC=$?" >>testtrygrep
|
|
echo "======== STDERR ========" >>testtrygrep
|
|
cat teststderrgrep >>testtrygrep
|
|
|
|
echo "---------------------------- Test 38 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep '>\x00<' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 39 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -A1 'before the binary zero' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 40 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -B1 'after the binary zero' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 41 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -B1 -o '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 42 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -B1 -onH '\w+ the binary zero' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 43 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -on 'before|zero|after' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 44 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -on -e before -ezero -e after ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 45 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -on -f ./testdata/greplist -e binary ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 46 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -eabc -e '(unclosed' ./testdata/grepinput) 2>>testtrygrep >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 47 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -Fx "AB.VE
|
|
elephant" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 48 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -F "AB.VE
|
|
elephant" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 49 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -F -e DATA -e "AB.VE
|
|
elephant" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 50 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep "^(abc|def|ghi|jkl)" ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 51 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -Mv "brown\sfox" ./testdata/grepinputv) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 52 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --colour=always jumps ./testdata/grepinputv) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 53 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --file-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 54 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --line-offsets 'before|zero|after' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 55 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -f./testdata/greplist --color=always ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 56 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -c lazy ./testdata/grepinput*) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 57 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -c -l lazy ./testdata/grepinput*) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 58 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --regex=PATTERN ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 59 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --regexp=PATTERN ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 60 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --regex PATTERN ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 61 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --regexp PATTERN ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 62 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --match-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 63 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --recursion-limit=1000 --no-jit -M 'This is a file(.|\R)*file.' ./testdata/grepinput) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 64 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o1 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 65 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 66 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o3 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 67 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o12 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 68 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --only-matching=2 '(?<=PAT)TERN (ap(pear)s)' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 69 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -vn --colour=always pattern ./testdata/grepinputx) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 70 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --color=always -M "triple:\t.*\n\n" ./testdata/grepinput3) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 71 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 72 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --color=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 73 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o --colour=always "^01|^02|^03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 74 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o "^01|02|^03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 75 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --color=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 76 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o --colour=always "^01|02|^03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 77 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o "^01|^02|03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 78 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --color=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 79 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o --colour=always "^01|^02|03" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 80 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o "\b01|\b02" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 81 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --color=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 82 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o --colour=always "\\b01|\\b02" ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 83 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --buffer-size=100 "^a" ./testdata/grepinput3) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 84 -----------------------------" >>testtrygrep
|
|
echo testdata/grepinput3 >testtemp1grep
|
|
(cd $srcdir; $valgrind $pcre2grep --file-list ./testdata/grepfilelist --file-list $builddir/testtemp1grep "fox|complete|t7") >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 85 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --file-list=./testdata/grepfilelist "dolor" ./testdata/grepinput3) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 86 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 87 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 88 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -v "cat" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 89 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -I "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 90 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --binary-files=without-match "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 91 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -a "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 92 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --binary-files=text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 93 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --text "dog" ./testdata/grepbinary) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 94 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -L -r --include=grepinputx --include grepinput8 'fox' ./testdata/grepinput* | sort) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 95 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --file-list ./testdata/grepfilelist --exclude grepinputv "fox|complete") >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 96 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -L -r --include-dir=testdata --exclude '^(?!grepinput)' 'fox' ./test* | sort) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 97 -----------------------------" >>testtrygrep
|
|
echo "grepinput$" >testtemp1grep
|
|
echo "grepinput8" >>testtemp1grep
|
|
(cd $srcdir; $valgrind $pcre2grep -L -r --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 98 -----------------------------" >>testtrygrep
|
|
echo "grepinput$" >testtemp1grep
|
|
echo "grepinput8" >>testtemp1grep
|
|
(cd $srcdir; $valgrind $pcre2grep -L -r --exclude=grepinput3 --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 99 -----------------------------" >>testtrygrep
|
|
echo "grepinput$" >testtemp1grep
|
|
echo "grepinput8" >testtemp2grep
|
|
(cd $srcdir; $valgrind $pcre2grep -L -r --include grepinput --exclude-from $builddir/testtemp1grep --exclude-from=$builddir/testtemp2grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 100 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -Ho2 --only-matching=1 -o3 '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 101 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -o3 -Ho2 -o12 --only-matching=1 -o3 --colour=always --om-separator='|' '(\w+) binary (\w+)(\.)?' ./testdata/grepinput) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 102 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -n "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 103 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 104 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -n --only-matching "^$" ./testdata/grepinput3) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 105 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --colour=always "ipsum|" ./testdata/grepinput3) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 106 -----------------------------" >>testtrygrep
|
|
(cd $srcdir; echo "a" | $valgrind $pcre2grep -M "|a" ) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test 107 -----------------------------" >>testtrygrep
|
|
echo "a" >testtemp1grep
|
|
echo "aaaaa" >>testtemp1grep
|
|
(cd $srcdir; $valgrind $pcre2grep --line-offsets '(?<=\Ka)' $builddir/testtemp1grep) >>testtrygrep 2>&1
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
# Now compare the results.
|
|
|
|
$cf $srcdir/testdata/grepoutput testtrygrep
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
|
|
# These tests require UTF-8 support
|
|
|
|
if [ $utf8 -ne 0 ] ; then
|
|
echo "Testing pcre2grep UTF-8 features"
|
|
|
|
echo "---------------------------- Test U1 ------------------------------" >testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -n -u --newline=any "^X" ./testdata/grepinput8) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test U2 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep -n -u -C 3 --newline=any "Match" ./testdata/grepinput8) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
echo "---------------------------- Test U3 ------------------------------" >>testtrygrep
|
|
(cd $srcdir; $valgrind $pcre2grep --line-offsets -u --newline=any '(?<=\K\x{17f})' ./testdata/grepinput8) >>testtrygrep
|
|
echo "RC=$?" >>testtrygrep
|
|
|
|
$cf $srcdir/testdata/grepoutput8 testtrygrep
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
else
|
|
echo "Skipping pcre2grep UTF-8 tests: no UTF-8 support in PCRE2 library"
|
|
fi
|
|
|
|
|
|
# We go to some contortions to try to ensure that the tests for the various
|
|
# newline settings will work in environments where the normal newline sequence
|
|
# 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. These tests are run in the build directory.
|
|
|
|
echo "Testing pcre2grep newline settings"
|
|
printf "abc\rdef\r\nghi\njkl" >testNinputgrep
|
|
|
|
printf "%c--------------------------- Test N1 ------------------------------\r\n" - >testtrygrep
|
|
$valgrind $pcre2grep -n -N CR "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
|
|
|
printf "%c--------------------------- Test N2 ------------------------------\r\n" - >>testtrygrep
|
|
$valgrind $pcre2grep -n --newline=crlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
|
|
|
printf "%c--------------------------- Test N3 ------------------------------\r\n" - >>testtrygrep
|
|
pattern=`printf 'def\rjkl'`
|
|
$valgrind $pcre2grep -n --newline=cr -F "$pattern" testNinputgrep >>testtrygrep
|
|
|
|
printf "%c--------------------------- Test N4 ------------------------------\r\n" - >>testtrygrep
|
|
$valgrind $pcre2grep -n --newline=crlf -F -f $srcdir/testdata/greppatN4 testNinputgrep >>testtrygrep
|
|
|
|
printf "%c--------------------------- Test N5 ------------------------------\r\n" - >>testtrygrep
|
|
$valgrind $pcre2grep -n --newline=any "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
|
|
|
printf "%c--------------------------- Test N6 ------------------------------\r\n" - >>testtrygrep
|
|
$valgrind $pcre2grep -n --newline=anycrlf "^(abc|def|ghi|jkl)" testNinputgrep >>testtrygrep
|
|
|
|
$cf $srcdir/testdata/grepoutputN testtrygrep
|
|
if [ $? != 0 ] ; then exit 1; fi
|
|
|
|
|
|
# Finally, some tests to exercise code that is not tested above, just to be
|
|
# sure that it runs OK. Doing this improves the coverage statistics. The output
|
|
# is not checked.
|
|
|
|
echo "Testing miscellaneous pcre2grep arguments (unchecked)"
|
|
echo '' >testtrygrep
|
|
checkspecial '-xxxxx' 2
|
|
checkspecial '--help' 0
|
|
checkspecial '--line-buffered --colour=auto abc /dev/null' 1
|
|
|
|
# Clean up local working files
|
|
rm -f testNinputgrep teststderrgrep testtrygrep testtemp1grep testtemp2grep
|
|
|
|
exit 0
|
|
|
|
# End
|