Permalink
Browse files

Make tests work with correct dependencies.

  • Loading branch information...
1 parent a9c3e93 commit f8988f5fbaef9c23656de5af4195597dddc0c1bd @cornelius committed Jun 26, 2010
Showing with 23 additions and 6 deletions.
  1. +22 −2 kxml_compiler/tests/CMakeLists.txt
  2. +1 −2 kxml_compiler/tests/testaccounts.cpp
  3. +0 −2 kxml_compiler/tests/testparser.cpp
@@ -1,3 +1,23 @@
+MACRO (KODE_ADD_LOCAL_XML_PARSER _sources)
+ foreach (_current_file ${ARGN})
+ get_filename_component( _schema ${_current_file} ABSOLUTE )
+ get_filename_component( _basename ${_schema} NAME_WE )
+
+ set( _source_cpp ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp )
+ set( _source_h ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h )
+
+ add_custom_command(
+ OUTPUT ${_source_cpp} ${_source_h}
+ COMMAND "${CMAKE_CURRENT_BINARY_DIR}/../kxml_compiler"
+ ARGS ${_schema}
+ MAIN_DEPENDENCY ${_schema}
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/../kxml_compiler"
+ )
+
+ set( ${_sources} ${${_sources}} ${_source_cpp} )
+ endforeach (_current_file)
+ENDMACRO (KODE_ADD_LOCAL_XML_PARSER)
+
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
########### next target ###############
@@ -31,13 +51,12 @@ target_link_libraries( parserxsdtest kschema ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LI
# next target
set( testaccounts_SRCS testaccounts.cpp )
-kode_add_xml_parser( testaccounts_SRCS account.xml )
+kode_add_local_xml_parser( testaccounts_SRCS account.xml )
kde4_add_executable( testaccounts TEST ${testaccounts_SRCS} )
target_link_libraries( testaccounts ${KDE4_KDECORE_LIBS} ${QT_QTXML_LIBRARY} )
# tests
set( testparser_SRCS testparser.cpp )
-kode_add_xml_parser( testparser_SRCS account.xml )
kde4_add_executable( testparser TEST ${testparser_SRCS} )
target_link_libraries( testparser ${KDE4_KDECORE_LIBS} ${QT_QTTEST_LIBRARY}
${QT_QTXML_LIBRARY} )
@@ -49,3 +68,4 @@ ADD_TEST(RunTestFeatures ${EXECUTABLE_OUTPUT_PATH}/testfeatures)
ADD_TEST(RunTestHolidays ${EXECUTABLE_OUTPUT_PATH}/testholidays)
ADD_TEST(RunTestAccount ${EXECUTABLE_OUTPUT_PATH}/testaccounts
${CMAKE_CURRENT_SOURCE_DIR}/account.xml)
+ADD_TEST(RunTestParser ${EXECUTABLE_OUTPUT_PATH}/testparser)
@@ -1,5 +1,4 @@
#include "account.h"
-#include "account_parser.h"
#include <KAboutData>
#include <KCmdLineArgs>
@@ -24,7 +23,7 @@ int main( int argc, char **argv )
QString filename = args->arg( 0 );
bool ok;
- Account account = AccountParser::parseFile( filename, &ok );
+ Account account = Account::parseFile( filename, &ok );
if ( !ok ) {
kError() <<"Parse error";
@@ -1,7 +1,5 @@
#include "testparser.h"
-#include "account.h"
-
#include "qtest_kde.h"
QTEST_KDEMAIN_CORE( TestParser )

0 comments on commit f8988f5

Please sign in to comment.