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: script:
- make - make
- make pawncc_tests - make test
- make package - make package
after_failure:
- cat Testing/Temporary/LastTest.log
deploy: deploy:
provider: releases provider: releases
api_key: api_key:

View File

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

View File

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

View File

@ -1,7 +1,7 @@
find_package(PythonInterp 2.7) find_package(PythonInterp 2.7)
if(PYTHONINTERP_FOUND) if(PYTHONINTERP_FOUND)
add_custom_target(pawncc_tests COMMAND add_custom_target(pawncc_tests
COMMAND ${PYTHON_EXECUTABLE} COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/run_tests.py ${CMAKE_CURRENT_SOURCE_DIR}/run_tests.py
-c $<TARGET_FILE:pawncc> -c $<TARGET_FILE:pawncc>
@ -10,6 +10,20 @@ if(PYTHONINTERP_FOUND)
-i ../../../include -i ../../../include
DEPENDS pawncc DEPENDS pawncc
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 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() 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() endif()