diff --git a/CMakeLists.txt b/CMakeLists.txt index bac8b0e879..13632ae99a 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,6 +389,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) @@ -441,7 +470,9 @@ SET(gnucash_DOCS INSTALL(FILES ${gnucash_DOCS} DESTINATION share/doc/gnucash) -# Link COPYING to LICENSE +#Link LICENSE to COPYING so that people expecting to find it, +#will. COPYING is normally linked by autogen.sh to the latest +#automake-provided version. SET (_CMD create_symlink) IF (WIN32) SET(_CMD copy) 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/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..62b7cf94f4 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 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/backend/dbi/CMakeLists.txt b/src/backend/dbi/CMakeLists.txt index ef3cc86b2c..de96c05630 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 644d1656b0..077ed90c3f 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.c 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 3125f77fb8..4df0cef153 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/bin/CMakeLists.txt b/src/bin/CMakeLists.txt index 98e3c2a490..bf109c5195 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..c5af60ca22 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 051c424c5e..cc4d3039fc 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..0863fd3c2b 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/gnome-utils/CMakeLists.txt b/src/gnome-utils/CMakeLists.txt index 73f6390872..2f353ba269 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) 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/import-export/CMakeLists.txt b/src/import-export/CMakeLists.txt index 4750c449b6..bcfb2cc987 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 940453e4fb..c55f7e3df9 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..4ee34c713f 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 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..05bc16e3bf 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 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..6c9ee11771 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 4b2f1a2905..0928143b48 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-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..6e629df5aa 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 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..bfdae12873 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 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..3c4d222d4a 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 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..2cd1e47379 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 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..9678a3d1b5 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 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..74bffc70e1 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..57f667b3e2 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}) 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 8cf782d27e..585309cfbe 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..b8857f2d9e 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..fe4eec739c 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..cccaa3a3da 100644 --- a/src/test-core/CMakeLists.txt +++ b/src/test-core/CMakeLists.txt @@ -19,8 +19,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 +44,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 +54,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)