Add CTest wrappers for tests

With CTest it's much easier to run the tests via command line -
no need to specify path to compiler, etc. Simply run this command
(from the build directory):

ctest -C Debug

or

ctest -C Debug -R pcode.*

to run tests matching a regexp (it will run pcode_test_example in
this case)).

It is still possible to use the run_tests.py script directly.
This commit is contained in:
Zeex 2018-09-02 09:33:03 +06:00
parent 0affc419db
commit 641169e053
4 changed files with 46 additions and 23 deletions

View File

@ -21,9 +21,12 @@ before_script:
script:
- make
- make pawncc_tests
- make test
- make package
after_failure:
- cat Testing/Temporary/LastTest.log
deploy:
provider: releases
api_key:

View File

@ -13,7 +13,10 @@ build_script:
- cmake --build . --config %CONFIGURATION% --target package
test_script:
- cmake --build . --config %CONFIGURATION% --target pawncc_tests
- ctest --build-config %CONFIGURATION%
on_failure:
- type Testing\Temporary\LastTest.log
artifacts:
- path: build/pawnc-*-windows.zip

View File

@ -164,28 +164,31 @@ if(MSVC)
endif()
# Generate targets for running compiler tests
set(PAWNRUNS_SRCS
pawnruns.c
../amx/amx.c
../amx/amx.h
../amx/amxaux.c
../amx/amxaux.h
../amx/amxcons.c
../amx/amxcore.c
)
if(UNIX)
include(CTest)
if(BUILD_TESTING)
set(PAWNRUNS_SRCS
${PAWNRUNS_SRCS}
../linux/getch.c
../linux/getch.h
../linux/binreloc.c
pawnruns.c
../amx/amx.c
../amx/amx.h
../amx/amxaux.c
../amx/amxaux.h
../amx/amxcons.c
../amx/amxcore.c
)
if(UNIX)
set(PAWNRUNS_SRCS
${PAWNRUNS_SRCS}
../linux/getch.c
../linux/getch.h
../linux/binreloc.c
)
endif()
add_executable(pawnruns ${PAWNRUNS_SRCS})
if(UNIX)
target_link_libraries(pawnruns dl)
endif()
add_subdirectory(tests)
endif()
add_executable(pawnruns ${PAWNRUNS_SRCS})
if(UNIX)
target_link_libraries(pawnruns dl)
endif()
add_subdirectory(tests)
# Generate a binary package with CPack
set(CPACK_PACKAGE_NAME pawnc)

View File

@ -1,7 +1,7 @@
find_package(PythonInterp 2.7)
if(PYTHONINTERP_FOUND)
add_custom_target(pawncc_tests COMMAND
add_custom_target(pawncc_tests
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/run_tests.py
-c $<TARGET_FILE:pawncc>
@ -10,6 +10,20 @@ if(PYTHONINTERP_FOUND)
-i ../../../include
DEPENDS pawncc
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
file(GLOB_RECURSE meta_files "*.meta")
foreach(meta_file IN LISTS meta_files)
get_filename_component(test_name ${meta_file} NAME_WE)
add_test(NAME ${test_name}
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/run_tests.py
-c $<TARGET_FILE:pawncc>
-d $<TARGET_FILE:pawndisasm>
-r $<TARGET_FILE:pawnruns>
-i ../../../include
${test_name}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endforeach()
else()
message("Python was not found, you will not be able to run the compiler tests")
message("Python was not found, you will not be able to run the tests")
endif()