From 7a974bbe61dc608ef6421cd895ba128a5f72efde Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Sat, 5 May 2012 01:17:45 +0200 Subject: [PATCH] Split tests into different targets --- tests/CMakeLists.txt | 4 ++++ tests/lastfm_add_test.cmake | 16 ++++++++++++++++ tests/{main.cpp => main.cpp.in} | 16 ++++++---------- 3 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/lastfm_add_test.cmake rename tests/{main.cpp => main.cpp.in} (66%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 000000000..77431afc2 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,4 @@ +include(lastfm_add_test.cmake) + +lastfm_add_test(UrlBuilder) +lastfm_add_test(Track) diff --git a/tests/lastfm_add_test.cmake b/tests/lastfm_add_test.cmake new file mode 100644 index 000000000..9161e6602 --- /dev/null +++ b/tests/lastfm_add_test.cmake @@ -0,0 +1,16 @@ +macro(lastfm_add_test test_class) + include_directories(${QT_INCLUDES} "${PROJECT_SOURCE_DIR}/src" ${CMAKE_CURRENT_BINARY_DIR}) + + set(LASTFM_TEST_CLASS ${test_class}) + configure_file(main.cpp.in Test${LASTFM_TEST_CLASS}.cpp) + configure_file(Test${LASTFM_TEST_CLASS}.h Test${LASTFM_TEST_CLASS}.h) + add_executable(${LASTFM_TEST_CLASS}Test Test${LASTFM_TEST_CLASS}.cpp) + + target_link_libraries(${LASTFM_TEST_CLASS}Test + lastfm + ${QT_QTTEST_LIBRARY} + ${QT_QTCORE_LIBRARY} + ) + + add_test(NAME ${LASTFM_TEST_CLASS}Test COMMAND ${LASTFM_TEST_CLASS}Test) +endmacro() \ No newline at end of file diff --git a/tests/main.cpp b/tests/main.cpp.in similarity index 66% rename from tests/main.cpp rename to tests/main.cpp.in index bbc6f04b1..2a93a6f1d 100644 --- a/tests/main.cpp +++ b/tests/main.cpp.in @@ -1,26 +1,22 @@ /* - This software is in the public domain, furnished "as is", without technical - support, and with no warranty, express or implied, as to its usefulness for + This software is in the public domain, furnished "as is", without technical + support, and with no warranty, express or implied, as to its usefulness for any purpose. */ #include #include -#include "TestTrack.h" -#include "moc_TestTrack.cpp" - -#include "TestUrlBuilder.h" -#include "moc_TestUrlBuilder.cpp" +#include "Test@LASTFM_TEST_CLASS@.h" +#include "moc_Test@LASTFM_TEST_CLASS@.cpp" int main( int argc, char** argv) { QCoreApplication app( argc, argv ); - + #define TEST( Type ) { \ Type o; \ if (int r = QTest::qExec( &o, argc, argv ) != 0) return r; } - TEST( TestTrack ); - TEST( TestUrlBuilder ); + TEST( Test@LASTFM_TEST_CLASS@ ); return 0; }