Build druntime/Phobos unit tests on make test.

This commit is contained in:
David Nadlinger
2012-09-30 03:28:47 +02:00
parent 247da8ea86
commit 23e6720605
3 changed files with 45 additions and 11 deletions

View File

@@ -319,12 +319,19 @@ set_target_properties(${LDMD_EXE} PROPERTIES
# GNU ld.
target_link_libraries(${LDMD_EXE} "${LLVM_LDFLAGS}" ${LLVM_LIBRARIES} "${LLVM_LDFLAGS}")
#
# Test and runtime targets. Note that enable_testing() is order-sensitive!
#
enable_testing()
add_subdirectory(runtime)
if(D_VERSION EQUAL 2)
add_subdirectory(tests/d2)
endif()
#
# Install target.
#
add_subdirectory(runtime)
install(TARGETS ${LDC_EXE} ${LDMD_EXE} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
if(${BUILD_SHARED})
# For now, only install libldc if explicitely building the shared library.
@@ -338,12 +345,3 @@ install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE}_install.rebuild.conf DESTINAT
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install(DIRECTORY bash_completion.d DESTINATION ${CONF_INST_DIR})
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
#
# Test targets.
#
enable_testing()
if(D_VERSION EQUAL 2)
add_subdirectory(tests/d2)
endif()

View File

@@ -398,3 +398,37 @@ if(PHOBOS2_DIR)
endif(PHOBOS2_DIR)
install(FILES ${RUNTIME_DIR}/src/object.di DESTINATION ${INCLUDE_INSTALL_DIR}/ldc)
install(DIRECTORY ${RUNTIME_DIR}/import/ldc DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.di")
#
# Test targets.
#
function(add_tests module_files)
foreach(file ${module_files})
string(REPLACE ${PROJECT_SOURCE_DIR}/ "" stripped ${file})
string(REPLACE ".d" "" stripped ${stripped})
string(REPLACE "/" "_" testroot ${stripped})
function(testcase name flags)
# -singleobj to avoid output file clashes when test are run in parallel.
add_test(NAME ${testroot}_${name}_build
COMMAND ${LDC_LOC}
-of${PROJECT_BINARY_DIR}/${testroot}_${name}
-unittest -d -w -singleobj ${flags}
${file} ${PROJECT_SOURCE_DIR}/emptymain.d
)
add_test(NAME ${testroot}_${name}_run COMMAND ${PROJECT_BINARY_DIR}/${testroot}_${name})
set_tests_properties(${testroot}_${name}_run PROPERTIES DEPENDS ${testroot}_${name}_build)
endfunction()
testcase(debug -g -debug)
testcase(release -O -release)
endforeach()
endfunction()
add_tests("${CORE_D}")
add_tests("${DCRT_D}")
add_tests("${GC_D}")
if(PHOBOS2_DIR)
add_tests("${PHOBOS2_D}")
endif()

2
runtime/emptymain.d Normal file
View File

@@ -0,0 +1,2 @@
// Stub used for building runtime unit tests.
void main() {}