Skip to content

Commit

Permalink
Rewrite re2c test runner in Python
Browse files Browse the repository at this point in the history
This pull request introduces a completely rewritten test runner
in Python.

The main goals of this change:

- Provide a OS-independent way to run tests (at least using CMake)
- Getting rid of dependence on Unix utilities in tests
  (grep, cat, tr, etc.)
- Flexibility
- Ease of maintenance
  • Loading branch information
sergeyklay authored and skvadrik committed Jun 19, 2021
1 parent cf57858 commit 9c99811
Show file tree
Hide file tree
Showing 7 changed files with 680 additions and 332 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ jobs:
- name: Full Build
run: |
find src -name '*.re' | xargs touch
cmake --build ${{ matrix.build-dir }} --config ${{ matrix.build-type }} --verbose
cmake --build ${{ matrix.build-dir }} --config ${{ matrix.build-type }}
- name: Test
if: startsWith(runner.os, 'Windows') == false
Expand All @@ -254,5 +254,5 @@ jobs:
# skeleton tests (if enabled)
if [[ "x${{ matrix.skeleton }}" == "xtrue" ]] ; then
./run_tests.sh --skeleton
python run_tests.py --skeleton
fi
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,9 @@ set(top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
configure_file(doc/manpage.rst.in doc/manpage.rst @ONLY)
configure_file(doc/help.rst.in doc/help.rst @ONLY)

configure_file(run_tests.sh.in run_tests.sh @ONLY)
set(RE2C_RUN_TESTS "${CMAKE_CURRENT_BINARY_DIR}/run_tests.sh")
if(CMAKE_HOST_UNIX)
execute_process(COMMAND chmod +x "${RE2C_RUN_TESTS}")
endif()
find_package(Python3 REQUIRED COMPONENTS Interpreter)
configure_file(run_tests.py.in run_tests.py @ONLY)
set(RE2C_RUN_TESTS "${CMAKE_CURRENT_BINARY_DIR}/run_tests.py")

ac_config_headers("config.h")

Expand Down Expand Up @@ -326,19 +324,19 @@ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
add_custom_target(tests
DEPENDS "${RE2C_RUN_TESTS}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND "${RE2C_RUN_TESTS}"
COMMAND "${Python3_EXECUTABLE}" "${RE2C_RUN_TESTS}"
)
add_dependencies(tests re2c)
add_custom_target(vtests
DEPENDS "${RE2C_RUN_TESTS}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND "${RE2C_RUN_TESTS}" --valgrind
COMMAND "${Python3_EXECUTABLE}" "${RE2C_RUN_TESTS}" --valgrind
)
add_dependencies(vtests re2c)
add_custom_target(wtests
DEPENDS "${RE2C_RUN_TESTS}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
COMMAND "${RE2C_RUN_TESTS}" --wine -j1
COMMAND "${Python3_EXECUTABLE}" "${RE2C_RUN_TESTS}" --wine -j1
)
add_dependencies(wtests re2c)
add_executable(re2c_test_range
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ endif
all-local: docs $(re2c_BOOT_PARSER)

# tests
re2c_TESTSUITE = run_tests.sh
re2c_TESTSUITE = run_tests.py
.PHONY: tests
tests: all $(re2c_TESTSUITE)
$(top_builddir)/$(re2c_TESTSUITE)
Expand Down
2 changes: 1 addition & 1 deletion build/__alltest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ done
# skeleton
build/__build.sh \
&& cd __build \
&& ./run_tests.sh --skeleton \
&& ./run_tests.py --skeleton \
&& cd .. \
|| { cd .. ; echo "*** skeleton failed ***"; exit 1; }

Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ AC_CONFIG_FILES([\
doc/manpage.rst \
doc/help.rst \
])
AC_CONFIG_FILES([run_tests.sh],
[chmod +x run_tests.sh])
AC_CONFIG_FILES([run_tests.py],
[chmod +x run_tests.py])
AC_CONFIG_FILES([benchmarks/submatch_dfa_aot/run.py],
[chmod +x benchmarks/submatch_dfa_aot/run.py])
AC_CONFIG_FILES([benchmarks/submatch_java/run.py],
Expand Down
Loading

0 comments on commit 9c99811

Please sign in to comment.