2013-12-14 18:47:59 +05:30
|
|
|
# run the unit tests with `make test`
|
2015-01-31 23:51:47 +05:30
|
|
|
find_package(Qt5 COMPONENTS Test Core Network)
|
2013-12-02 15:39:56 +05:30
|
|
|
|
2015-09-05 22:16:57 +05:30
|
|
|
include_directories(../logic ${CMAKE_CURRENT_BINARY_DIR}/../logic)
|
2015-02-09 06:21:14 +05:30
|
|
|
include_directories(../depends/util/include/)
|
2013-12-02 15:39:56 +05:30
|
|
|
|
|
|
|
unset(MultiMC_TESTS)
|
|
|
|
macro(add_unit_test name)
|
|
|
|
unset(srcs)
|
|
|
|
foreach(arg ${testname} ${ARGN})
|
|
|
|
list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/${arg})
|
2014-04-06 23:13:09 +05:30
|
|
|
if(WIN32)
|
2013-12-17 06:39:58 +05:30
|
|
|
list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc)
|
|
|
|
endif()
|
2013-12-02 15:39:56 +05:30
|
|
|
endforeach()
|
|
|
|
add_executable(tst_${name} ${srcs})
|
2015-01-31 23:51:47 +05:30
|
|
|
qt5_use_modules(tst_${name} Test Core Network)
|
2015-02-09 06:21:14 +05:30
|
|
|
target_link_libraries(tst_${name} MultiMC_logic)
|
2013-12-02 15:39:56 +05:30
|
|
|
list(APPEND MultiMC_TESTS tst_${name})
|
2013-12-14 18:47:59 +05:30
|
|
|
add_test(NAME ${name} COMMAND tst_${name})
|
2013-12-02 15:39:56 +05:30
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Tests START #
|
|
|
|
|
2013-12-14 18:47:59 +05:30
|
|
|
add_unit_test(pathutils tst_pathutils.cpp)
|
2014-07-16 05:33:52 +05:30
|
|
|
add_unit_test(gradlespecifier tst_gradlespecifier.cpp)
|
2013-12-14 18:47:59 +05:30
|
|
|
add_unit_test(userutils tst_userutils.cpp)
|
2014-09-06 21:46:56 +05:30
|
|
|
add_unit_test(modutils tst_modutils.cpp)
|
2014-03-30 01:46:54 +05:30
|
|
|
add_unit_test(inifile tst_inifile.cpp)
|
2013-12-14 19:23:18 +05:30
|
|
|
add_unit_test(UpdateChecker tst_UpdateChecker.cpp)
|
2015-02-08 22:26:14 +05:30
|
|
|
add_unit_test(DownloadTask tst_DownloadTask.cpp)
|
2015-08-18 05:55:24 +05:30
|
|
|
add_unit_test(filematchers tst_filematchers.cpp)
|
2015-06-06 16:00:49 +05:30
|
|
|
add_unit_test(Resource tst_Resource.cpp)
|
2015-09-14 05:55:47 +05:30
|
|
|
add_unit_test(GZip tst_GZip.cpp)
|
2013-12-02 15:39:56 +05:30
|
|
|
|
|
|
|
# Tests END #
|
2015-01-31 23:51:47 +05:30
|
|
|
|
2013-12-02 15:39:56 +05:30
|
|
|
set(COVERAGE_SOURCE_DIRS
|
2014-04-09 19:11:49 +05:30
|
|
|
${MMC_SRC}/logic/*
|
|
|
|
${MMC_SRC}/logic/auth/*
|
|
|
|
${MMC_SRC}/logic/auth/flows/*
|
|
|
|
${MMC_SRC}/logic/lists/*
|
|
|
|
${MMC_SRC}/logic/net/*
|
|
|
|
${MMC_SRC}/logic/tasks/*
|
2015-02-09 06:21:14 +05:30
|
|
|
${MMC_SRC}/application/*
|
|
|
|
${MMC_SRC}/application/dialogs/*
|
|
|
|
${MMC_SRC}/application/widgets/*
|
2014-04-09 19:11:49 +05:30
|
|
|
${MMC_SRC}/depends/settings/include/*
|
|
|
|
${MMC_SRC}/depends/settings/src/*
|
|
|
|
${MMC_SRC}/depends/util/include/*
|
|
|
|
${MMC_SRC}/depends/util/src/*
|
2013-12-02 15:39:56 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
if(MultiMC_CODE_COVERAGE)
|
|
|
|
unset(MultiMC_RUN_TESTS)
|
|
|
|
unset(MultiMC_TEST_COVERAGE_FILES)
|
|
|
|
|
|
|
|
foreach(test ${MultiMC_TESTS})
|
|
|
|
add_custom_target(MultiMC_RUN_TEST_${test}
|
2014-04-09 19:11:49 +05:30
|
|
|
COMMAND lcov -d ${CMAKE_CURRENT_BINARY_DIR} -z -q # clean test
|
2013-12-02 15:39:56 +05:30
|
|
|
&& lcov -d ${MMC_BIN} -z -q # clean common
|
|
|
|
&& lcov -d ${MMC_BIN}/depends/settings/CMakeFiles/libSettings.dir -z -q # clean settings
|
|
|
|
&& lcov -d ${MMC_BIN}/depends/utils/CMakeFiles/libUtil.dir -z -q # clean utils
|
|
|
|
&& ${MMC_BIN}/${test} -o coverage_${test}.out,xml # run test
|
|
|
|
&& lcov -q --checksum -b ${MMC_SRC} -d ${CMAKE_CURRENT_BINARY_DIR} -c -o coverage_${test}.info # generate for test
|
|
|
|
&& lcov -q --checksum -b ${MMC_SRC} -d ${MMC_BIN} -c -o coverage_common.info # generate for common
|
|
|
|
&& lcov -q --checksum -b ${MMC_SRC} -d ${MMC_BIN}/depends/settings/CMakeFiles/libSettings.dir -c -o coverage_settings.info # generate for settings
|
|
|
|
&& lcov -q --checksum -b ${MMC_SRC} -d ${MMC_BIN}/depends/util/CMakeFiles/libUtil.dir -c -o coverage_utils.info # generate for utils
|
|
|
|
&& lcov -q --checksum -b ${MMC_SRC} -d .
|
|
|
|
-a coverage_${test}.info -a coverage_common.info -a coverage_settings.info -a coverage_utils.info
|
|
|
|
-o coverage_${test}-combined.info # combine test and common
|
|
|
|
&& lcov -q --checksum -b ${MMC_SRC} --list-full-path --extract coverage_${test}-combined.info ${COVERAGE_SOURCE_DIRS} -o coverage_${test}-stripped.info # strip
|
2014-04-09 19:11:49 +05:30
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
VERBATIM
|
|
|
|
DEPENDS ${test}
|
|
|
|
COMMENT "Running ${test}..."
|
2013-12-02 15:39:56 +05:30
|
|
|
)
|
|
|
|
list(APPEND MultiMC_TEST_COVERAGE_FILES coverage_${test}-stripped.info)
|
|
|
|
list(APPEND MultiMC_RUN_TESTS MultiMC_RUN_TEST_${test})
|
|
|
|
endforeach(test)
|
|
|
|
|
|
|
|
add_custom_target(MultiMC_GENERATE_COVERAGE
|
2014-04-09 19:11:49 +05:30
|
|
|
DEPENDS ${MultiMC_RUN_TESTS}
|
|
|
|
COMMENT "Generating coverage files..."
|
2013-12-02 15:39:56 +05:30
|
|
|
)
|
|
|
|
add_custom_target(MultiMC_GENERATE_COVERAGE_HTML
|
2014-04-09 19:11:49 +05:30
|
|
|
COMMAND genhtml -t "MultiMC 5 Test Coverage" --num-spaces 4 --demangle-cpp --legend -o ${MMC_SRC}/html/coverage ${MultiMC_TEST_COVERAGE_FILES}
|
|
|
|
DEPENDS MultiMC_GENERATE_COVERAGE
|
|
|
|
COMMENT "Generating test coverage html..."
|
2013-12-02 15:39:56 +05:30
|
|
|
)
|
|
|
|
add_custom_target(MultiMC_RUN_TESTS DEPENDS MultiMC_GENERATE_COVERAGE_HTML)
|
|
|
|
endif(MultiMC_CODE_COVERAGE)
|
|
|
|
|
2014-01-06 03:54:05 +05:30
|
|
|
set(MultiMC_TEST_DATA_PATH "${CMAKE_CURRENT_BINARY_DIR}/data")
|
2015-01-31 23:51:47 +05:30
|
|
|
message("${CMAKE_CURRENT_BINARY_DIR}/data")
|
2014-01-06 03:54:05 +05:30
|
|
|
if(UNIX)
|
|
|
|
# on unix we get the third / from the filename
|
|
|
|
set(MultiMC_TEST_DATA_PATH "file://${MultiMC_TEST_DATA_PATH}")
|
|
|
|
else()
|
|
|
|
# we don't on windows, so we have to add it ourselves
|
|
|
|
set(MultiMC_TEST_DATA_PATH "file:///${MultiMC_TEST_DATA_PATH}")
|
|
|
|
endif()
|
|
|
|
file(GLOB data_files "data/*")
|
|
|
|
foreach(data_file ${data_files})
|
|
|
|
get_filename_component(filename ${data_file} NAME)
|
2014-01-19 03:21:04 +05:30
|
|
|
configure_file(
|
|
|
|
${data_file}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/data/${filename}
|
|
|
|
@ONLY
|
|
|
|
NEWLINE_STYLE LF
|
|
|
|
)
|
2014-01-06 03:54:05 +05:30
|
|
|
endforeach()
|
2013-12-17 06:39:58 +05:30
|
|
|
|
2014-01-06 03:54:05 +05:30
|
|
|
configure_file(test_config.h.in test_config.h @ONLY)
|