mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
gnc-module - move most of scm tests to bindings/guile
This is a first rudimentary separation of gnc-module tests based on whether they require guile or not. Needs plenty of refinement which will be applied in followup commits.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# C(++) tests requiring a proper guile environment set up
|
||||
|
||||
add_subdirectory(mod-foo)
|
||||
add_subdirectory(mod-bar)
|
||||
add_subdirectory(mod-baz)
|
||||
|
||||
set(ENGINE_TEST_INCLUDE_DIRS
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/backend/xml
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/engine
|
||||
@@ -112,6 +116,44 @@ if (HAVE_SRFI64)
|
||||
endif (HAVE_SRFI64)
|
||||
|
||||
|
||||
set (test_gnc_module_SCHEME
|
||||
test-gnc-module-scm-init.scm
|
||||
test-gnc-module-load-scm.scm
|
||||
test-gnc-module-swigged-c.scm
|
||||
test-gnc-module-load-deps.scm
|
||||
test-gnc-module-scm-dynload.scm
|
||||
test-gnc-module-scm-module.scm
|
||||
test-gnc-module-scm-multi.scm
|
||||
)
|
||||
|
||||
set (test_gnc_module_DEPENDS
|
||||
scm-gnc-module
|
||||
scm-test-core
|
||||
scm-mod-foo
|
||||
gncmod-bar
|
||||
scm-mod-baz
|
||||
gncmod-agedver
|
||||
gncmod-incompatdep
|
||||
gncmod-futuremodsys
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets (test-gnc-modules-scm
|
||||
"${test_gnc_module_SCHEME}"
|
||||
"tests"
|
||||
"${test_gnc_module_DEPENDS}"
|
||||
TRUE
|
||||
)
|
||||
gnc_add_scheme_tests ("${test_gnc_module_SCHEME}")
|
||||
if(NOT WIN32)
|
||||
# This little dance is needed because gnc_module_init will assert if
|
||||
# it finds libgncmod-futuremod.so outside of a test that expects it.
|
||||
get_guile_env()
|
||||
set(_GNC_MODULE_PATH "${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:${LIBDIR_BUILD}/gnucash/test")
|
||||
foreach(test_file ${test_gnc_module_SCHEME})
|
||||
get_filename_component(basename ${test_file} NAME_WE)
|
||||
set_tests_properties(${basename} PROPERTIES ENVIRONMENT "${GUILE_ENV};GNC_MODULE_PATH=${_GNC_MODULE_PATH}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(test_engine_SCHEME_DIST
|
||||
srfi64-extras.scm
|
||||
@@ -121,12 +163,20 @@ set(test_engine_SCHEME_DIST
|
||||
test-business-core.scm
|
||||
)
|
||||
|
||||
set_dist_list(test_guile_DIST
|
||||
set_local_dist(test_guile_DIST_local
|
||||
CMakeLists.txt
|
||||
test-scm-query.cpp
|
||||
${test_engine_SCHEME_DIST}
|
||||
${test_gnc_module_SCHEME}
|
||||
${test_scm_SCHEME}
|
||||
)
|
||||
set(test_guile_DIST
|
||||
${test_guile_DIST_local}
|
||||
${mod_bar_DIST}
|
||||
${mod_baz_DIST}
|
||||
${mod_foo_DIST}
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
# Define two imaginary deprecated guile modules to test the compat file generation code
|
||||
gnc_add_scheme_deprecated_module ("gnucash deprecated-module" "" "" "")
|
||||
|
@@ -6,7 +6,7 @@ gnc_add_swig_guile_command (swig-baz-c
|
||||
|
||||
add_library(baz EXCLUDE_FROM_ALL baz.c baz.h)
|
||||
target_include_directories(baz PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module/test/mod-foo
|
||||
${CMAKE_SOURCE_DIR}/bindings/guile/test/mod-foo
|
||||
)
|
||||
target_link_libraries(baz foo)
|
||||
|
@@ -1,7 +1,4 @@
|
||||
|
||||
add_subdirectory(mod-foo)
|
||||
add_subdirectory(mod-bar)
|
||||
add_subdirectory(mod-baz)
|
||||
add_subdirectory(misc-mods)
|
||||
|
||||
set(GNC_MODULE_TEST_INCLUDE_DIRS
|
||||
@@ -21,6 +18,7 @@ set(GNC_MODULE_TEST_LIBS
|
||||
gncmod-agedver
|
||||
gncmod-futuremodsys
|
||||
gncmod-incompatdep
|
||||
gncmod-ordinarymod
|
||||
)
|
||||
|
||||
gnc_add_test_with_guile(test-load-c test-load-c.c GNC_MODULE_TEST_INCLUDE_DIRS GNC_MODULE_TEST_LIBS "GNC_MODULE_PATH=${LIBDIR_BUILD}/gnucash/test")
|
||||
@@ -45,46 +43,6 @@ gnc_add_test(test-dynload test-dynload.c
|
||||
LIBDIR=${_LIBDIR}
|
||||
)
|
||||
|
||||
set(test_gnc_module_SCHEME
|
||||
test-gnc-module-scm-init.scm
|
||||
test-gnc-module-load-scm.scm
|
||||
test-gnc-module-swigged-c.scm
|
||||
test-gnc-module-load-deps.scm
|
||||
test-gnc-module-scm-dynload.scm
|
||||
test-gnc-module-scm-module.scm
|
||||
test-gnc-module-scm-multi.scm
|
||||
)
|
||||
|
||||
set(CORE_GUILE_DEPENDS
|
||||
scm-gnc-module
|
||||
scm-test-core
|
||||
scm-mod-foo
|
||||
gncmod-bar
|
||||
scm-mod-baz
|
||||
gncmod-agedver
|
||||
gncmod-incompatdep
|
||||
gncmod-futuremodsys
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(test-gnc-modules-scm
|
||||
"${test_gnc_module_SCHEME}"
|
||||
"tests"
|
||||
"${CORE_GUILE_DEPENDS}"
|
||||
TRUE
|
||||
)
|
||||
|
||||
gnc_add_scheme_tests("${test_gnc_module_SCHEME}")
|
||||
if(NOT WIN32)
|
||||
# This little dance is needed because gnc_module_init will assert if
|
||||
# it finds libgncmod-futuremod.so outside of a test that expects it.
|
||||
get_guile_env()
|
||||
set(_GNC_MODULE_PATH "${LIBDIR_BUILD}:${LIBDIR_BUILD}/gnucash:${LIBDIR_BUILD}/gnucash/test")
|
||||
foreach(test_file ${test_gnc_module_SCHEME})
|
||||
get_filename_component(basename ${test_file} NAME_WE)
|
||||
set_tests_properties(${basename} PROPERTIES ENVIRONMENT "${GUILE_ENV};GNC_MODULE_PATH=${_GNC_MODULE_PATH}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(test_gnc_module_SOURCE_DIST
|
||||
test-agedver.c
|
||||
test-dynload.c
|
||||
@@ -95,7 +53,6 @@ set(test_gnc_module_SOURCE_DIST
|
||||
|
||||
set(test_gnc_module_EXTRA_DIST
|
||||
README
|
||||
${test_gnc_module_SCHEME}
|
||||
)
|
||||
|
||||
set_local_dist(test_gnc_module_DIST_local CMakeLists.txt README ${test_gnc_module_SOURCE_DIST} ${test_gnc_module_EXTRA_DIST})
|
||||
|
@@ -13,9 +13,12 @@ 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})
|
||||
|
||||
set_target_properties(gncmod-agedver gncmod-futuremodsys gncmod-incompatdep PROPERTIES
|
||||
add_library(gncmod-ordinarymod EXCLUDE_FROM_ALL ordinarymod.c)
|
||||
target_link_libraries(gncmod-ordinarymod gnc-module ${GLIB2_LDFLAGS})
|
||||
|
||||
set_target_properties(gncmod-agedver gncmod-futuremodsys gncmod-incompatdep gncmod-ordinarymod PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
set_dist_list(misc_mods_DIST CMakeLists.txt agedver.c futuremodsys.c incompatdep.c)
|
||||
set_dist_list(misc_mods_DIST CMakeLists.txt agedver.c futuremodsys.c incompatdep.c ordinarymod.c)
|
||||
|
@@ -51,7 +51,7 @@ libgncmod_incompatdep_gnc_module_description(void)
|
||||
int
|
||||
libgncmod_incompatdep_gnc_module_init(int refcount)
|
||||
{
|
||||
if (gnc_module_load("gnucash/foo", 25))
|
||||
if (gnc_module_load("gnucash/ordinarymod", 25))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
59
libgnucash/gnc-module/test/misc-mods/ordinarymod.c
Normal file
59
libgnucash/gnc-module/test/misc-mods/ordinarymod.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ordinarymod.c : ordinary module */
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmod_ordinarymod)
|
||||
|
||||
int libgncmod_ordinarymod_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_ordinarymod_gnc_module_current = 0;
|
||||
int libgncmod_ordinarymod_gnc_module_age = 0;
|
||||
int libgncmod_ordinarymod_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_ordinarymod_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/ordinarymod");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_ordinarymod_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a very ordinary module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_ordinarymod_gnc_module_init(int refcount)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_ordinarymod_gnc_module_end(int refcount)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
@@ -29,7 +29,7 @@
|
||||
static void
|
||||
guile_main(void *closure, int argc, char ** argv)
|
||||
{
|
||||
GNCModule foo;
|
||||
GNCModule ordinarymod;
|
||||
gchar *msg = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod-futuremodsys.so' requires newer module system\n";
|
||||
gchar *logdomain = "gnc.module";
|
||||
guint loglevel = G_LOG_LEVEL_WARNING;
|
||||
@@ -41,17 +41,17 @@ guile_main(void *closure, int argc, char ** argv)
|
||||
|
||||
gnc_module_system_init();
|
||||
|
||||
foo = gnc_module_load("gnucash/foo", 0);
|
||||
ordinarymod = gnc_module_load("gnucash/ordinarymod", 0);
|
||||
|
||||
if (!foo)
|
||||
if (!ordinarymod)
|
||||
{
|
||||
g_test_message(" Failed to load foo\n");
|
||||
g_test_message(" Failed to load ordinarymod\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!gnc_module_unload(foo))
|
||||
if (!gnc_module_unload(ordinarymod))
|
||||
{
|
||||
g_test_message(" Failed to unload foo\n");
|
||||
g_test_message(" Failed to unload ordinarymod\n");
|
||||
exit(-1);
|
||||
}
|
||||
g_test_message(" successful.\n");
|
||||
|
Reference in New Issue
Block a user