Only enable gui in tests that need it.
This commit is contained in:
parent
2b812a76fd
commit
1cad21a3e0
@ -55,7 +55,7 @@ add_custom_target(build_tests
|
|||||||
add_dependencies(test build_tests)
|
add_dependencies(test build_tests)
|
||||||
|
|
||||||
# Given a file foo_test.cpp, creates a target foo_test and adds it to the test target.
|
# Given a file foo_test.cpp, creates a target foo_test and adds it to the test target.
|
||||||
macro(add_test_file test_source)
|
macro(add_test_file test_source gui_required)
|
||||||
get_filename_component(TEST_NAME ${test_source} NAME_WE)
|
get_filename_component(TEST_NAME ${test_source} NAME_WE)
|
||||||
add_executable(${TEST_NAME}
|
add_executable(${TEST_NAME}
|
||||||
EXCLUDE_FROM_ALL
|
EXCLUDE_FROM_ALL
|
||||||
@ -63,16 +63,22 @@ macro(add_test_file test_source)
|
|||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(${TEST_NAME} gmock clementine_lib test_utils)
|
target_link_libraries(${TEST_NAME} gmock clementine_lib test_utils)
|
||||||
|
set(GUI_REQUIRED ${gui_required})
|
||||||
|
if (GUI_REQUIRED)
|
||||||
|
set_target_properties(${TEST_NAME} PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS GUI)
|
||||||
|
endif (GUI_REQUIRED)
|
||||||
|
|
||||||
add_custom_command(TARGET test POST_BUILD
|
add_custom_command(TARGET test POST_BUILD
|
||||||
COMMAND ./${TEST_NAME})
|
COMMAND ./${TEST_NAME})
|
||||||
add_dependencies(build_tests ${TEST_NAME})
|
add_dependencies(build_tests ${TEST_NAME})
|
||||||
endmacro (add_test_file)
|
endmacro (add_test_file)
|
||||||
|
|
||||||
|
|
||||||
add_test_file(m3uparser_test.cpp)
|
add_test_file(m3uparser_test.cpp false)
|
||||||
add_test_file(song_test.cpp)
|
add_test_file(song_test.cpp false)
|
||||||
add_test_file(librarybackend_test.cpp)
|
add_test_file(librarybackend_test.cpp false)
|
||||||
add_test_file(albumcoverfetcher_test.cpp)
|
add_test_file(albumcoverfetcher_test.cpp false)
|
||||||
add_test_file(xspfparser_test.cpp)
|
add_test_file(xspfparser_test.cpp false)
|
||||||
add_test_file(library_test.cpp)
|
add_test_file(library_test.cpp false)
|
||||||
add_test_file(albumcovermanager_test.cpp)
|
add_test_file(albumcovermanager_test.cpp true)
|
||||||
|
@ -25,7 +25,11 @@ int main(int argc, char** argv) {
|
|||||||
testing::InitGoogleMock(&argc, argv);
|
testing::InitGoogleMock(&argc, argv);
|
||||||
|
|
||||||
testing::AddGlobalTestEnvironment(new MetatypesEnvironment);
|
testing::AddGlobalTestEnvironment(new MetatypesEnvironment);
|
||||||
|
#ifdef GUI
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
#else
|
||||||
|
QCoreApplication a(argc, argv);
|
||||||
|
#endif
|
||||||
testing::AddGlobalTestEnvironment(new ResourcesEnvironment);
|
testing::AddGlobalTestEnvironment(new ResourcesEnvironment);
|
||||||
|
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user