Skip to content

Commit 725a37d

Browse files
committed
All tests run by CMake
1 parent 0ace0fa commit 725a37d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ add_executable(clock_example example/main-clock.cpp)
2525
add_executable(count_fives_example example/main-count-fives.cpp)
2626

2727
# Building time tests (/compile-test)
28-
# These invoke "cmake --build ..."
2928
# Tests that should compile
3029
FILE(GLOB TestCompileSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test-compile/compiles/*_test.cpp)
3130
foreach(testCompSrc ${TestCompileSources})
@@ -40,3 +39,16 @@ foreach(testCompSrc ${TestCompileSources})
4039
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
4140
endforeach(testCompSrc)
4241

42+
# Tests that should fail compilation
43+
FILE(GLOB TestCompileFailSources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} test-compile/compile-fails/*_test.cpp)
44+
foreach(testCmpFailSrc ${TestCompileFailSources})
45+
get_filename_component(testCmpFailName ${testCmpFailSrc} NAME_WE)
46+
add_executable(${testCmpFailName} ${testCmpFailSrc})
47+
set_target_properties(${testCmpFailName} PROPERTIES
48+
EXCLUDE_FROM_ALL TRUE
49+
EXCLUDE_FROM_DEFAULT_BUILD TRUE)
50+
add_test(NAME ${testCmpFailName}
51+
COMMAND ${CMAKE_COMMAND} --build . --target ${testCmpFailName}
52+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
53+
set_tests_properties(${testCmpFailName} PROPERTIES WILL_FAIL TRUE)
54+
endforeach(testCmpFailSrc)

0 commit comments

Comments
 (0)