diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fccad49a4..d29fd03e05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ ENDIF() PROJECT (Gnucash) +#ENABLE_TESTING() + # Version number of gnucash SET (GNUCASH_MAJOR_VERSION 2) SET (GNUCASH_MINOR_VERSION 6) @@ -43,6 +45,7 @@ INCLUDE (CheckIncludeFiles) INCLUDE (GncAddSchemeTargets) INCLUDE (GncConfigure) INCLUDE (GncAddGSchemaTargets) +#INCLUDE (GncAddTest) # ############################################################ # These options are settable from the CMake command line. For example, to disable @@ -76,6 +79,8 @@ SET(DATADIRNAME share) SET(GNC_SYSTEM_XDG_DATA_DIRS /usr/local/share /usr/share) SET(GNC_DBD_DIR ${CMAKE_PREFIX_PATH}/lib/dbd CACHE PATH "specify location of libdbi drivers") SET(PKGLIBDIR ${CMAKE_INSTALL_PREFIX}/lib/gnucash) +#SET(TEST_MYSQL_URL "" CACHE STRING "MySQL database URL for testing") +#SET(TEST_PGSQL_URL "" CACHE STRING "PgSQL database URL for testing") IF(GNC_BUILD_AS_INSTALL) SET(DATADIR_BUILD ${CMAKE_BINARY_DIR}/${DATADIRNAME}) @@ -85,6 +90,11 @@ IF(GNC_BUILD_AS_INSTALL) ENDIF() +#SET(SHELL_FROM_ENV $ENV{SHELL}) +#SET(SHELL bin/bash) +#IF (SHELL_FROM_ENV) # Replacing this with IF ($ENV{SHELL}) doesn't work. +# SET(SHELL ${SHELL_FROM_ENV}) +#ENDIF() IF (WIN32) # Help Windows find the various dependencies. We assume here that the standard advice for building @@ -379,7 +389,7 @@ ENDIF (APPLE AND WITH_GNUCASH) IF (UNIX AND NOT APPLE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib/gnucash") -ENDIF() +ENDIF() SET(BUILD_SHARED_LIBS ON) @@ -406,6 +416,25 @@ IF (GNC_BUILD_AS_INSTALL) ENDIF() # ############################################################ +#SET(CMAKE_CTEST_COMMAND ctest) +#IF (XCODE_VERSION) +# SET(CMAKE_CTEST_COMMAND ctest -C Debug) +#ENDIF() + +# There are targets that need to build before tests will run +#ADD_CUSTOM_TARGET(check +# COMMAND ${CMAKE_CTEST_COMMAND} +# DEPENDS gnucash scm-app-utils scm-gnome-utils scm-report-gnome +# scm-engine scm-gnc-module scm-test-engine scm-report-system-3 +# scm-test-core scm-test-report-system scm-standard-reports-2 +# scm-test-standard-reports foo gncmodfoo baz gncmodbaz +# bar gncmodbar gncmod_agedver gncmod_incompatdep +# gncmod_futuremodsys +#) +#IF (NOT WIN32) +# ADD_DEPENDENCIES(check gncmod-backend-xml-link) +#ENDIF() + # The subdirectories ADD_SUBDIRECTORY (accounts) ADD_SUBDIRECTORY (checks) diff --git a/cmake/README_CMAKE.txt b/cmake/README_CMAKE.txt index 439a04867b..c9249e14c6 100644 --- a/cmake/README_CMAKE.txt +++ b/cmake/README_CMAKE.txt @@ -29,10 +29,10 @@ faster that using the default Makefile generator to me.) == Scope -The scope of the current work is to duplicate the `make` and `make -install` actions as the Autotools system would. Currently, there is no -support for `make check`, `make dist`, `make distcheck` or similar -targets. Other limitations include: +The scope of the current work is to duplicate the `make`, +`make check` and `make install` actions as the Autotools system would. +Currently, there is no support for `make dist`, `make distcheck` or +similar targets. Other limitations include: * Not all options available in `./configure` have been ported to this CMake system. @@ -152,6 +152,24 @@ For Xcode via the command line (see below to build from within Xcode): $ xcodebuild -jobs N [-target=install] +=== Running tests + +To run the Gnucash tests (also called checks), use the `check` target. +For ninja, use: + + $ ninja check + +For Makefiles: + + $ make check + +For Xcode via the command line: + + $ xcodebuild -jobs N -target=check + +A test summary will appear in the terminal. Full logs are available +in at Testing/Temporary/LastTest.log in the build directory. + === Launching GnuCash Assuming the build completes successfully, in all cases you can run @@ -186,7 +204,6 @@ Then continue to follow the existing build instructions. At this writing, generating a distribution with the CMake build via dist.sh has not been tested. - == Using Xcode on OS X CMake can generate build files for Xcode such that GnuCash can be diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt index 1b35478368..69aa20b1e9 100644 --- a/po/CMakeLists.txt +++ b/po/CMakeLists.txt @@ -1,9 +1,9 @@ # Set of available languages. -SET (TP_LINGUAS az ca cs da eu fa ja nl pt rw sk sr sv tr uk zh_CN) +SET (TP_LINGUAS az ca cs da eu fa ja nl rw sk sr sv tr uk zh_CN) # already marked as external at TP: -SET (GC_LINGUAS ar bg de el en_GB es fi fr gu he hi hu it kn ko lt lv mr nb ne pl pt_BR pt_PT ro ru ta te ur vi zh_TW) +SET (GC_LINGUAS ar bg de el en_GB es fi fr gu he hi hu it kn ko lt lv mr nb ne pl pt pt_BR ro ru ta te ur vi zh_TW) # not marked or no TP team: SET (NEW_LINGUAS as brx doi es_NI kok kok@latin ks mai mni mni@bengali) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b67f3ba7d..c7045bfb61 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,6 +103,7 @@ IF (APPLE) # FIXME: HANDLE gtk-mac-integration-gtk2 SET(GNC_PLATFORM_DARWIN 1) SET(GNC_PLATFORM_OSX 1) + SET(PLATFORM_OSX 1) SET(HAVE_OSX_KEYCHAIN 1) ENDIF(APPLE) diff --git a/src/app-utils/CMakeLists.txt b/src/app-utils/CMakeLists.txt index dd4f97a7ce..6318fc0087 100644 --- a/src/app-utils/CMakeLists.txt +++ b/src/app-utils/CMakeLists.txt @@ -1,4 +1,4 @@ - +#ADD_SUBDIRECTORY(test) # Build the library SET (app_utils_noinst_HEADERS @@ -190,4 +190,4 @@ GNC_ADD_SCHEME_TARGETS(scm-app-utils-3 FALSE ) -ADD_CUSTOM_TARGET(scm-app-utils ALL DEPENDS scm-app-utils-3 scm-app-utils-2 scm-app-utils-1 scm-gettext) \ No newline at end of file +ADD_CUSTOM_TARGET(scm-app-utils ALL DEPENDS scm-app-utils-3 scm-app-utils-2 scm-app-utils-1 scm-gettext) diff --git a/src/app-utils/gnc-sx-instance-model.c b/src/app-utils/gnc-sx-instance-model.c index 3575d65a00..cd0d526663 100644 --- a/src/app-utils/gnc-sx-instance-model.c +++ b/src/app-utils/gnc-sx-instance-model.c @@ -1199,7 +1199,7 @@ create_each_transaction_helper(Transaction *template_txn, void *user_data) if (err_flag) { - g_critical("new transaction creation sx [%s]", + g_critical("Error in SX transaction [%s], creation aborted.", xaccSchedXactionGetName(sx)); xaccTransDestroy(new_txn); xaccTransCommitEdit(new_txn); @@ -1278,6 +1278,7 @@ gnc_sx_instance_model_effect_change(GncSxInstanceModel *model, { GncSxInstance *inst = (GncSxInstance*)instance_iter->data; gboolean sx_is_auto_create; + GList *instance_errors = NULL; xaccSchedXactionGetAutoCreate(inst->parent->sx, &sx_is_auto_create, NULL); if (auto_create_only && !sx_is_auto_create) @@ -1315,9 +1316,20 @@ gnc_sx_instance_model_effect_change(GncSxInstanceModel *model, increment_sx_state(inst, &last_occur_date, &instance_count, &remain_occur_count); break; case SX_INSTANCE_STATE_TO_CREATE: - create_transactions_for_instance(inst, created_transaction_guids, creation_errors); - increment_sx_state(inst, &last_occur_date, &instance_count, &remain_occur_count); - gnc_sx_instance_model_change_instance_state(model, inst, SX_INSTANCE_STATE_CREATED); + create_transactions_for_instance (inst, + created_transaction_guids, + &instance_errors); + if (instance_errors == NULL) + { + increment_sx_state (inst, &last_occur_date, + &instance_count, + &remain_occur_count); + gnc_sx_instance_model_change_instance_state + (model, inst, SX_INSTANCE_STATE_CREATED); + } + else + *creation_errors = g_list_concat (*creation_errors, + instance_errors); break; case SX_INSTANCE_STATE_REMINDER: // do nothing diff --git a/src/app-utils/test/CMakeLists.txt b/src/app-utils/test/CMakeLists.txt new file mode 100644 index 0000000000..3b48eccacd --- /dev/null +++ b/src/app-utils/test/CMakeLists.txt @@ -0,0 +1,28 @@ + +SET(APP_UTILS_TEST_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/src/app-utils + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${CMAKE_SOURCE_DIR}/src/test-core + ${CMAKE_SOURCE_DIR}/src/engine/test-core + ${CMAKE_BINARY_DIR}/src # for config.h + ${GLIB2_INCLUDE_DIRS} + ${GUILE_INCLUDE_DIRS} +) + +SET(APP_UTILS_TEST_LIBS gncmod-app-utils gncmod-test-engine gnc-qof test-core ${GUILE_LDFLAGS}) + +MACRO(ADD_APP_UTILS_TEST _TARGET _SOURCE_FILES) + GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS) +ENDMACRO() + +ADD_APP_UTILS_TEST(test-exp-parser test-exp-parser.c) +GNC_ADD_TEST_WITH_GUILE(test-link-module test-link-module APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS) +ADD_APP_UTILS_TEST(test-print-parse-amount test-print-parse-amount.c) +# This test not run in autotools build. +#GNC_ADD_TEST_WITH_GUILE(test-print-queries test-print-queries.c APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS) +GNC_ADD_TEST_WITH_GUILE(test-scm-query-string test-scm-query-string.c + APP_UTILS_TEST_INCLUDE_DIRS APP_UTILS_TEST_LIBS +) +ADD_APP_UTILS_TEST(test-sx test-sx.c) + +GNC_ADD_SCHEME_TEST(scm-test-load-module test-load-module.in) diff --git a/src/app-utils/test/test-scm-query-string.cpp b/src/app-utils/test/test-scm-query-string.cpp index 68b963ab57..33f963ef39 100644 --- a/src/app-utils/test/test-scm-query-string.cpp +++ b/src/app-utils/test/test-scm-query-string.cpp @@ -135,7 +135,7 @@ main (int argc, char **argv) /* When built with clang, guile-1.8.8's scm_c_eval_string truncates all * integer values to int32, which causes this test to fail. */ -#ifndef __clang__ +#if !(defined(__clang__)) || defined(HAVE_GUILE20) scm_boot_guile (argc, argv, main_helper, NULL); #endif return 0; diff --git a/src/backend/dbi/CMakeLists.txt b/src/backend/dbi/CMakeLists.txt index 8e96b818a9..a6f3c0265e 100644 --- a/src/backend/dbi/CMakeLists.txt +++ b/src/backend/dbi/CMakeLists.txt @@ -1,5 +1,7 @@ # CMakeLists.txt for src/backend/dbi +#ADD_SUBDIRECTORY(test) + # Source file gncmod-backend-dbi.c does not appear to be use in Makefile.in, so not included here. SET (backend_dbi_SOURCES diff --git a/src/backend/dbi/test/CMakeLists.txt b/src/backend/dbi/test/CMakeLists.txt new file mode 100644 index 0000000000..d3e7c800d6 --- /dev/null +++ b/src/backend/dbi/test/CMakeLists.txt @@ -0,0 +1,31 @@ + +SET(BACKEND_DBI_TEST_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/core-utils + ${CMAKE_SOURCE_DIR}/src/backend/dbi/test + ${CMAKE_SOURCE_DIR}/src/backend/sql + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${CMAKE_SOURCE_DIR}/src/engine + ${CMAKE_SOURCE_DIR}/src/engine/test-core + ${CMAKE_SOURCE_DIR}/src/test-core + ${LIBDBI_INCLUDE_PATH} + ${GLIB2_INCLUDE_DIRS} +) +SET(BACKEND_DBI_TEST_LIBS gnc-backend-sql gncmod-engine gncmod-test-engine gnc-qof test-core ${LIBDBI_LIBRARY}) + +SET(test_dbi_backend_SOURCES + test-backend-dbi.c + test-backend-dbi-basic.c + test-dbi-business-stuff.c + test-dbi-stuff.c +) + +GNC_ADD_TEST(test-backend-dbi "${test_dbi_backend_SOURCES}" + BACKEND_DBI_TEST_INCLUDE_DIRS BACKEND_DBI_TEST_LIBS +) + +TARGET_COMPILE_DEFINITIONS(test-backend-dbi PRIVATE + TEST_MYSQL_URL=\"${TEST_MYSQL_URL}\" + TEST_PGSQL_URL=\"${TEST_PGSQL_URL}\" + DBI_TEST_XML_FILENAME=\"${CMAKE_CURRENT_SOURCE_DIR}/test-dbi.xml\" +) \ No newline at end of file diff --git a/src/backend/sql/CMakeLists.txt b/src/backend/sql/CMakeLists.txt index 4da6bfa7a2..c9293e2056 100644 --- a/src/backend/sql/CMakeLists.txt +++ b/src/backend/sql/CMakeLists.txt @@ -1,6 +1,6 @@ # CMakeLists.txt for src/backend/dbi - +#ADD_SUBDIRECTORY(test) SET (backend_sql_SOURCES gnc-backend-sql.cpp diff --git a/src/backend/sql/test/CMakeLists.txt b/src/backend/sql/test/CMakeLists.txt new file mode 100644 index 0000000000..2d6a63f8d0 --- /dev/null +++ b/src/backend/sql/test/CMakeLists.txt @@ -0,0 +1,23 @@ + +SET(BACKEND_SQL_TEST_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/backend/sql + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof. + ${CMAKE_SOURCE_DIR}/src/engine + ${CMAKE_SOURCE_DIR}/src/test-core + ${GLIB2_INCLUDE_DIRS} +) + +SET(BACKEND_SQL_TEST_LIBS gnc-backend-sql gncmod-engine gnc-qof test-core) + +# This test does not actually do anything. +GNC_ADD_TEST(test-column-types test-column-types.c + BACKEND_SQL_TEST_INCLUDE_DIRS BACKEND_SQL_TEST_LIBS +) + + + +GNC_ADD_TEST(test-sqlbe "test-sqlbe.c;utest-gnc-backend-sql.c" + BACKEND_SQL_TEST_INCLUDE_DIRS BACKEND_SQL_TEST_LIBS +) +TARGET_COMPILE_DEFINITIONS(test-sqlbe PRIVATE TESTPROG=test_sqlbe) \ No newline at end of file diff --git a/src/backend/xml/CMakeLists.txt b/src/backend/xml/CMakeLists.txt index 99fd6986f1..22eeaa789d 100644 --- a/src/backend/xml/CMakeLists.txt +++ b/src/backend/xml/CMakeLists.txt @@ -1,5 +1,7 @@ # CMakeLists.txt for src/backend/xml +#ADD_SUBDIRECTORY(test) + # Command to generate the swig-engine.c wrapper file SET (SWIG_GNC_MODULE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnc-module.c) GNC_ADD_SWIG_COMMAND (${SWIG_GNC_MODULE_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnc-module.i) diff --git a/src/backend/xml/test/CMakeLists.txt b/src/backend/xml/test/CMakeLists.txt new file mode 100644 index 0000000000..d9e4c7cf1c --- /dev/null +++ b/src/backend/xml/test/CMakeLists.txt @@ -0,0 +1,99 @@ +# Common stuff + +SET(XML_TEST_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/src/backend/xml + ${CMAKE_SOURCE_DIR}/src/backend/xml/test + ${CMAKE_SOURCE_DIR}/src/engine + ${CMAKE_SOURCE_DIR}/src/engine/test-core + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/test-core # for unittest-support.h + ${GLIB2_INCLUDE_DIRS} + ${LIBXML2_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIRS} +) + + +SET(XML_TEST_LIBS gncmod-engine gnc-qof gncmod-test-engine test-core ${LIBXML2_LDFLAGS} -lz) + +FUNCTION(ADD_XML_TEST _TARGET _SOURCE_FILES) + GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" XML_TEST_INCLUDE_DIRS XML_TEST_LIBS ${ARGN}) +ENDFUNCTION() + + +################################ + +SET(test_backend_xml_base_SOURCES + ${CMAKE_SOURCE_DIR}/src/backend/xml/sixtp-dom-parsers.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/sixtp-dom-generators.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/sixtp-utils.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/sixtp.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/sixtp-stack.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/sixtp-to-dom-parser.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-xml-helper.c +) + +## the xml backend is now a GModule - this test does +## not load it as a module and cannot link to it +## and remain portable. + +SET(test_backend_xml_module_SOURCES + ${test_backend_xml_base_SOURCES} + ${CMAKE_SOURCE_DIR}/src/backend/xml/io-example-account.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/io-gncxml-gen.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/io-gncxml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/io-utils.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-account-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-budget-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-lot-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-recurrence-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-schedxaction-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-freqspec-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-transaction-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-commodity-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-book-xml-v2.c + ${CMAKE_SOURCE_DIR}/src/backend/xml/gnc-pricedb-xml-v2.c +) + +# The test test-dom-parser1.c is not run by Makefile.am + +ADD_XML_TEST(test-date-converting "${test_backend_xml_base_SOURCES};test-date-converting.c") +ADD_XML_TEST(test-dom-converters1 "${test_backend_xml_base_SOURCES};test-dom-converters1.c") +ADD_XML_TEST(test-kvp-frames "${test_backend_xml_base_SOURCES};test-kvp-frames.c") +ADD_XML_TEST(test-load-backend test-load-backend.c) +ADD_XML_TEST(test-load-xml2 test-load-xml2.c + GNC_TEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/test-files/xml2 +) +# Not run in autotools. +#ADD_XML_TEST(test-save-in-lang test-save-in-lang.c +# GNC_TEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/test-files/xml2 +#) + +GNC_ADD_TEST_WITH_GUILE(test-load-example-account + "${test_backend_xml_module_SOURCES};test-load-example-account.c" + XML_TEST_INCLUDE_DIRS XML_TEST_LIBS + GNC_ACCOUNT_PATH=${CMAKE_SOURCE_DIR}/accounts/C +) +ADD_XML_TEST(test-string-converters "${test_backend_xml_base_SOURCES};test-string-converters.c") +ADD_XML_TEST(test-xml-account "${test_backend_xml_module_SOURCES};test-xml-account.c;test-file-stuff.c") +ADD_XML_TEST(test-xml-commodity "${test_backend_xml_module_SOURCES};test-xml-commodity.c;test-file-stuff.c") +ADD_XML_TEST(test-xml-pricedb "${test_backend_xml_module_SOURCES};test-xml-pricedb.c;test-file-stuff.c") +ADD_XML_TEST(test-xml-transaction "${test_backend_xml_module_SOURCES};test-xml-transaction.c;test-file-stuff.c") +ADD_XML_TEST(test-xml2-is-file "${test_backend_xml_module_SOURCES};test-xml2-is-file.c" + GNC_TEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/test-files/xml2) + +SET(CMAKE_COMMAND_TMP "") +IF (${CMAKE_VERSION} VERSION_GREATER 3.1) + SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) +ENDIF() + +SET(test-real-data-env + SRCDIR=${CMAKE_CURRENT_SOURCE_DIR} + VERBOSE=yes + TEST_PATH=${CMAKE_BINARY_DIR}/bin +) +ADD_TEST(NAME test-real-data + COMMAND ${CMAKE_COMMAND_TMP} + ${SHELL} ${CMAKE_CURRENT_SOURCE_DIR}/test-real-data.sh.in +) +SET_TESTS_PROPERTIES(test-real-data PROPERTIES ENVIRONMENT "${test-real-data-env}") diff --git a/src/backend/xml/test/test-real-data.sh.in b/src/backend/xml/test/test-real-data.sh.in index 0c273bf458..49e757b83c 100755 --- a/src/backend/xml/test/test-real-data.sh.in +++ b/src/backend/xml/test/test-real-data.sh.in @@ -3,7 +3,9 @@ #set -e EXIT_VALUE=0 - +if [ "x$TEST_PATH" == "x" ] ; then + TEST_PATH=. +fi for i in $SRCDIR/test-files/xml2/*.gml2 ; do if [ ! -d $i ] ; then @@ -15,9 +17,9 @@ for i in $SRCDIR/test-files/xml2/*.gml2 ; do FILES=`perl $SRCDIR/grab-types.pl "gnc:$j" $i "$j/dataXXX.xml"` if [ ! -z "$FILES" ] ; then if [ "x$VERBOSE" = "xyes" ] ; then - echo "Testing ./test-xml-$j $j/data*.xml # from `basename $i`:" + echo "Testing $TEST_PATH/test-xml-$j $j/data*.xml # from `basename $i`:" fi - eval "./test-xml-$j $FILES 2>/dev/null" + eval "$TEST_PATH/test-xml-$j $FILES 2>/dev/null" if [ $? != 0 ] ; then EXIT_VALUE=1 fi diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt index 98e3c2a490..aa24740bc3 100644 --- a/src/bin/CMakeLists.txt +++ b/src/bin/CMakeLists.txt @@ -1,5 +1,5 @@ ADD_SUBDIRECTORY(overrides) - +#ADD_SUBDIRECTORY(test) # Some settings are platform dependent. Let's define them per platform. IF (WIN32) # Windows specific settings go here: diff --git a/src/bin/test/CMakeLists.txt b/src/bin/test/CMakeLists.txt new file mode 100644 index 0000000000..540e0152c9 --- /dev/null +++ b/src/bin/test/CMakeLists.txt @@ -0,0 +1,3 @@ + +ADD_TEST(NAME test-version + COMMAND ${CMAKE_BINARY_DIR}/bin/gnucash --version) \ No newline at end of file diff --git a/src/cmake_modules/GncAddTest.cmake b/src/cmake_modules/GncAddTest.cmake new file mode 100644 index 0000000000..3284ce8135 --- /dev/null +++ b/src/cmake_modules/GncAddTest.cmake @@ -0,0 +1,64 @@ + +FUNCTION(GNC_ADD_TEST _TARGET _SOURCE_FILES TEST_INCLUDE_VAR_NAME TEST_LIBS_VAR_NAME) + SET(HAVE_ENV_VARS FALSE) + IF (${ARGC} GREATER 4) + # Extra arguments are treated as environment variables + SET(HAVE_ENV_VARS TRUE) + ENDIF() + SET(TEST_INCLUDE_DIRS ${${TEST_INCLUDE_VAR_NAME}}) + SET(TEST_LIBS ${${TEST_LIBS_VAR_NAME}}) + SET_SOURCE_FILES_PROPERTIES (${_SOURCE_FILES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H}) + ADD_EXECUTABLE(${_TARGET} EXCLUDE_FROM_ALL ${_SOURCE_FILES}) + TARGET_LINK_LIBRARIES(${_TARGET} ${TEST_LIBS}) + TARGET_INCLUDE_DIRECTORIES(${_TARGET} PRIVATE ${TEST_INCLUDE_DIRS}) + IF (${HAVE_ENV_VARS}) + SET(CMAKE_COMMAND_TMP "") + IF (${CMAKE_VERSION} VERSION_GREATER 3.1) + SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) + ENDIF() + ADD_TEST(${_TARGET} ${CMAKE_COMMAND_TMP} + ${CMAKE_BINARY_DIR}/bin/${_TARGET} + ) + SET_TESTS_PROPERTIES(${_TARGET} PROPERTIES ENVIRONMENT "${ARGN}") + ELSE() + ADD_TEST(NAME ${_TARGET} COMMAND ${_TARGET}) + ENDIF() + ADD_DEPENDENCIES(check ${_TARGET}) +ENDFUNCTION() + +FUNCTION(GNC_ADD_TEST_WITH_GUILE _TARGET _SOURCE_FILES TEST_INCLUDE_VAR_NAME TEST_LIBS_VAR_NAME) + SET(_GNC_MODULE_PATH ${CMAKE_BINARY_DIR}/lib:${CMAKE_BINARY_DIR}/lib/gnucash) + GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" "${TEST_INCLUDE_VAR_NAME}" "${TEST_LIBS_VAR_NAME}" + GNC_UNINSTALLED=yes + GNC_BUILDDIR=${CMAKE_BINARY_DIR} + GUILE_WARN_DEPRECATED=no + GNC_MODULE_PATH=${_GNC_MODULE_PATH} + DYLD_LIBRARY_PATH=${_GNC_MODULE_PATH} + LD_LIBRARY_PATH=${_GNC_MODULE_PATH} + GUILE_LOAD_COMPILED_PATH=${CMAKE_BINARY_DIR}/lib/gnucash/scm/ccache/2.0 + ${ARGN} + ) +ENDFUNCTION() + + +FUNCTION(GNC_ADD_SCHEME_TEST _TARGET _SOURCE_FILE) + SET(CMAKE_COMMAND_TMP "") + IF (${CMAKE_VERSION} VERSION_GREATER 3.1) + SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) + ENDIF() + SET(_GNC_MODULE_PATH ${CMAKE_BINARY_DIR}/lib:${CMAKE_BINARY_DIR}/lib/gnucash) + SET(GUILE_ENV + GNC_UNINSTALLED=yes + GNC_BUILDDIR=${CMAKE_BINARY_DIR} + GUILE_WARN_DEPRECATED=no + GNC_MODULE_PATH=${_GNC_MODULE_PATH} + DYLD_LIBRARY_PATH=${_GNC_MODULE_PATH} + LD_LIBRARY_PATH=${_GNC_MODULE_PATH} + GUILE_LOAD_COMPILED_PATH=${CMAKE_BINARY_DIR}/lib/gnucash/scm/ccache/2.0 + ${ARGN} + ) + ADD_TEST(${_TARGET} ${CMAKE_COMMAND_TMP} + ${GUILE_EXECUTABLE} --debug -l ${CMAKE_CURRENT_SOURCE_DIR}/${_SOURCE_FILE} -c "(exit (run-test))" + ) + SET_TESTS_PROPERTIES(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV}") +ENDFUNCTION() diff --git a/src/config.h.cmake.in b/src/config.h.cmake.in index c4754cbb9e..cd9b25014e 100644 --- a/src/config.h.cmake.in +++ b/src/config.h.cmake.in @@ -36,6 +36,7 @@ /* Running on OSX, either X11 or Quartz */ #cmakedefine GNC_PLATFORM_OSX 1 +#cmakedefine PLATFORM_OSX 1 /* POSIX-compliant OS */ #cmakedefine GNC_PLATFORM_POSIX 1 diff --git a/src/core-utils/CMakeLists.txt b/src/core-utils/CMakeLists.txt index 55eab995ff..2d5241078a 100644 --- a/src/core-utils/CMakeLists.txt +++ b/src/core-utils/CMakeLists.txt @@ -1,6 +1,6 @@ # CMakeLists.txt for src/core-utils - +#ADD_SUBDIRECTORY(test) # Command to generate the swig-engine.c wrapper file SET (SWIG_CORE_UTILS_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils.c) GNC_ADD_SWIG_COMMAND (${SWIG_CORE_UTILS_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i) diff --git a/src/core-utils/test/CMakeLists.txt b/src/core-utils/test/CMakeLists.txt new file mode 100644 index 0000000000..c701343dd5 --- /dev/null +++ b/src/core-utils/test/CMakeLists.txt @@ -0,0 +1,18 @@ + + +SET(CORE_UTILS_TEST_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/core-utils + ${CMAKE_SOURCE_DIR}/src/test-core + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${GLIB2_INCLUDE_DIRS} +) +SET(CORE_UTILS_TEST_LIBS gnc-core-utils gnc-qof test-core) + +MACRO(ADD_CORE_UTILS_TEST _TARGET _SOURCE_FILES) + GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" CORE_UTILS_TEST_INCLUDE_DIRS CORE_UTILS_TEST_LIBS) +ENDMACRO() + +ADD_CORE_UTILS_TEST(test-gnc-glib-utils test-gnc-glib-utils.c) +ADD_CORE_UTILS_TEST(test-gnc-uri-utils test-gnc-uri-utils.c) +ADD_CORE_UTILS_TEST(test-resolve-file-path test-resolve-file-path.c) \ No newline at end of file diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt index 9bb9fbb99a..4d911f5f1f 100644 --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -1,5 +1,8 @@ # CMakeLists.txt for src/engine +#ADD_SUBDIRECTORY(test-core) +#ADD_SUBDIRECTORY(test) + SET(engine_noinst_HEADERS AccountP.h ScrubP.h diff --git a/src/engine/test-core/CMakeLists.txt b/src/engine/test-core/CMakeLists.txt new file mode 100644 index 0000000000..d5b7790650 --- /dev/null +++ b/src/engine/test-core/CMakeLists.txt @@ -0,0 +1,17 @@ + + +SET(libgncmod_test_engine_SOURCES + gncmod-test-engine.c test-engine-stuff.c +) + +ADD_LIBRARY(gncmod-test-engine STATIC ${libgncmod_test_engine_SOURCES}) + +TARGET_INCLUDE_DIRECTORIES(gncmod-test-engine PRIVATE + ${GMODULE_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${CMAKE_SOURCE_DIR}/src/libqof/qof + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/engine + ${CMAKE_SOURCE_DIR}/src/test-core +) \ No newline at end of file diff --git a/src/engine/test/CMakeLists.txt b/src/engine/test/CMakeLists.txt new file mode 100644 index 0000000000..b66c1bc9ef --- /dev/null +++ b/src/engine/test/CMakeLists.txt @@ -0,0 +1,91 @@ +# Common stuff + +SET(ENGINE_TEST_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/src/backend/xml + ${CMAKE_SOURCE_DIR}/src/engine + ${CMAKE_SOURCE_DIR}/src/engine/test-core + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/test-core # for unittest-support.h + ${GLIB2_INCLUDE_DIRS} +) + +SET(ENGINE_TEST_LIBS gncmod-engine gnc-qof gncmod-test-engine test-core ${LIBXML2_LDFLAGS}) + +MACRO(ADD_ENGINE_TEST _TARGET _SOURCE_FILES) + GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" ENGINE_TEST_INCLUDE_DIRS ENGINE_TEST_LIBS) +ENDMACRO() + +# Not via macro because of unique link requirements + +ADD_EXECUTABLE(test-link EXCLUDE_FROM_ALL test-link.c) +TARGET_LINK_LIBRARIES(test-link gnc-qof gnc-core-utils) +ADD_TEST(NAME test-link COMMAND test-link) +ADD_DEPENDENCIES(check test-link) + +################################################# + +ADD_ENGINE_TEST(test-load-engine test-load-engine.c) +ADD_ENGINE_TEST(test-guid test-guid.c) +ADD_ENGINE_TEST(test-numeric test-numeric.c) +ADD_ENGINE_TEST(test-date test-date.c) +ADD_ENGINE_TEST(test-object test-object.c) +ADD_ENGINE_TEST(test-commodities test-commodities.c) + +SET(test_engine_SOURCES + test-engine.c + utest-Account.c + utest-Budget.c + utest-Entry.c + utest-Invoice.c + utest-Split.c + utest-Transaction.c +) + +ADD_ENGINE_TEST(test-engine "${test_engine_SOURCES}") +TARGET_COMPILE_OPTIONS(test-engine PRIVATE -Wno-write-strings) + +ADD_ENGINE_TEST(test-account-object test-account-object.c) +ADD_ENGINE_TEST(test-group-vs-book test-group-vs-book.c) +ADD_ENGINE_TEST(test-lots test-lots.c) +ADD_ENGINE_TEST(test-querynew test-querynew.c) +ADD_ENGINE_TEST(test-query test-query.c) +ADD_ENGINE_TEST(test-split-vs-account test-split-vs-account.c) +ADD_ENGINE_TEST(test-transaction-reversal test-transaction-reversal.c) +ADD_ENGINE_TEST(test-transaction-voiding test-transaction-voiding.c) +ADD_ENGINE_TEST(test-recurrence test-recurrence.c) +ADD_ENGINE_TEST(test-business test-business.c) +ADD_ENGINE_TEST(test-address test-address.c) +ADD_ENGINE_TEST(test-customer test-customer.c) +ADD_ENGINE_TEST(test-employee test-employee.c) +ADD_ENGINE_TEST(test-job test-job.c) +ADD_ENGINE_TEST(test-vendor test-vendor.c) + +############################ +# This is a C test that needs GUILE environment variables set. +GNC_ADD_TEST_WITH_GUILE(test-scm-query test-scm-query.c ENGINE_TEST_INCLUDE_DIRS ENGINE_TEST_LIBS) +############################ + +GNC_ADD_SCHEME_TEST(scm-test-account test-account.scm) +GNC_ADD_SCHEME_TEST(scm-test-create-account test-create-account.scm) +GNC_ADD_SCHEME_TEST(scm-test-test-extra test-test-extras.scm) +GNC_ADD_SCHEME_TEST(scm-test-split test-split.scm) +# This check not run in autotools. Doesn't pass. +#GNC_ADD_SCHEME_TEST(scm-test-scm-query-import test-scm-query-import.scm) + +SET(engine_test_SCHEME test-extras.scm) + +SET(GUILE_MODULES "") +SET(GUILE_LOAD_DIRS src/app-utils src/scm) +SET(GUILE_LIBRARY_DIRS "") +SET(GUILE_DEPENDS scm-app-utils scm-scm) + +GNC_ADD_SCHEME_TARGETS(scm-test-engine + "${engine_test_SCHEME}" + gnucash/engine/test + "${GUILE_MODULES}" + "${GUILE_LOAD_DIRS}" + "${GUILE_LIBRARY_DIRS}" + "${GUILE_DEPENDS}" + FALSE +) diff --git a/src/gnc-module/CMakeLists.txt b/src/gnc-module/CMakeLists.txt index d06f982fef..ebad85a961 100644 --- a/src/gnc-module/CMakeLists.txt +++ b/src/gnc-module/CMakeLists.txt @@ -1,4 +1,5 @@ # CMakeLists.txt for src/gnc-module +#ADD_SUBDIRECTORY(test) # Command to generate the swig-engine.c wrapper file SET (SWIG_GNC_MODULE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnc-module.c) diff --git a/src/gnc-module/test/CMakeLists.txt b/src/gnc-module/test/CMakeLists.txt new file mode 100644 index 0000000000..b9de8a4996 --- /dev/null +++ b/src/gnc-module/test/CMakeLists.txt @@ -0,0 +1,103 @@ + +# TESTCOUNTS: { dir: gnc-module/test, test_count: 12 } + +ADD_SUBDIRECTORY(mod-foo) +ADD_SUBDIRECTORY(mod-bar) +ADD_SUBDIRECTORY(mod-baz) +ADD_SUBDIRECTORY(misc-mods) + +SET(GNC_MODULE_TEST_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${CMAKE_SOURCE_DIR}/src/test-core + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${GLIB2_INCLUDE_DIRS} + ${GUILE_INCLUDE_DIRS} +) + +SET(GNC_MODULE_TEST_LIBS gnc-module gnc-qof test-core) + +MACRO(ADD_GNC_MODULE_TEST _TARGET _SOURCE_FILES) + GNC_ADD_TEST(${_TARGET} "${_SOURCE_FILES}" GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS) +ENDMACRO() + +SET(_GNC_MODULE_PATH ${CMAKE_BINARY_DIR}/lib:${CMAKE_BINARY_DIR}/lib/gnucash) +SET(GUILE_ENV + GNC_UNINSTALLED=yes + GNC_BUILDDIR=${CMAKE_BINARY_DIR} + GUILE_WARN_DEPRECATED=no + GNC_MODULE_PATH=${_GNC_MODULE_PATH} + DYLD_LIBRARY_PATH=${_GNC_MODULE_PATH} + LD_LIBRARY_PATH=${_GNC_MODULE_PATH} + GUILE_LOAD_COMPILED_PATH=${CMAKE_BINARY_DIR}/lib/gnucash/scm/ccache/2.0 +) + + +FUNCTION(RUN_TEST_WITH_GUILE _TARGET _SOURCE_FILE) + SET(CMAKE_COMMAND_TMP "") + IF (${CMAKE_VERSION} VERSION_GREATER 3.1) + SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) + ENDIF() + ADD_TEST(NAME ${_TARGET} + COMMAND ${CMAKE_COMMAND_TMP} + ${GUILE_EXECUTABLE} -s ${_SOURCE_FILE} + ) + SET_TESTS_PROPERTIES(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV};${ARGN}") +ENDFUNCTION() + +GNC_ADD_TEST_WITH_GUILE(test-load-c test-load-c.c GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS + GUILE_LOAD_PATH=${CMAKE_CURRENT_SOURCE_DIR}/mod-foo +) + +RUN_TEST_WITH_GUILE(test-load-scm ${CMAKE_CURRENT_SOURCE_DIR}/test-load-scm.in + GUILE_LOAD_PATH=${CMAKE_CURRENT_SOURCE_DIR}/mod-foo +) +RUN_TEST_WITH_GUILE(test-load-deps ${CMAKE_CURRENT_SOURCE_DIR}/test-load-deps.in + GUILE_LOAD_PATH=${CMAKE_CURRENT_SOURCE_DIR}/mod-foo:${CMAKE_CURRENT_SOURCE_DIR}/mod-baz +) +RUN_TEST_WITH_GUILE(test-scm-init ${CMAKE_CURRENT_SOURCE_DIR}/test-scm-init.in) + +RUN_TEST_WITH_GUILE(test-scm-multi ${CMAKE_CURRENT_SOURCE_DIR}/test-scm-multi.in + GUILE_LOAD_PATH=${CMAKE_CURRENT_SOURCE_DIR}/mod-foo:${CMAKE_CURRENT_SOURCE_DIR}/mod-bar +) +RUN_TEST_WITH_GUILE(test-scm-dynload ${CMAKE_CURRENT_SOURCE_DIR}/test-scm-dynload.in) + +GNC_ADD_TEST_WITH_GUILE(test-modsysver test-modsysver.c + GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS +) +GNC_ADD_TEST_WITH_GUILE(test-incompatdep test-incompatdep.c + GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS +) +GNC_ADD_TEST_WITH_GUILE(test-agedver test-agedver.c + GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS +) + +GNC_ADD_TEST(test-dynload test-dynload.c + GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS + LIBDIR=${CMAKE_BINARY_DIR}/lib +) + +SET(GUILE ${GUILE_EXECUTABLE}) +CONFIGURE_FILE(test-gwrapped-c.in test-gwrapped-c) +CONFIGURE_FILE(test-scm-module.in test-scm-module) + +FUNCTION(RUN_GUILE_SHELL_TEST _TARGET _SOURCE_FILE) + SET(CMAKE_COMMAND_TMP "") + IF (${CMAKE_VERSION} VERSION_GREATER 3.1) + SET(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env) + ENDIF() + ADD_TEST(NAME ${_TARGET} + COMMAND ${CMAKE_COMMAND_TMP} + ${SHELL} ${_SOURCE_FILE} + ) + SET_TESTS_PROPERTIES(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV};${ARGN}") +ENDFUNCTION() + +RUN_GUILE_SHELL_TEST(test-gwrapped-c ${CMAKE_CURRENT_BINARY_DIR}/test-gwrapped-c + GUILE_LOAD_PATH=${CMAKE_CURRENT_SOURCE_DIR}/mod-foo +) + +RUN_GUILE_SHELL_TEST(test-scm-module ${CMAKE_CURRENT_BINARY_DIR}/test-scm-module + GUILE_LOAD_PATH=${CMAKE_CURRENT_SOURCE_DIR}/mod-foo +) + diff --git a/src/gnc-module/test/misc-mods/CMakeLists.txt b/src/gnc-module/test/misc-mods/CMakeLists.txt new file mode 100644 index 0000000000..71f7ed1514 --- /dev/null +++ b/src/gnc-module/test/misc-mods/CMakeLists.txt @@ -0,0 +1,14 @@ + +INCLUDE_DIRECTORIES( + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${GLIB2_INCLUDE_DIRS} +) + +ADD_LIBRARY(gncmod_agedver EXCLUDE_FROM_ALL agedver.c) +TARGET_LINK_LIBRARIES(gncmod_agedver ${GLIB2_LDFLAGS}) + +ADD_LIBRARY(gncmod_futuremodsys EXCLUDE_FROM_ALL futuremodsys.c) +TARGET_LINK_LIBRARIES(gncmod_futuremodsys ${GLIB2_LDFLAGS}) + +ADD_LIBRARY(gncmod_incompatdep EXCLUDE_FROM_ALL incompatdep.c) +TARGET_LINK_LIBRARIES(gncmod_incompatdep gnc-module ${GLIB2_LDFLAGS}) \ No newline at end of file diff --git a/src/gnc-module/test/mod-bar/CMakeLists.txt b/src/gnc-module/test/mod-bar/CMakeLists.txt new file mode 100644 index 0000000000..6ebf7895c7 --- /dev/null +++ b/src/gnc-module/test/mod-bar/CMakeLists.txt @@ -0,0 +1,18 @@ + +SET (SWIG_BAR_C ${CMAKE_CURRENT_BINARY_DIR}/swig-bar.c) +GNC_ADD_SWIG_COMMAND (${SWIG_BAR_C} ${CMAKE_CURRENT_SOURCE_DIR}/bar.i bar.h) + +ADD_LIBRARY(bar EXCLUDE_FROM_ALL bar.c bar.h) +ADD_LIBRARY(gncmodbar EXCLUDE_FROM_ALL gnc-mod-bar.c) +SET_SOURCE_FILES_PROPERTIES (gnc-mod-bar.c PROPERTY OBJECT_DEPENDS ${SWIG_BAR_C}) + +TARGET_LINK_LIBRARIES(gncmodbar bar gnc-module) +TARGET_INCLUDE_DIRECTORIES(gncmodbar PRIVATE + ${CMAKE_BINARY_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${GLIB2_INCLUDE_DIRS} + ${GUILE_INCLUDE_DIRS} +) diff --git a/src/gnc-module/test/mod-baz/CMakeLists.txt b/src/gnc-module/test/mod-baz/CMakeLists.txt new file mode 100644 index 0000000000..376ff07ce4 --- /dev/null +++ b/src/gnc-module/test/mod-baz/CMakeLists.txt @@ -0,0 +1,24 @@ + +SET (SWIG_BAZ_C ${CMAKE_CURRENT_BINARY_DIR}/swig-baz.c) +GNC_ADD_SWIG_COMMAND (${SWIG_BAZ_C} ${CMAKE_CURRENT_SOURCE_DIR}/baz.i baz.h) + +ADD_LIBRARY(baz EXCLUDE_FROM_ALL baz.c baz.h) +TARGET_INCLUDE_DIRECTORIES(baz PRIVATE + ${CMAKE_SOURCE_DIR}/src/gnc-module/test/mod-foo +) +TARGET_LINK_LIBRARIES(baz foo) + + +ADD_LIBRARY(gncmodbaz EXCLUDE_FROM_ALL gnc-mod-baz.c) +SET_SOURCE_FILES_PROPERTIES (gnc-mod-baz.c PROPERTY OBJECT_DEPENDS ${SWIG_BAZ_C}) + +TARGET_LINK_LIBRARIES(gncmodbaz baz gnc-module) +TARGET_INCLUDE_DIRECTORIES(gncmodbaz PRIVATE + ${CMAKE_BINARY_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${GLIB2_INCLUDE_DIRS} + ${GUILE_INCLUDE_DIRS} +) diff --git a/src/gnc-module/test/mod-foo/CMakeLists.txt b/src/gnc-module/test/mod-foo/CMakeLists.txt new file mode 100644 index 0000000000..13dc0984d7 --- /dev/null +++ b/src/gnc-module/test/mod-foo/CMakeLists.txt @@ -0,0 +1,18 @@ + +SET (SWIG_FOO_C ${CMAKE_CURRENT_BINARY_DIR}/swig-foo.c) +GNC_ADD_SWIG_COMMAND (${SWIG_FOO_C} ${CMAKE_CURRENT_SOURCE_DIR}/foo.i foo.h) + +ADD_LIBRARY(foo EXCLUDE_FROM_ALL foo.c foo.h) +ADD_LIBRARY(gncmodfoo EXCLUDE_FROM_ALL gnc-mod-foo.c) +SET_SOURCE_FILES_PROPERTIES (gnc-mod-foo.c PROPERTY OBJECT_DEPENDS ${SWIG_FOO_C}) + +TARGET_LINK_LIBRARIES(gncmodfoo foo gnc-module) +TARGET_INCLUDE_DIRECTORIES(gncmodfoo PRIVATE + ${CMAKE_BINARY_DIR}/src + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${GLIB2_INCLUDE_DIRS} + ${GUILE_INCLUDE_DIRS} +) diff --git a/src/gnc-module/test/test-dynload.c b/src/gnc-module/test/test-dynload.c index a66f57419f..3fb49196bc 100644 --- a/src/gnc-module/test/test-dynload.c +++ b/src/gnc-module/test/test-dynload.c @@ -40,10 +40,16 @@ guile_main(void *closure, int argc, char ** argv) gchar *logdomain = "gnc.module"; gchar *modpath; guint loglevel = G_LOG_LEVEL_WARNING; + const char *libdir = g_getenv("LIBDIR"); TestErrorStruct check = { loglevel, logdomain, msg }; g_log_set_handler (logdomain, loglevel, (GLogFunc)test_checked_handler, &check); + if (libdir == NULL) + { + libdir = "../.libs"; + } + g_test_message(" test-dynload.c: testing dynamic linking of libgnc-module ..."); #ifdef G_OS_WIN32 /* MinGW builds libgnc-module-0.dll */ @@ -53,9 +59,16 @@ guile_main(void *closure, int argc, char ** argv) * that means that g_module_build_path (), which uses ".so", doesn't * build the right path name. */ - modpath = g_build_filename ("..", ".libs", "libgnc-module.dylib", NULL); + if (libdir == NULL) + { + modpath = g_build_filename ("..", ".libs", "libgnc-module.dylib", NULL); + } + else + { + modpath = g_build_filename (libdir, "libgnc-module.dylib", NULL); + } #else /* Regular Unix */ - modpath = g_module_build_path ("../.libs", "gnc-module"); + modpath = g_module_build_path (libdir, "gnc-module"); #endif gmodule = g_module_open(modpath, 0); diff --git a/src/gnome-utils/CMakeLists.txt b/src/gnome-utils/CMakeLists.txt index 73f6390872..cc60e44700 100644 --- a/src/gnome-utils/CMakeLists.txt +++ b/src/gnome-utils/CMakeLists.txt @@ -3,6 +3,7 @@ ADD_SUBDIRECTORY(gschemas) ADD_SUBDIRECTORY(gtkbuilder) ADD_SUBDIRECTORY(ui) +#ADD_SUBDIRECTORY(test) SET (SWIG_GNOME_UTILS_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnome-utils.c) GNC_ADD_SWIG_COMMAND (${SWIG_GNOME_UTILS_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnome-utils.i) @@ -261,4 +262,4 @@ GNC_ADD_SCHEME_TARGETS(scm-gnome-utils-2 FALSE ) -ADD_CUSTOM_TARGET(scm-gnome-utils ALL DEPENDS scm-gnome-utils-2 scm-gnome-utils-1) \ No newline at end of file +ADD_CUSTOM_TARGET(scm-gnome-utils ALL DEPENDS scm-gnome-utils-2 scm-gnome-utils-1) diff --git a/src/gnome-utils/test/CMakeLists.txt b/src/gnome-utils/test/CMakeLists.txt new file mode 100644 index 0000000000..f3d241a666 --- /dev/null +++ b/src/gnome-utils/test/CMakeLists.txt @@ -0,0 +1,32 @@ + +SET(GNOME_UTILS_TEST_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${GLIB2_INCLUDE_DIRS} + ${GUILE_INCLUDE_DIRS} +) +SET(GNOME_UTILS_TEST_LIBS gnc-module test-core) + +GNC_ADD_TEST_WITH_GUILE(test-link-module-gnome-utils test-link-module.c + GNOME_UTILS_TEST_INCLUDE_DIRS GNOME_UTILS_TEST_LIBS +) + + +SET(GNOME_UTILS_GUI_TEST_INCLUDE_DIRS + ${GNOME_UTILS_TEST_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR}/src + ${CMAKE_SOURCE_DIR}/src/gnome-utils + ${CMAKE_SOURCE_DIR}/src/engine + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${GTK2_INCLUDE_DIRS} +) +SET(GNOME_UTILS_GUI_TEST_LIBS + ${GNOME_UTILS_TEST_LIBS} + gncmod-gnome-utils +) +#This is a GUI test +#GNC_ADD_TEST(test-gnc-recurrence test-gnc-recurrence.c +# GNOME_UTILS_GUI_TEST_INCLUDE_DIRS +# GNOME_UTILS_GUI_TEST_LIBS +# + +GNC_ADD_SCHEME_TEST(test-load-module-gnome-utils test-load-module.in) diff --git a/src/gnome/dialog-sx-editor.c b/src/gnome/dialog-sx-editor.c index 2fe8a59018..e53b6c5d3a 100644 --- a/src/gnome/dialog-sx-editor.c +++ b/src/gnome/dialog-sx-editor.c @@ -644,6 +644,8 @@ gnc_sxed_split_check_account (GncSxEditorDialog *sxed, Split *s, "sx-account", &acct_guid, NULL); acct = xaccAccountLookup (acct_guid, gnc_get_current_book ()); + if (acct == NULL) + return FALSE; split_cmdty = xaccAccountGetCommodity(acct); split_amount = xaccSplitGetAmount(s); if (!gnc_numeric_zero_p(split_amount) && base_cmdty == NULL) @@ -685,6 +687,100 @@ gnc_sxed_split_calculate_formula (GncSxEditorDialog *sxed, Split *s, return TRUE; } +typedef struct +{ + GncSxEditorDialog *sxed; + GHashTable *txns; + GHashTable *vars; + txnCreditDebitSums *tcds; + gboolean multi_commodity; + gboolean err; +} CheckTxnSplitData; + +static void +split_error_warning_dialog (GtkWidget *parent, const gchar *title, + gchar *message) +{ + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (parent), 0, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_CLOSE, + "%s", title); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + "%s", message); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent)); + g_signal_connect_swapped (dialog, "response", + G_CALLBACK(gtk_widget_destroy), dialog); + gtk_dialog_run (GTK_DIALOG (dialog)); + +} +static gboolean +check_transaction_splits (Transaction *txn, gpointer data) +{ + GList *splitList = xaccTransGetSplitList (txn); + CheckTxnSplitData *sd = (CheckTxnSplitData*)data; + + for ( ; splitList; splitList = splitList->next ) + { + gnc_commodity *base_cmdty = NULL; + txnCreditDebitSums *tcds; + Split *s = (Split*)splitList->data; + + tcds = (txnCreditDebitSums*)g_hash_table_lookup (sd->txns, + (gpointer)txn); + if (sd->tcds == NULL) + { + sd->tcds = tcds_new (); + g_hash_table_insert (sd->txns, (gpointer)txn, (gpointer)(sd->tcds)); + } + + if (!gnc_sxed_split_check_account (sd->sxed, s, base_cmdty, + &sd->multi_commodity)) + { + gchar *message = g_strdup_printf + (_("Split with memo %s has an invalid account."), + xaccSplitGetMemo (s)); + split_error_warning_dialog (sd->sxed->dialog, + _("Invalid Account in Split"), + message); + g_free (message); + sd->err = TRUE; + return FALSE; + } + + if (!gnc_sxed_split_calculate_formula (sd->sxed, s, sd->vars, + "sx-credit-formula", + sd->tcds)) + { + gchar *message = g_strdup_printf + (_("Split with memo %s has an unparseable Credit Formula."), + xaccSplitGetMemo (s)); + split_error_warning_dialog (sd->sxed->dialog, + _("Unparsable Formula in Split"), + message); + g_free (message); + sd->err = TRUE; + return FALSE; + } + + if (!gnc_sxed_split_calculate_formula (sd->sxed, s, sd->vars, + "sx-debit-formula", + sd->tcds)) + + { + gchar *message = g_strdup_printf + (_("Split with memo %s has an unparseable Debit Formula."), + xaccSplitGetMemo (s)); + split_error_warning_dialog (sd->sxed->dialog, + _("Unparsable Formula in Split"), + message); + g_free (message); + sd->err = TRUE; + return FALSE; + } + } + return TRUE; +} + /******************************************************************************* * Checks to make sure that the SX is in a reasonable state to save. * @return true if checks out okay, false otherwise. @@ -724,6 +820,8 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed ) (GDestroyNotify)gnc_sx_variable_free); GHashTable *txns = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); + CheckTxnSplitData sd = {sxed, txns, vars, NULL, FALSE, FALSE}; + /** * Plan: * . Do a first pass to get the variables. @@ -751,38 +849,16 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed ) for ( i = 0; i < numIters && !unbalanceable; i++ ) { GList *splitList = xaccSchedXactionGetSplits (sxed->sx); + Account *tmpl_acct = gnc_sx_get_template_transaction_account (sxed->sx); gnc_sx_randomize_variables(vars); g_hash_table_foreach( txns, set_sums_to_zero, NULL ); splitCount += g_list_length( splitList ); - for ( ; splitList; splitList = splitList->next ) - { - gnc_commodity *base_cmdty = NULL; - txnCreditDebitSums *tcds; - Split *s = (Split*)splitList->data; - Transaction *t = xaccSplitGetParent (s); + xaccAccountForEachTransaction(tmpl_acct, check_transaction_splits, &sd); - tcds = (txnCreditDebitSums*)g_hash_table_lookup (txns, (gpointer)t); - if (tcds == NULL) - { - tcds = tcds_new (); - g_hash_table_insert (txns, (gpointer)t, (gpointer)tcds); - } - - if (!gnc_sxed_split_check_account (sxed, s, base_cmdty, - &multi_commodity)) - return FALSE; - - if (!gnc_sxed_split_calculate_formula (sxed, s, vars, - "sx-credit-formula", - tcds)) - return FALSE; - if (!gnc_sxed_split_calculate_formula (sxed, s, vars, - "sx-debit-formula", - tcds)) - return FALSE; - } + if (sd.err) + return FALSE; g_hash_table_foreach (txns, check_credit_debit_balance, &unbalanceable); } @@ -807,7 +883,7 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed ) return FALSE; if (!gnc_sxed_check_autocreate (sxed, ttVarCount, - splitCount, multi_commodity)) + splitCount, sd.multi_commodity)) return FALSE; if (!gnc_sxed_check_endpoint (sxed)) @@ -819,7 +895,7 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed ) /****************************************************************************** * Saves the contents of the SX. This assumes that gnc_sxed_check_consistent * has returned true. - *****************************************************************************/ + *****************************************************************************/ static void gnc_sxed_save_sx( GncSxEditorDialog *sxed ) { diff --git a/src/gnome/dialog-sx-since-last-run.c b/src/gnome/dialog-sx-since-last-run.c index 3964e68619..939605b969 100644 --- a/src/gnome/dialog-sx-since-last-run.c +++ b/src/gnome/dialog-sx-since-last-run.c @@ -791,10 +791,42 @@ gnc_sx_slr_tree_model_adapter_new(GncSxInstanceModel *instances) return rtn; } +static void +creation_error_dialog (GList **creation_errors) +{ + GList *node = *creation_errors; + GtkWidget *dialog = NULL; + gchar *message = NULL; + if (*creation_errors == NULL) return; + for(; node != NULL; node = g_list_next (node)) + { + gchar *new_msg = NULL; + if (message == NULL) + new_msg = g_strdup_printf ("%s", (gchar*)(node->data)); + else + new_msg = g_strdup_printf("%s\n%s", message, (gchar*)(node->data)); + g_free (message); + message = new_msg; + g_free(node->data); + } + g_list_free (*creation_errors); + creation_errors = NULL; + dialog = gtk_message_dialog_new (NULL, 0, + GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, + "\t%s\t", _("Invalid Transactions")); + gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), + "%s", message); + g_signal_connect_swapped (dialog, "response", + G_CALLBACK(gtk_widget_destroy), dialog); + gtk_dialog_run (GTK_DIALOG (dialog)); + g_free (message); +} + void gnc_sx_sxsincelast_book_opened(void) { GList *auto_created_txns = NULL; + GList *creation_errors = NULL; GncSxInstanceModel *inst_model; GncSxSummary summary; @@ -810,7 +842,8 @@ gnc_sx_sxsincelast_book_opened(void) inst_model = gnc_sx_get_current_instances(); gnc_sx_instance_model_summarize(inst_model, &summary); gnc_sx_summary_print(&summary); - gnc_sx_instance_model_effect_change(inst_model, TRUE, &auto_created_txns, NULL); + gnc_sx_instance_model_effect_change(inst_model, TRUE, &auto_created_txns, + &creation_errors); if (summary.need_dialog) { @@ -837,6 +870,8 @@ gnc_sx_sxsincelast_book_opened(void) } g_list_free(auto_created_txns); g_object_unref(G_OBJECT(inst_model)); + if (creation_errors) + creation_error_dialog(&creation_errors); } static void @@ -1075,6 +1110,7 @@ dialog_destroy_cb(GtkWidget *object, GncSxSinceLastRunDialog *app_dialog) static void dialog_response_cb(GtkDialog *dialog, gint response_id, GncSxSinceLastRunDialog *app_dialog) { + GList* creation_errors = NULL; switch (response_id) { case GTK_RESPONSE_OK: @@ -1108,8 +1144,11 @@ dialog_response_cb(GtkDialog *dialog, gint response_id, GncSxSinceLastRunDialog } } gnc_suspend_gui_refresh(); - gnc_sx_slr_model_effect_change(app_dialog->editing_model, FALSE, &app_dialog->created_txns, NULL); + gnc_sx_slr_model_effect_change(app_dialog->editing_model, FALSE, &app_dialog->created_txns, &creation_errors); gnc_resume_gui_refresh(); + if (creation_errors) + creation_error_dialog(&creation_errors); + if (gtk_toggle_button_get_active(app_dialog->review_created_txns_toggle) && g_list_length(app_dialog->created_txns) > 0) { diff --git a/src/import-export/CMakeLists.txt b/src/import-export/CMakeLists.txt index 55c7fad3d4..ca1c1e7313 100644 --- a/src/import-export/CMakeLists.txt +++ b/src/import-export/CMakeLists.txt @@ -1,5 +1,7 @@ # CMakeLists.txt for src/import-export +#ADD_SUBDIRECTORY(test) + # ############################################################ IF (WITH_AQBANKING) ADD_SUBDIRECTORY(aqb) diff --git a/src/import-export/csv-imp/CMakeLists.txt b/src/import-export/csv-imp/CMakeLists.txt index dc4298629e..f946e19baa 100644 --- a/src/import-export/csv-imp/CMakeLists.txt +++ b/src/import-export/csv-imp/CMakeLists.txt @@ -1,4 +1,5 @@ ADD_SUBDIRECTORY(gschemas) +#ADD_SUBDIRECTORY(test) SET(csv_import_SOURCES gncmod-csv-import.c diff --git a/src/import-export/csv-imp/test/CMakeLists.txt b/src/import-export/csv-imp/test/CMakeLists.txt new file mode 100644 index 0000000000..6dd3fc3cd8 --- /dev/null +++ b/src/import-export/csv-imp/test/CMakeLists.txt @@ -0,0 +1,22 @@ + +SET(CSV_IMP_TEST_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/engine + ${CMAKE_SOURCE_DIR}/src/test-core + ${CMAKE_SOURCE_DIR}/src/libqof/qof + ${CMAKE_SOURCE_DIR}/lib + ${GLIB2_INCLUDE_DIRS} +) +SET(CSV_IMP_TEST_LIBS gncmod-csv-import gncmod-engine gnc-qof test-core) + +SET(test_csv_imp_SOURCES + test-csv-imp.c + utest-gnc-csv-model.c +) + +GNC_ADD_TEST(test-csv-imp "${test_csv_imp_SOURCES}" + CSV_IMP_TEST_INCLUDE_DIRS CSV_IMP_TEST_LIBS + SRCDIR=${CMAKE_CURRENT_SOURCE_DIR} +) + diff --git a/src/import-export/ofx/CMakeLists.txt b/src/import-export/ofx/CMakeLists.txt index de0d7ed402..0edd5b6b39 100644 --- a/src/import-export/ofx/CMakeLists.txt +++ b/src/import-export/ofx/CMakeLists.txt @@ -1,4 +1,5 @@ ADD_SUBDIRECTORY(gschemas) +#ADD_SUBDIRECTORY(test) SET(ofx_SOURCES gnc-ofx-import.c @@ -38,4 +39,4 @@ INSTALL(FILES ${ofx_UI} DESTINATION share/gnucash/ui) IF (GNC_BUILD_AS_INSTALL) FILE(COPY ${ofx_UI} DESTINATION ${DATADIR_BUILD}/gnucash/ui) -ENDIF() \ No newline at end of file +ENDIF() diff --git a/src/import-export/ofx/test/CMakeLists.txt b/src/import-export/ofx/test/CMakeLists.txt new file mode 100644 index 0000000000..ac817894e6 --- /dev/null +++ b/src/import-export/ofx/test/CMakeLists.txt @@ -0,0 +1,8 @@ + + +SET(OFX_TEST_INCLUDE_DIRS + ${LIBOFX_INCLUDE_DIRS} +) +SET(OFX_TEST_LIBS) + +GNC_ADD_TEST(test-link-ofx test-link.c OFX_TEST_INCLUDE_DIRS OFX_TEST_LIBS) \ No newline at end of file diff --git a/src/import-export/qif-imp/CMakeLists.txt b/src/import-export/qif-imp/CMakeLists.txt index 72055437db..6baeda7734 100644 --- a/src/import-export/qif-imp/CMakeLists.txt +++ b/src/import-export/qif-imp/CMakeLists.txt @@ -1,6 +1,7 @@ # CMakeLists.txt for src/import_export/qif-imp ADD_SUBDIRECTORY(gschemas) +#ADD_SUBDIRECTORY(test) SET (qif_import_SOURCES dialog-account-picker.c @@ -87,4 +88,4 @@ IF (GNC_BUILD_AS_INSTALL) DESTINATION ${DATADIR_BUILD}/gnucash/ui) FILE(COPY ${qif_import_GLADE} DESTINATION ${DATADIR_BUILD}/gnucash/gtkbuilder) -ENDIF() \ No newline at end of file +ENDIF() diff --git a/src/import-export/qif-imp/test/CMakeLists.txt b/src/import-export/qif-imp/test/CMakeLists.txt new file mode 100644 index 0000000000..f502445f3a --- /dev/null +++ b/src/import-export/qif-imp/test/CMakeLists.txt @@ -0,0 +1,6 @@ + + +SET(QIF_IMP_TEST_INCLUDE_DIRS) +SET(QIF_IMP_TEST_LIBS) + +GNC_ADD_TEST(test-link-qif-imp test-link.c QIF_IMP_TEST_INCLUDE_DIRS QIF_IMP_TEST_LIBS) diff --git a/src/import-export/qif/CMakeLists.txt b/src/import-export/qif/CMakeLists.txt index 0bb858a8b1..94114e3b20 100644 --- a/src/import-export/qif/CMakeLists.txt +++ b/src/import-export/qif/CMakeLists.txt @@ -1,4 +1,7 @@ +#Tests for this directory are not run. +##ADD_SUBDIRECTORY(test) + SET(qif_SOURCES qif-context.c qif-defaults.c diff --git a/src/import-export/qif/test/CMakeLists.txt b/src/import-export/qif/test/CMakeLists.txt new file mode 100644 index 0000000000..659f987636 --- /dev/null +++ b/src/import-export/qif/test/CMakeLists.txt @@ -0,0 +1,13 @@ + +SET(QIF_TEST_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src + ${CMAKE_SOURCE_DIR}/src/import-export/qif + ${CMAKE_SOURCE_DIR}/src/libqof/qof + ${CMAKE_SOURCE_DIR}/src/test-core + ${GLIB2_INCLUDE_DIRS} +) +SET(QIF_TEST_LIBS gncmod-qif test-core) + +GNC_ADD_TEST(test-link-qif test-link.c QIF_TEST_INCLUDE_DIRS QIF_TEST_LIBS) +GNC_ADD_TEST(test-qif test-qif.c QIF_TEST_INCLUDE_DIRS QIF_TEST_LIBS + GNC_TEST_FILES=${CMAKE_CURRENT_SOURCE_DIR}/test-files) \ No newline at end of file diff --git a/src/import-export/test/CMakeLists.txt b/src/import-export/test/CMakeLists.txt new file mode 100644 index 0000000000..5e7ffae9f0 --- /dev/null +++ b/src/import-export/test/CMakeLists.txt @@ -0,0 +1,19 @@ + + +SET(GENERIC_IMPORT_TEST_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${CMAKE_SOURCE_DIR}/src/import-export + ${CMAKE_SOURCE_DIR}/src/libqof/qof + ${CMAKE_SOURCE_DIR}/src/test-core + ${GLIB2_INCLUDE_DIRS} + ${GUILE_INCLUDE_DIRS} +) +SET(GENERIC_IMPORT_TEST_LIBS gncmod-generic-import gnc-qof test-core) + +GNC_ADD_TEST_WITH_GUILE(test-import-parse test-import-parse.c + GENERIC_IMPORT_TEST_INCLUDE_DIRS GENERIC_IMPORT_TEST_LIBS +) +GNC_ADD_TEST(test-link-generic-import test-link.c + GENERIC_IMPORT_TEST_INCLUDE_DIRS GENERIC_IMPORT_TEST_LIBS +) diff --git a/src/libqof/CMakeLists.txt b/src/libqof/CMakeLists.txt index 88afdc2218..100a9a94af 100644 --- a/src/libqof/CMakeLists.txt +++ b/src/libqof/CMakeLists.txt @@ -1,5 +1,7 @@ # CMakeLists.txt for src/libqof +#ADD_SUBDIRECTORY(qof/test) + SET (gnc_qof_HEADERS qof/gnc-aqbanking-templates.h qof/gnc-date-p.h diff --git a/src/libqof/qof/test/CMakeLists.txt b/src/libqof/qof/test/CMakeLists.txt new file mode 100644 index 0000000000..61fdc68efc --- /dev/null +++ b/src/libqof/qof/test/CMakeLists.txt @@ -0,0 +1,26 @@ + +SET(TEST_QOF_INCLUDE_DIRS + ${CMAKE_BINARY_DIR}/src # for config.h + ${CMAKE_SOURCE_DIR}/src/test-core # for unittest-support.h + ${CMAKE_SOURCE_DIR}/src/libqof/qof # for qof.h + ${GLIB2_INCLUDE_DIRS} +) + +SET(TEST_QOF_LIBS + gnc-qof test-core ${GLIB2_LDFLAGS} -lm +) + +SET(test_qof_SOURCES + test-gnc-date.c + test-qof.c + test-qofbook.c + test-qofinstance.c + test-kvp_frame.c + test-qofobject.c + test-qofsession.c + test-qof-string-cache.c + ${CMAKE_SOURCE_DIR}/src/test-core/unittest-support.c +) + +GNC_ADD_TEST(test-qof "${test_qof_SOURCES}" TEST_QOF_INCLUDE_DIRS TEST_QOF_LIBS) +TARGET_COMPILE_DEFINITIONS(test-qof PRIVATE TESTPROG=test_qof) diff --git a/src/register/ledger-core/CMakeLists.txt b/src/register/ledger-core/CMakeLists.txt index 09b3fbce5b..f72dd7825a 100644 --- a/src/register/ledger-core/CMakeLists.txt +++ b/src/register/ledger-core/CMakeLists.txt @@ -1,4 +1,5 @@ +#ADD_SUBDIRECTORY(test) SET (ledger_core_SOURCES gnc-ledger-display.c @@ -40,4 +41,4 @@ INSTALL(TARGETS gncmod-ledger-core LIBRARY DESTINATION lib/gnucash ARCHIVE DESTINATION lib/gnucash RUNTIME DESTINATION bin) -# No headers to install \ No newline at end of file +# No headers to install diff --git a/src/register/ledger-core/test/CMakeLists.txt b/src/register/ledger-core/test/CMakeLists.txt new file mode 100644 index 0000000000..1ec9b9222a --- /dev/null +++ b/src/register/ledger-core/test/CMakeLists.txt @@ -0,0 +1,7 @@ + +SET(LEDGER_CORE_TEST_INCLUDE_DIRS "") +SET(LEDGER_CORE_TEST_LIBS) + +GNC_ADD_TEST(test-link-module-ledger-core test-link-module.c + LEDGER_CORE_TEST_INCLUDE_DIRS LEDGER_CORE_TEST_LIBS +) \ No newline at end of file diff --git a/src/register/register-core/CMakeLists.txt b/src/register/register-core/CMakeLists.txt index c5ab961b4e..0407a1f78f 100644 --- a/src/register/register-core/CMakeLists.txt +++ b/src/register/register-core/CMakeLists.txt @@ -1,4 +1,4 @@ - +#ADD_SUBDIRECTORY(test) SET (register_core_SOURCES gncmod-register-core.c @@ -56,4 +56,4 @@ INSTALL(TARGETS gncmod-register-core ARCHIVE DESTINATION lib/gnucash RUNTIME DESTINATION bin) -INSTALL(FILES ${register_core_HEADERS} DESTINATION include/gnucash) \ No newline at end of file +INSTALL(FILES ${register_core_HEADERS} DESTINATION include/gnucash) diff --git a/src/register/register-core/test/CMakeLists.txt b/src/register/register-core/test/CMakeLists.txt new file mode 100644 index 0000000000..4bf1f051ba --- /dev/null +++ b/src/register/register-core/test/CMakeLists.txt @@ -0,0 +1,7 @@ + +SET(REGISTER_CORE_TEST_INCLUDE_DIRS "") +SET(REGISTER_CORE_TEST_LIBS) + +GNC_ADD_TEST(test-link-module-register-core test-link-module.c + REGISTER_CORE_TEST_INCLUDE_DIRS REGISTER_CORE_TEST_LIBS +) \ No newline at end of file diff --git a/src/register/register-gnome/CMakeLists.txt b/src/register/register-gnome/CMakeLists.txt index 9f0a5dbb5f..f3fe444419 100644 --- a/src/register/register-gnome/CMakeLists.txt +++ b/src/register/register-gnome/CMakeLists.txt @@ -1,3 +1,4 @@ +#ADD_SUBDIRECTORY(test) SET (register_gnome_SOURCES gncmod-register-gnome.c @@ -55,4 +56,4 @@ INSTALL(TARGETS gncmod-register-gnome LIBRARY DESTINATION lib/gnucash ARCHIVE DESTINATION lib/gnucash RUNTIME DESTINATION bin) -# No headers to install \ No newline at end of file +# No headers to install diff --git a/src/register/register-gnome/test/CMakeLists.txt b/src/register/register-gnome/test/CMakeLists.txt new file mode 100644 index 0000000000..38251b87a6 --- /dev/null +++ b/src/register/register-gnome/test/CMakeLists.txt @@ -0,0 +1,7 @@ + +SET(REGISTER_GNOME_TEST_INCLUDE_DIRS "") +SET(REGISTER_GNOME_TEST_LIBS) + +GNC_ADD_TEST(test-link-module-register-gnome test-link-module.c +REGISTER_GNOME_TEST_INCLUDE_DIRS REGISTER_GNOME_TEST_LIBS +) \ No newline at end of file diff --git a/src/report/locale-specific/us/CMakeLists.txt b/src/report/locale-specific/us/CMakeLists.txt index 1945079665..c0da9719c1 100644 --- a/src/report/locale-specific/us/CMakeLists.txt +++ b/src/report/locale-specific/us/CMakeLists.txt @@ -1,4 +1,4 @@ - +#ADD_SUBDIRECTORY(test) SET(locale_reports_us_SOURCES gncmod-locale-reports-us.c @@ -51,4 +51,4 @@ GNC_ADD_SCHEME_TARGETS(scm-report-locale-specific-2 "${GUILE_LIBRARY_DIRS}" "scm-report-locale-specific-1;${GUILE_DEPENDS}" FALSE -) \ No newline at end of file +) diff --git a/src/report/locale-specific/us/test/CMakeLists.txt b/src/report/locale-specific/us/test/CMakeLists.txt new file mode 100644 index 0000000000..72cab04e22 --- /dev/null +++ b/src/report/locale-specific/us/test/CMakeLists.txt @@ -0,0 +1,11 @@ +SET(LOCALE_SPECIFIC_US_TEST_INCLUDE_DIRS "") +SET(LOCALE_SPECIFIC_US_TEST_LIBS) + +GNC_ADD_TEST(test-link-module-report-locale-specific-us test-link-module.c + LOCALE_SPECIFIC_US_TEST_INCLUDE_DIRS LOCALE_SPECIFIC_US_TEST_LIBS +) + +# This test not run in the autotools build. +#GNC_ADD_SCHEME_TEST(test-load-module-report-locale-specific-us +# test-load-module.in +#) \ No newline at end of file diff --git a/src/report/report-gnome/CMakeLists.txt b/src/report/report-gnome/CMakeLists.txt index 8df635eeeb..94ef5479b1 100644 --- a/src/report/report-gnome/CMakeLists.txt +++ b/src/report/report-gnome/CMakeLists.txt @@ -1,4 +1,4 @@ - +#ADD_SUBDIRECTORY(test) SET (report_gnome_HEADERS dialog-report-column-view.h @@ -74,4 +74,4 @@ IF (GNC_BUILD_AS_INSTALL) DESTINATION ${DATADIR_BUILD}/gnucash/ui) FILE(COPY ${report_gnome_GLADE} DESTINATION ${DATADIR_BUILD}/gnucash/gtkbuilder) -ENDIF() \ No newline at end of file +ENDIF() diff --git a/src/report/report-gnome/test/CMakeLists.txt b/src/report/report-gnome/test/CMakeLists.txt new file mode 100644 index 0000000000..29f7dd0a3e --- /dev/null +++ b/src/report/report-gnome/test/CMakeLists.txt @@ -0,0 +1,14 @@ +SET(REPORT_GNOME_TEST_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${GUILE_INCLUDE_DIRS} + +) +SET(REPORT_GNOME_TEST_LIBS gnc-module) + +GNC_ADD_TEST_WITH_GUILE(test-link-module-report-gnome test-link-module.c + REPORT_GNOME_TEST_INCLUDE_DIRS REPORT_GNOME_TEST_LIBS +) + +GNC_ADD_SCHEME_TEST(test-load-module-report-gnome + test-load-module.in +) \ No newline at end of file diff --git a/src/report/report-system/CMakeLists.txt b/src/report/report-system/CMakeLists.txt index 33db0fde86..1c4b314e15 100644 --- a/src/report/report-system/CMakeLists.txt +++ b/src/report/report-system/CMakeLists.txt @@ -1,3 +1,4 @@ +#ADD_SUBDIRECTORY(test) SET (report_system_HEADERS gnc-report.h diff --git a/src/report/report-system/test/CMakeLists.txt b/src/report/report-system/test/CMakeLists.txt new file mode 100644 index 0000000000..f04e7c79bc --- /dev/null +++ b/src/report/report-system/test/CMakeLists.txt @@ -0,0 +1,26 @@ +SET(REPORT_SYSTEM_TEST_INCLUDE_DIRS + ${CMAKE_SOURCE_DIR}/src/gnc-module + ${GUILE_INCLUDE_DIRS} +) +SET(REPORT_SYSTEM_TEST_LIBS gnc-module) + +GNC_ADD_TEST_WITH_GUILE(test-link-module-report-system test-link-module.c + REPORT_SYSTEM_TEST_INCLUDE_DIRS REPORT_SYSTEM_TEST_LIBS +) + +GNC_ADD_SCHEME_TEST(test-load-module-report-system test-load-module.in) +GNC_ADD_SCHEME_TEST(test-collectors test-collectors.scm) +GNC_ADD_SCHEME_TEST(test-list-extras test-list-extras.scm) +GNC_ADD_SCHEME_TEST(test-report-utilities test-report-utilities.scm) +# This test is not run in the autotools build. +#GNC_ADD_SCHEME_TEST(test-test-extras test-test-extras.scm) + +GNC_ADD_SCHEME_TARGETS(scm-test-report-system + test-extras.scm + gnucash/report/report-system/test + "" + "" + "" + "scm-gnc-module;scm-test-engine;scm-report-system-3" + FALSE +) \ No newline at end of file diff --git a/src/report/standard-reports/CMakeLists.txt b/src/report/standard-reports/CMakeLists.txt index 53bb1cda35..8a35848cfc 100644 --- a/src/report/standard-reports/CMakeLists.txt +++ b/src/report/standard-reports/CMakeLists.txt @@ -1,4 +1,6 @@ +#ADD_SUBDIRECTORY(test) + SET(standard_reports_SOURCES gncmod-standard-reports.c) ADD_LIBRARY (gncmod-standard-reports ${standard_reports_SOURCES}) @@ -81,4 +83,4 @@ FILE(MAKE_DIRECTORY ${STD_RPT_DIR}) FILE(COPY standard-reports.scm DESTINATION ${STD_RPT_DIR}) FILE(MAKE_DIRECTORY ${STD_RPT_DIR}/standard-reports) -FILE(COPY ${standard_reports_SCHEME_2} DESTINATION ${STD_RPT_DIR}/standard-reports) \ No newline at end of file +FILE(COPY ${standard_reports_SCHEME_2} DESTINATION ${STD_RPT_DIR}/standard-reports) diff --git a/src/report/standard-reports/test/CMakeLists.txt b/src/report/standard-reports/test/CMakeLists.txt new file mode 100644 index 0000000000..d7541764f4 --- /dev/null +++ b/src/report/standard-reports/test/CMakeLists.txt @@ -0,0 +1,22 @@ + +GNC_ADD_SCHEME_TEST(test-cash-flow test-cash-flow.scm) +GNC_ADD_SCHEME_TEST(test-standard-category-report test-standard-category-report.scm) +GNC_ADD_SCHEME_TEST(test-standard-net-barchart test-standard-net-barchart.scm) +GNC_ADD_SCHEME_TEST(test-standard-net-linechart test-standard-net-linechart.scm) +GNC_ADD_SCHEME_TEST(test-load-module-report-standard-reports test-load-module.in) + +SET(scm_test_standard_reports_SOURCES + test-generic-category-report.scm + test-generic-net-barchart.scm + test-generic-net-linechart.scm +) + +GNC_ADD_SCHEME_TARGETS(scm-test-standard-reports + "${scm_test_standard_reports_SOURCES}" + gnucash/report/standard-reports/test + "" + "" + "" + "scm-gnc-module;scm-test-report-system" + FALSE +) \ No newline at end of file diff --git a/src/report/stylesheets/CMakeLists.txt b/src/report/stylesheets/CMakeLists.txt index acb58a34cb..5ceba71b0c 100644 --- a/src/report/stylesheets/CMakeLists.txt +++ b/src/report/stylesheets/CMakeLists.txt @@ -1,3 +1,4 @@ +#ADD_SUBDIRECTORY(test) SET(stylesheets_SOURCES gnc-plugin-stylesheets.c diff --git a/src/report/stylesheets/test/CMakeLists.txt b/src/report/stylesheets/test/CMakeLists.txt new file mode 100644 index 0000000000..89b5db4ad2 --- /dev/null +++ b/src/report/stylesheets/test/CMakeLists.txt @@ -0,0 +1,4 @@ + +GNC_ADD_SCHEME_TEST(test-load-module-report-stylesheets + test-load-module.in +) \ No newline at end of file diff --git a/src/report/utility-reports/CMakeLists.txt b/src/report/utility-reports/CMakeLists.txt index c0110c47fa..66c73ca04a 100644 --- a/src/report/utility-reports/CMakeLists.txt +++ b/src/report/utility-reports/CMakeLists.txt @@ -1,4 +1,4 @@ - +#ADD_SUBDIRECTORY(test) SET(utility_reports_SOURCES gncmod-utility-reports.c diff --git a/src/report/utility-reports/test/CMakeLists.txt b/src/report/utility-reports/test/CMakeLists.txt new file mode 100644 index 0000000000..540abb9dd7 --- /dev/null +++ b/src/report/utility-reports/test/CMakeLists.txt @@ -0,0 +1,4 @@ + +GNC_ADD_SCHEME_TEST(test-load-module-report-utility-reports + test-load-module.in +) \ No newline at end of file diff --git a/src/tax/us/CMakeLists.txt b/src/tax/us/CMakeLists.txt index 0424b7837e..514a9ae794 100644 --- a/src/tax/us/CMakeLists.txt +++ b/src/tax/us/CMakeLists.txt @@ -1,3 +1,5 @@ +#ADD_SUBDIRECTORY(test) + SET(tax_us_SOURCES gncmod-tax-us.c) # Add dependency on config.h diff --git a/src/tax/us/test/CMakeLists.txt b/src/tax/us/test/CMakeLists.txt new file mode 100644 index 0000000000..60fe2c71f1 --- /dev/null +++ b/src/tax/us/test/CMakeLists.txt @@ -0,0 +1,9 @@ +SET(TAX_US_TEST_INCLUDE_DIRS "") +SET(TAX_US_TEST_LIBS "") + +GNC_ADD_TEST(test-link-module-tax-us test-link-module.c + TAX_US_TEST_INCLUDE_DIRS TAX_US_TEST_LIBS +) + +# This test not run in autotools build. +#GNC_ADD_SCHEME_TEST(test-load-module-tax-us test-load-module.in) diff --git a/src/test-core/CMakeLists.txt b/src/test-core/CMakeLists.txt index 63177b6be2..d6aca03a29 100644 --- a/src/test-core/CMakeLists.txt +++ b/src/test-core/CMakeLists.txt @@ -1,4 +1,3 @@ - SET(test_core_SOURCES test-stuff.c unittest-support.c @@ -19,8 +18,11 @@ INCLUDE_DIRECTORIES( ${GUILE_INCLUDE_DIRS} ) -ADD_LIBRARY(test-core ${test_core_SOURCES} ${test_core_noinst_HEADERS}) -TARGET_LINK_LIBRARIES(test-core gnc-qof ${GLIB2_LDFLAGS}) +ADD_LIBRARY(test-core STATIC ${test_core_SOURCES} ${test_core_noinst_HEADERS}) +TARGET_LINK_LIBRARIES(test-core gncmod-engine gnc-qof ${GLIB2_LDFLAGS}) +IF (UNIX) + TARGET_COMPILE_OPTIONS(test-core PRIVATE -fPIC) +ENDIF() SET (SWIG_UNITTEST_SUPPORT_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-guile.c) GNC_ADD_SWIG_COMMAND (${SWIG_UNITTEST_SUPPORT_GUILE_C} @@ -41,7 +43,7 @@ SET(GUILE_LIBRARY_DIRS src/test-core src/libqof) SET(GUILE_DEPENDS test-core-guile) -GNC_ADD_SCHEME_TARGETS(scm_test_core +GNC_ADD_SCHEME_TARGETS(scm-test-core ${test_core_SCHEME} ${GUILE_OUTPUT_DIR} "${GUILE_MODULES}" @@ -51,4 +53,4 @@ GNC_ADD_SCHEME_TARGETS(scm_test_core FALSE ) -INSTALL(FILES unittest-support.h DESTINATION libexec/gnucash/src/libqof/qof/test) \ No newline at end of file +INSTALL(FILES unittest-support.h DESTINATION libexec/gnucash/src/libqof/qof/test)