Skip to content

Commit

Permalink
Add RunGrepTest.bat to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
NWilson committed Nov 26, 2024
1 parent 9134ae9 commit c94d846
Show file tree
Hide file tree
Showing 12 changed files with 491 additions and 65 deletions.
36 changes: 25 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1014,13 +1014,6 @@ IF(PCRE2_BUILD_TESTS)
TARGET_LINK_LIBRARIES(pcre2_jit_test ${PCRE2_JIT_TEST_LIBS})
ENDIF(PCRE2_SUPPORT_JIT)

# exes in Debug location tested by the RunTest and RunGrepTest shell scripts
# via "make test"

IF(PCRE2_BUILD_PCRE2GREP)
SET(PCRE2GREP_EXE $<TARGET_FILE:pcre2grep>)
ENDIF(PCRE2_BUILD_PCRE2GREP)

# =================================================
# Write out a CTest configuration file
#
Expand Down Expand Up @@ -1082,10 +1075,31 @@ if errorlevel 1 exit /b 1
echo RunTest.bat tests successfully completed
")

ADD_TEST(NAME pcre2_test_bat
COMMAND pcre2_test.bat)
SET_TESTS_PROPERTIES(pcre2_test_bat PROPERTIES
PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
ADD_TEST(NAME pcre2_test_bat
COMMAND pcre2_test.bat)
SET_TESTS_PROPERTIES(pcre2_test_bat PROPERTIES
PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")

IF(PCRE2_BUILD_PCRE2GREP)
FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_grep_test.bat
"\@REM This is a generated file.
\@echo off
setlocal
SET srcdir=\"${winsrc}\"
SET pcre2test=\"${winbin}\\pcre2test.exe\"
if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2test=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2test.exe\"
SET pcre2grep=\"${winbin}\\pcre2grep.exe\"
if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2grep=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2grep.exe\"
call %srcdir%\\RunGrepTest.bat
if errorlevel 1 exit /b 1
echo RunGrepTest.bat tests successfully completed
")

ADD_TEST(NAME pcre2_grep_test_bat
COMMAND pcre2_grep_test.bat)
SET_TESTS_PROPERTIES(pcre2_grep_test_bat PROPERTIES
PASS_REGULAR_EXPRESSION "RunGrepTest\\.bat tests successfully completed")
ENDIF(PCRE2_BUILD_PCRE2GREP)

IF("$ENV{OSTYPE}" STREQUAL "msys")
# Both the sh and bat file versions of RunTest are run if make test is used
Expand Down
47 changes: 30 additions & 17 deletions RunGrepTest
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ echo "---------------------------- Test 35 -----------------------------" >>test
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 36 -----------------------------" >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include='grepinput[^C]' --exclude 'grepinput$' --exclude=grepinput8 --exclude=grepinputM --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include='grepinput[^C]' --exclude 'grepinput$' --exclude='grepinput(Bad)?8' --exclude=grepinputM --exclude=grepinputUN --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 37 -----------------------------" >>testtrygrep
Expand Down Expand Up @@ -530,25 +530,28 @@ echo "---------------------------- Test 95 -----------------------------" >>test
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 96 -----------------------------" >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include-dir=testdata --exclude '^(?!grepinput)' --exclude=grepinput[MC] 'fox' ./test* | sort) >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include-dir=testdata --exclude '^(?!grepinput)' --exclude=grepinput[MCU] 'fox' ./test* | sort) >>testtrygrep
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 97 -----------------------------" >>testtrygrep
echo "grepinput$" >testtemp1grep
echo "grepinput8" >>testtemp1grep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinput --exclude=grepinput[MC] --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
echo "grepinputBad8" >>testtemp1grep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include=grepinput --exclude=grepinput[MCU] --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 $vjs $pcre2grep -L -r --exclude=grepinput3 --exclude=grepinput[MC] --include=grepinput --exclude-from $builddir/testtemp1grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
echo "grepinputBad8" >>testtemp1grep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --exclude=grepinput3 --exclude=grepinput[MCU] --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 $vjs $pcre2grep -L -r --include grepinput --exclude=grepinput[MC] --exclude-from $builddir/testtemp1grep --exclude-from=$builddir/testtemp2grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
echo "grepinputBad8" >>testtemp1grep
(cd $srcdir; $valgrind $vjs $pcre2grep -L -r --include grepinput --exclude=grepinput[MCU] --exclude-from $builddir/testtemp1grep --exclude-from=$builddir/testtemp2grep --exclude-dir='^\.' 'fox' ./testdata | sort) >>testtrygrep
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 100 ------------------------------" >>testtrygrep
Expand Down Expand Up @@ -618,7 +621,7 @@ echo "---------------------------- Test 115 -----------------------------" >>tes
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 116 -----------------------------" >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep --exclude=grepinput[MC] -th 'the' testdata/grepinput*) >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep --exclude=grepinput[MCU] -th 'the' testdata/grepinput*) >>testtrygrep
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 117 -----------------------------" >>testtrygrep
Expand Down Expand Up @@ -763,7 +766,7 @@ echo "---------------------------- Test 140 -----------------------------" >>tes
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 141 -----------------------------" >>testtrygrep
printf "$srcdir/testdata/grepinputv\n-\n" >testtemp1grep
printf "%s/testdata/grepinputv\n-\n" "$srcdir" >testtemp1grep
printf 'This is a line from stdin.' >testtemp2grep
$valgrind $vjs $pcre2grep --file-list testtemp1grep "line from stdin" <testtemp2grep >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
Expand Down Expand Up @@ -848,12 +851,13 @@ if [ $? -ne 0 ]; then
echo "RC=2" >>testtrygrep
else

(cd $srcdir; unset LC_ALL; env LC_CTYPE=locale.bad $valgrind $vjs $pcre2grep abc /dev/null) >>testtrygrep 2>&1
(cd $srcdir; unset LC_ALL; LC_CTYPE=locale.bad $valgrind $vjs $pcre2grep abc /dev/null) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep
fi

echo "---------------------------- Test 151 -----------------------------" >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep --colour=always -e this -e The -e 'The wo' testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 152 -----------------------------" >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep -nA3 --group-separator='++' 'four' ./testdata/grepinputx) >>testtrygrep
Expand Down Expand Up @@ -889,7 +893,7 @@ echo "spaces." >testtemp1grep
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test 159 -----------------------------" >>testtrygrep
printf "spaces.\015\012" >testtemp1grep
printf "spaces.\r\n" >testtemp1grep
(cd $srcdir; $valgrind $vjs $pcre2grep --posix-pattern-file -f$builddir/testtemp1grep ./testdata/grepinputv) >>testtrygrep
echo "RC=$?" >>testtrygrep

Expand Down Expand Up @@ -917,13 +921,11 @@ if [ $utf8 -ne 0 ] ; then
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test U4 ------------------------------" >>testtrygrep
printf 'A\341\200\200\200CD\342\200\200Z\n' >testtemp1grep
(cd $srcdir; $valgrind $vjs $pcre2grep -u -o '....' $builddir/testtemp1grep) >>testtrygrep 2>&1
(cd $srcdir; $valgrind $vjs $pcre2grep -u -o '....' ./testdata/grepinputBad8) >>testtrygrep 2>&1
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test U5 ------------------------------" >>testtrygrep
printf 'A\341\200\200\200CD\342\200\200Z\n' >testtemp1grep
(cd $srcdir; $valgrind $vjs $pcre2grep -U -o '....' $builddir/testtemp1grep) >>testtrygrep
(cd $srcdir; $valgrind $vjs $pcre2grep -U -o '....' ./testdata/grepinputBad8) >>testtrygrep
echo "RC=$?" >>testtrygrep

echo "---------------------------- Test U6 -----------------------------" >>testtrygrep
Expand Down Expand Up @@ -1003,8 +1005,7 @@ if [ $utf8 -ne 0 ] ; then
echo "Testing pcre2grep newline settings with UTF-8 features"

printf '%c--------------------------- Test UN1 ------------------------------\r\n' - >testtrygrep
printf 'abc\341\210\264def\nxyz' >testNinputgrep
$valgrind $vjs $pcre2grep -nau --newline=anycrlf "^(abc|def)" testNinputgrep >>testtrygrep
$valgrind $vjs $pcre2grep -nau --newline=anycrlf "^(abc|def)" $srcdir/testdata/grepinputUN >>testtrygrep
echo "" >>testtrygrep

$cf $srcdir/testdata/grepoutputUN testtrygrep
Expand All @@ -1021,11 +1022,17 @@ fi

if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'callout scripts in patterns are supported'; then
echo "Testing pcre2grep script callouts"
$valgrind $vjs $pcre2grep '(T)(..(.))(?C"/bin/echo|Arg1: [$1] [$2] [$3]|Arg2: $|${1}$| ($4) ($14) ($0)")()' $srcdir/testdata/grepinputv >testtrygrep
echo "--- Test 1 ---" >testtrygrep
$valgrind $vjs $pcre2grep '(T)(..(.))(?C"/bin/echo|Arg1: [$1] [$2] [$3]|Arg2: $|${1}$| ($4) ($14) ($0)")()' $srcdir/testdata/grepinputv >>testtrygrep
echo "--- Test 2 ---" >>testtrygrep
$valgrind $vjs $pcre2grep '(T)(..(.))()()()()()()()(..)(?C"/bin/echo|Arg1: [$11] [${11}]")' $srcdir/testdata/grepinputv >>testtrygrep
echo "--- Test 3 ---" >>testtrygrep
$valgrind $vjs $pcre2grep '(T)(?C"|$0:$1$n")' $srcdir/testdata/grepinputv >>testtrygrep
echo "--- Test 4 ---" >>testtrygrep
$valgrind $vjs $pcre2grep '(T)(?C"/bin/echo|$0:$1$n")' $srcdir/testdata/grepinputv >>testtrygrep
echo "--- Test 5 ---" >>testtrygrep
$valgrind $vjs $pcre2grep '(T)(?C"|$1$n")(*F)' $srcdir/testdata/grepinputv >>testtrygrep
echo "--- Test 6 ---" >>testtrygrep
$valgrind $vjs $pcre2grep -m1 '(T)(?C"|$0:$1:$x{41}$o{101}$n")' $srcdir/testdata/grepinputv >>testtrygrep

if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'Non-fork callout scripts in patterns are supported'; then
Expand All @@ -1041,7 +1048,9 @@ if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'callout scri

if [ $utf8 -ne 0 ] ; then
echo "Testing pcre2grep script callout with UTF-8 features"
$valgrind $vjs $pcre2grep -u '(T)(?C"|$0:$x{a6}$n")' $srcdir/testdata/grepinputv >testtrygrep
echo "--- Test 1 ---" >testtrygrep
$valgrind $vjs $pcre2grep -u '(T)(?C"|$0:$x{a6}$n")' $srcdir/testdata/grepinputv >>testtrygrep
echo "--- Test 2 ---" >>testtrygrep
$valgrind $vjs $pcre2grep -u '(T)(?C"/bin/echo|$0:$x{a6}$n")' $srcdir/testdata/grepinputv >>testtrygrep

if [ $nonfork = 1 ] ; then
Expand All @@ -1050,7 +1059,11 @@ if $valgrind $vjs $pcre2grep --help | $valgrind $vjs $pcre2grep -q 'callout scri
$cf $srcdir/testdata/grepoutputCU testtrygrep
fi
if [ $? != 0 ] ; then exit 1; fi
else
echo "Skipping pcre2grep script callout UTF-8 tests: no UTF-8 support in PCRE2 library"
fi

unset nonfork
else
echo "Script callouts are not supported"
fi
Expand Down
Loading

0 comments on commit c94d846

Please sign in to comment.