Skip to content

Commit

Permalink
Split tests into different targets
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed May 8, 2012
1 parent 965bd9c commit 7a974bb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
4 changes: 4 additions & 0 deletions tests/CMakeLists.txt
@@ -0,0 +1,4 @@
include(lastfm_add_test.cmake)

lastfm_add_test(UrlBuilder)
lastfm_add_test(Track)
16 changes: 16 additions & 0 deletions 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()
16 changes: 6 additions & 10 deletions tests/main.cpp → 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 <QtCore>
#include <QtTest>
#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;
}

0 comments on commit 7a974bb

Please sign in to comment.