Merge pull request #344 from oynqr/build/allow-disabling-tests

This commit is contained in:
Sefa Eyeoglu 2022-03-29 14:42:49 +02:00 committed by GitHub
commit e22d54abd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 50 deletions

View File

@ -6,7 +6,7 @@ if(WIN32)
endif()
project(Launcher)
enable_testing()
include(CTest)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD)
if(IS_IN_SOURCE_BUILD)

View File

@ -5,6 +5,7 @@ set(TEST_RESOURCE_PATH ${CMAKE_CURRENT_LIST_DIR})
message(${TEST_RESOURCE_PATH})
function(add_unit_test name)
if(BUILD_TESTING)
set(options "")
set(oneValueArgs DATA)
set(multiValueArgs SOURCES LIBS)
@ -45,4 +46,5 @@ function(add_unit_test name)
target_include_directories(${name}_test PRIVATE "${TEST_RESOURCE_PATH}/UnitTest/")
add_test(NAME ${name} COMMAND ${name}_test WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
endfunction()

View File

@ -355,21 +355,23 @@ add_unit_test(GradleSpecifier
LIBS Launcher_logic
)
add_executable(PackageManifest
if(BUILD_TESTING)
add_executable(PackageManifest
mojang/PackageManifest_test.cpp
)
target_link_libraries(PackageManifest
)
target_link_libraries(PackageManifest
Launcher_logic
Qt5::Test
)
target_include_directories(PackageManifest
)
target_include_directories(PackageManifest
PRIVATE ../cmake/UnitTest/
)
add_test(
)
add_test(
NAME PackageManifest
COMMAND PackageManifest
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
)
endif()
add_unit_test(MojangVersionFormat
SOURCES minecraft/MojangVersionFormat_test.cpp