diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-10-07 11:41:05 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2011-10-07 11:41:05 +0000 |
commit | d6256d8964de10e4494cf24f2516064db079d054 (patch) | |
tree | f0f55dfd35e06d5c95ce331ef19b6edecfee8b8a | |
parent | 107b71431b03b819c3805298baea30a2a265e655 (diff) | |
download | pcre-d6256d8964de10e4494cf24f2516064db079d054.tar.gz |
Another improved RunTest.bat and also CMakeLists.txt provided by Sheri P.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@719 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | CMakeLists.txt | 165 | ||||
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | RunTest.bat | 117 |
3 files changed, 219 insertions, 67 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fbb826..2e5adb9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,10 +41,22 @@ # 2011-08-22 PH added PCRE_SUPPORT_JIT # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT +# 2011-10-04 Sheri added support for including coff data in windows shared libraries +# compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in +# the source dir by the user prior to building +# 2011-10-04 Sheri changed various add_test's to use exes' location built instead +# of DEBUG location only (likely only matters in MSVC) +# 2011-10-04 Sheri added scripts to provide needed variables to RunTest and +# RunGrepTest (used for UNIX and Msys) +# 2011-10-04 Sheri added scripts to provide needed variables and to execute +# RunTest.bat in Win32 (for effortless testing with "make test") +# 2011-10-04 Sheri Increased minimum required cmake version PROJECT(PCRE C CXX) -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6) +# Increased minimum to 2.8.0 to support newer add_test features + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake @@ -344,10 +356,34 @@ SET(PCRE_SOURCES pcre_xclass.c ) + SET(PCREPOSIX_HEADERS pcreposix.h) SET(PCREPOSIX_SOURCES pcreposix.c) +IF(MINGW AND NOT PCRE_STATIC) +IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc) +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o +PRE-LINK +COMMAND windres ARGS pcre.rc pcre.o +WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +COMMENT Using pcre coff info in mingw build) +SET(PCRE_SOURCES + ${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o +) +ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc) +IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc) +ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o +PRE-LINK +COMMAND windres ARGS pcreposix.rc pcreposix.o +WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +COMMENT Using pcreposix coff info in mingw build) +SET(PCREPOSIX_SOURCES + ${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o +) +ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc) +ENDIF(MINGW AND NOT PCRE_STATIC) + SET(PCRECPP_HEADERS pcrecpp.h pcre_scanner.h @@ -433,12 +469,11 @@ ENDIF(PCRE_BUILD_PCRECPP) # SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC") # ENDIF(NOT BUILD_SHARED_LIBS) -IF(PCRE_BUILD_PCREGREP) +IF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS) ADD_EXECUTABLE(pcregrep pcregrep.c) SET(targets ${targets} pcregrep) TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS}) -ENDIF(PCRE_BUILD_PCREGREP) - +ENDIF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS) # Testing IF(PCRE_BUILD_TESTS) @@ -473,59 +508,109 @@ IF(PCRE_BUILD_TESTS) TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp) ENDIF(PCRE_BUILD_PCRECPP) + # exes in Debug location tested by the RunTest shell script + # via "make test" GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION) GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION) - # Write out a CTest configuration file that sets some needed environment - # variables for the test scripts. +# ================================================= + # Write out a CTest configuration file # FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest "# This is a generated file. - SET(ENV{srcdir} ${PROJECT_SOURCE_DIR}) - SET(ENV{pcregrep} ${PCREGREP_EXE}) - SET(ENV{pcretest} ${PCRETEST_EXE}) - ") +MESSAGE(\"When testing is complete, review test output in the +${PROJECT_BINARY_DIR}/Testing/Temporary folder.\") +MESSAGE(\"\") +") + + FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh + "#! /bin/sh +# This is a generated file. +srcdir=${PROJECT_SOURCE_DIR} +pcregrep=${PCREGREP_EXE} +pcretest=${PCRETEST_EXE} +source ${PROJECT_SOURCE_DIR}/RunTest +if test \"$?\" != \"0\"; then exit 1; fi +# End +") + + FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh + "#! /bin/sh +# This is a generated file. +srcdir=${PROJECT_SOURCE_DIR} +pcregrep=${PCREGREP_EXE} +pcretest=${PCRETEST_EXE} +source ${PROJECT_SOURCE_DIR}/RunGrepTest +if test \"$?\" != \"0\"; then exit 1; fi +# End +") IF(UNIX) - ADD_TEST(pcre_test ${PROJECT_SOURCE_DIR}/RunTest) - ADD_TEST(pcre_grep_test ${PROJECT_SOURCE_DIR}/RunGrepTest) + ADD_TEST(pcre_test ${PROJECT_BINARY_DIR}/pcre_test.sh) + ADD_TEST(pcre_grep_test ${PROJECT_BINARY_DIR}/pcre_grep_test.sh) ENDIF(UNIX) IF(WIN32) - IF("$ENV{OSTYPE}" STREQUAL "msys") - ADD_TEST(pcre_test sh ${PROJECT_SOURCE_DIR}/RunTest) - ADD_TEST(pcre_grep_test sh ${PROJECT_SOURCE_DIR}/RunGrepTest) - ELSE("$ENV{OSTYPE}" STREQUAL "msys") - # ADD_TEST(pcre_test cmd /C ${PROJECT_SOURCE_DIR}/RunTest.bat) - ADD_TEST(pcre_test ${PROJECT_SOURCE_DIR}/RunTest.bat) - ENDIF("$ENV{OSTYPE}" STREQUAL "msys") - ENDIF(WIN32) + # Provide environment for executing the bat file version of RunTest + string(REPLACE "/" "\\" winsrc "${PROJECT_SOURCE_DIR}") + + FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.txt + "\@REM This is a generated file. +\@Echo off +setlocal +SET\ srcdir=\${srcdir} +SET\ pcretest=\${pcretest} +SET\ pcregrep=\${pcregrep} +call \"\${srcdir}\\RunTest.Bat\" +if errorlevel 1 exit /b 1 +echo RunTest.bat tests successfully completed +") + + FILE(WRITE ${PROJECT_BINARY_DIR}/BatDriver.cmake + "# This is a generated file. +# this script is run with arguments via the cmake command in add_test(NAME pcre_test_bat) +# BatDriver feeds the actual location of pcretest.exe and pcregrep.exe +FILE(TO_NATIVE_PATH \${pcretestx} pcretest) +FILE(TO_NATIVE_PATH \${pcregrepx} pcregrep) +FILE(TO_NATIVE_PATH \${srcdirx} srcdir) +configure_file(\"\${bindirx}/pcre_test.txt\" \"\${bindirx}/pcre_test.bat\") +# MESSAGE(\"cmake\ variable\ pcretest\ is\ \${pcretest}\") +# MESSAGE(\"cmake\ variable\ pcregrep\ is\ \${pcregrep}\") +# STRING(REPLACE \" \" \"\\ \" bindir \${bindirx}) +MESSAGE(\"COMMAND pcre_test.bat \") +EXECUTE_PROCESS(COMMAND pcre_test.bat +WORKING_DIRECTORY . +OUTPUT_VARIABLE batoutput) +MESSAGE(\"OUTPUT: \${batoutput}\") +") + + ADD_TEST(NAME pcre_test_bat + COMMAND ${CMAKE_COMMAND} -D bindirx=${PROJECT_BINARY_DIR} -D srcdirx=${PROJECT_SOURCE_DIR} -D pcretestx=$<TARGET_FILE:pcretest> -D pcregrepx=$<TARGET_FILE:pcregrep> -P "${PROJECT_BINARY_DIR}/BatDriver.cmake") + SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES + PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed") - IF(PCRE_SUPPORT_JIT) - GET_TARGET_PROPERTY(PCRE_JIT_TEST_EXE - pcre_jit_test - DEBUG_LOCATION) - ENDIF(PCRE_SUPPORT_JIT) + IF("$ENV{OSTYPE}" STREQUAL "msys") + # Both the sh and bat file versions of RunTest are run if make test is used + # in msys - GET_TARGET_PROPERTY(PCRECPP_UNITTEST_EXE - pcrecpp_unittest - DEBUG_LOCATION) + ADD_TEST(pcre_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh) + ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh) - GET_TARGET_PROPERTY(PCRE_SCANNER_UNITTEST_EXE - pcre_scanner_unittest - DEBUG_LOCATION) + ENDIF("$ENV{OSTYPE}" STREQUAL "msys") + ENDIF(WIN32) - GET_TARGET_PROPERTY(PCRE_STRINGPIECE_UNITTEST_EXE - pcre_stringpiece_unittest - DEBUG_LOCATION) + # Changed to accommodate testing whichever location was just built IF(PCRE_SUPPORT_JIT) - ADD_TEST(pcre_jit_test ${PCRE_JIT_TEST_EXE}) + ADD_TEST(pcre_jit_test pcre_jit_test) ENDIF(PCRE_SUPPORT_JIT) - ADD_TEST(pcrecpp_test ${PCRECPP_UNITTEST_EXE}) - ADD_TEST(pcre_scanner_test ${PCRE_SCANNER_UNITTEST_EXE}) - ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE}) + IF(PCRE_BUILD_PCRECPP) + ADD_TEST(pcrecpp_test pcrecpp_unittest) + ADD_TEST(pcre_scanner_test pcre_scanner_unittest) + ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest) + + ENDIF(PCRE_BUILD_PCRECPP) ENDIF(PCRE_BUILD_TESTS) # Installation @@ -555,7 +640,6 @@ ELSE(PCRE_BUILD_PCRECPP) SET(man3 ${man3_new}) ENDIF(PCRE_BUILD_PCRECPP) - INSTALL(FILES ${man1} DESTINATION man/man1) INSTALL(FILES ${man3} DESTINATION man/man3) INSTALL(FILES ${html} DESTINATION share/doc/pcre/html) @@ -603,7 +687,8 @@ IF(PCRE_SHOW_REPORT) MESSAGE(STATUS " Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}") MESSAGE(STATUS " Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}") MESSAGE(STATUS " Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}") - MESSAGE(STATUS " Build tests (implies pcretest) .. : ${PCRE_BUILD_TESTS}") + MESSAGE(STATUS " Build tests (implies pcretest .. : ${PCRE_BUILD_TESTS}") + MESSAGE(STATUS " and pcregrep)") IF(ZLIB_FOUND) MESSAGE(STATUS " Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}") ELSE(ZLIB_FOUND) @@ -54,8 +54,8 @@ Version 8.20 23-Sep-2011 8. If (*THEN) was present in the first (true) branch of a conditional group, it was not handled as intended. [But see 16 below.] -9. Replaced RunTest.bat with the much improved version provided by Sheri - Pierce. +9. Replaced RunTest.bat and CMakeLists.txt with improved versions provided by + Sheri Pierce. 10. A pathological pattern such as /(*ACCEPT)a/ was miscompiled, thinking that the first byte in a match must be "a". diff --git a/RunTest.bat b/RunTest.bat index d937a6d..5db979f 100644 --- a/RunTest.bat +++ b/RunTest.bat @@ -1,7 +1,7 @@ @echo off
@rem This file must use CRLF linebreaks to function properly
-@rem and user must have external findstr command
-@rem This file was contributed by Ralf Junker, and touched up by
+@rem and requires both pcretest and pcregrep
+@rem This file was originally contributed by Ralf Junker, and touched up by
@rem Daniel Richard G. Tests 10-12 added by Philip H.
@rem Philip H also changed test 3 to use "wintest" files.
@rem
@@ -17,33 +17,51 @@ @rem 10 requires ucp and link size 2
@rem 14 requires presense of jit support
@rem 15 requires absence of jit support
-
@rem Sheri P also added override tests for study and jit testing
-@rem Output is written to newly created subfolders named testout testoutstudy and testoutjit.
-@rem Current dir should be the build dir. The testdata folder should exist in the current dir or in ..
-@rem Copy RunTest.bat to the build dir manually if necessary.
-@rem
setlocal enabledelayedexpansion
-
-if exist testdata set srcdir=.
-if [%srcdir%]==[] set srcdir=..
-if NOT exist %srcdir%\testdata (
-echo distribution testdata folder not found.
+if [%srcdir%]==[] (
+if exist testdata\ set srcdir=.)
+if [%srcdir%]==[] (
+if exist ..\testdata\ set srcdir=..)
+if [%srcdir%]==[] (
+if exist ..\..\testdata\ set srcdir=..\..)
+if NOT exist "%srcdir%\testdata\" (
+Error: echo distribution testdata folder not found.
+call :conferror
exit /b 1
goto :eof
)
-if [%pcretest%]==[] set pcretest=pcretest
-%pcretest% -C |findstr /C:"No UTF-8 support" >NUL
+if "%pcregrep%"=="" set pcregrep=.\pcregrep.exe
+if "%pcretest%"=="" set pcretest=.\pcretest.exe
+
+echo source dir is %srcdir%
+echo pcretest=%pcretest%
+echo pcregrep=%pcregrep%
+
+if NOT exist "%pcregrep%" (
+echo Error: "%pcregrep%" not found.
+echo.
+call :conferror
+exit /b 1
+)
+
+if NOT exist "%pcretest%" (
+echo Error: "%pcretest%" not found.
+echo.
+call :conferror
+exit /b 1
+)
+
+"%pcretest%" -C|"%pcregrep%" --no-jit "No UTF-8 support">NUL
set utf8=%ERRORLEVEL%
-%pcretest% -C |findstr /C:"No Unicode properties support" >NUL
+"%pcretest%" -C|"%pcregrep%" --no-jit "No Unicode properties support">NUL
set ucp=%ERRORLEVEL%
-%pcretest% -C |findstr /C:"No just-in-time compiler support" >NUL
+"%pcretest%" -C|"%pcregrep%" --no-jit "No just-in-time compiler support">NUL
set jit=%ERRORLEVEL%
-%pcretest% -C |findstr /C:"Internal link size = 2" >NUL
+"%pcretest%" -C|"%pcregrep%" --no-jit "Internal link size = 2">NUL
set link2=%ERRORLEVEL%
-
set ucpandlink2=0
if %ucp% EQU 1 (
if %link2% EQU 0 set ucpandlink2=1
@@ -83,6 +101,8 @@ for %%a in (%*) do ( exit /b 1
)
)
+set failed="no"
+
if "%all%" == "yes" (
set do1=yes
set do2=yes
@@ -101,6 +121,9 @@ if "%all%" == "yes" ( set do15=yes
)
+@echo RunTest.bat's pcretest output is written to newly created subfolders named
+@echo testout, testoutstudy and testoutjit.
+@echo.
if "%do1%" == "yes" call :do1
if "%do2%" == "yes" call :do2
if "%do3%" == "yes" call :do3
@@ -116,6 +139,11 @@ if "%do12%" == "yes" call :do12 if "%do13%" == "yes" call :do13
if "%do14%" == "yes" call :do14
if "%do15%" == "yes" call :do15
+if %failed% == "yes" (
+echo In above output, one or more of the various tests failed!
+exit /b 1
+)
+echo All OK
goto :eof
:runsub
@@ -149,22 +177,39 @@ if exist %srcdir%\testdata\win%testinput% ( set testoutput=wintestoutput%1
)
-echo.
echo Test %1: %3
-%pcretest% %4 %5 %6 %7 %8 %9 %srcdir%\testdata\%testinput%>%2\%testoutput%
+"%pcretest%" %4 %5 %6 %7 %8 %9 "%srcdir%\testdata\%testinput%">%2\%testoutput%
if errorlevel 1 (
- echo Test %1: pcretest failed!
+ echo. failed executing command-line:
+ echo. "%pcretest%" %4 %5 %6 %7 %8 %9 "%srcdir%\testdata\%testinput%"^>%2\%testoutput%
+ set failed="yes"
goto :eof
)
-fc /n %srcdir%\testdata\%testoutput% %2\%testoutput%
+fc /n "%srcdir%\testdata\%testoutput%" "%2\%testoutput%">NUL
if errorlevel 1 (
- echo Test %1: file compare failed!
+ echo. failed comparison: fc /n "%srcdir%\testdata\%testoutput%" "%2\%testoutput%"
+ set failed="yes"
+ if [%1]==[2] (
+ echo.
+ echo ** Test 2 requires a lot of stack. PCRE can be configured to
+ echo ** use heap for recursion. Otherwise, to pass Test 2
+ echo ** you generally need to allocate 8 mb stack to PCRE.
+ echo ** See the 'pcrestack' page for a discussion of PCRE's
+ echo ** stack usage.
+ echo.
+)
+ if [%1]==[3] (
+ echo.
+ echo ** Test 3 failure usually means french locale is not
+ echo ** available on the system, rather than a bug or problem with PCRE.
+ echo.
+)
+
goto :eof
)
-echo Test %1: Passed.
-echo.
+echo. Passed.
goto :eof
:do1
@@ -295,3 +340,25 @@ goto :eof call :runsub 15 testout "JIT-specific features - no JIT" -q
call :runsub 15 testoutstudy "Test with Study Override" -q -s
goto :eof
+
+:conferror
+@echo Configuration error.
+@echo.
+@echo If configured with cmake and executed via "make test" or the MSVC "RUN_TESTS"
+@echo project, pcre_test.bat defines variables and automatically calls RunTest.bat.
+@echo For manual testing of all available features, after configuring with cmake
+@echo and building, you can run the built pcre_test.bat. For best results with
+@echo cmake builds and tests avoid directories with full path names that include
+@echo spaces for source or build.
+@echo.
+@echo Otherwise, if the build dir is in a subdir of the source dir, testdata needed
+@echo for input and verification should be found automatically when (from the
+@echo location of the the built exes) you call RunTest.bat. By default RunTest.bat
+@echo runs all tests compatible with the linked pcre library but it can be given
+@echo a test number as an argument.
+@echo.
+@echo If the build dir is not under the source dir you can either copy your exes
+@echo to the source folder or copy RunTest.bat and the testdata folder to the
+@echo location of your built exes and then run RunTest.bat.
+@echo.
+goto :eof
|