gnc-module test updates

- move test modules into a subdirectory on Windows as well
- move the futuremod module into its own subdirectory
  to avoid its load warnings each time gnc_module_init is called
  That also tends to happen when building guile modules.
- remove the log handlers filtering out the futuremodsys warnings
  They didn't match the actual warning signature anyway and
  they're no longer emitted during testing
This commit is contained in:
Geert Janssens 2019-11-21 16:55:17 +01:00
parent 8aed43ec55
commit 043c6367a5
18 changed files with 24 additions and 97 deletions

View File

@ -132,9 +132,6 @@ set (test_gnc_module_DEPENDS
scm-mod-foo
gncmod-bar
scm-mod-baz
gncmod-agedver
gncmod-incompatdep
gncmod-futuremodsys
)
gnc_add_scheme_test_targets (test-gnc-modules-scm

View File

@ -29,7 +29,7 @@ gnc_add_scheme_test_targets(scm-mod-bar
set_target_properties(bar gncmod-bar PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test
)
set_dist_list(mod_bar_DIST CMakeLists.txt bar.c gnucash/bar.scm bar.h bar.i gnc-mod-bar.c)

View File

@ -35,6 +35,6 @@ gnc_add_scheme_test_targets(scm-mod-baz
set_target_properties(baz gncmod-baz PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test)
set_dist_list(mod_baz_DIST CMakeLists.txt baz.c gnucash/baz.scm baz.h baz.i gnc-mod-baz.c)

View File

@ -29,6 +29,6 @@ gnc_add_scheme_test_targets(scm-mod-foo
set_target_properties(foo gncmod-foo PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test)
set_dist_list(mod_foo_DIST CMakeLists.txt foo.i gnucash/foo.scm foo.c foo.h gnc-mod-foo.c)

View File

@ -1,12 +1,3 @@
(use-modules (tests unittest-support))
(define log-domain "gnc.module")
(define check (new-TestErrorStruct))
(define log-level (G-LOG-LEVEL-WARNING))
(define msg "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
(TestErrorStruct-log-domain-set check log-domain)
(TestErrorStruct-log-level-set check log-level)
(TestErrorStruct-msg-set check msg)
(define handler (test-set-checked-handler log-domain log-level check))
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
@ -17,6 +8,4 @@
(baz:scheme-hello)
(foo:scheme-hello)
(g-log-remove-handler log-domain handler)
(exit 0)

View File

@ -1,14 +1,6 @@
(use-modules (tests unittest-support))
(define log-domain "gnc.module")
(define check (new-TestErrorStruct))
(define log-level (G-LOG-LEVEL-WARNING))
(define msg "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
(TestErrorStruct-log-domain-set check log-domain)
(TestErrorStruct-log-level-set check log-level)
(TestErrorStruct-msg-set check msg)
(define handler (test-set-checked-handler log-domain log-level check))
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(gnc:module-load "gnucash/foo" 0)
(g-log-remove-handler log-domain handler)
(exit 0)

View File

@ -1,15 +1,5 @@
(use-modules (tests unittest-support))
(define log-domain "gnc.module")
(define check (new-TestErrorStruct))
(define log-level (G-LOG-LEVEL-WARNING))
(define msg "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
(TestErrorStruct-log-domain-set check log-domain)
(TestErrorStruct-log-level-set check log-level)
(TestErrorStruct-msg-set check msg)
(define handler (test-set-checked-handler log-domain log-level check))
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(g-log-remove-handler log-domain handler)
(exit 0)

View File

@ -1,14 +1,6 @@
(use-modules (tests unittest-support))
(define log-domain "gnc.module")
(define check (new-TestErrorStruct))
(define log-level (G-LOG-LEVEL-WARNING))
(define msg "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
(TestErrorStruct-log-domain-set check log-domain)
(TestErrorStruct-log-level-set check log-level)
(TestErrorStruct-msg-set check msg)
(define handler (test-set-checked-handler log-domain log-level check))
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(if (not (gnc:module-load "gnucash/foo" 0)) (exit -1))
(exit (foo:scheme-hello))
(g-log-remove-handler log-domain handler)

View File

@ -1,23 +1,14 @@
(use-modules (tests unittest-support))
(define log-domain "gnc.module")
(define check (new-TestErrorStruct))
(define log-level (G-LOG-LEVEL-WARNING))
(define msg "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
(TestErrorStruct-log-domain-set check log-domain)
(TestErrorStruct-log-level-set check log-level)
(TestErrorStruct-msg-set check msg)
(define handler (test-set-checked-handler log-domain log-level check))
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(gnc:module-load "gnucash/foo" 0)
(foo-hello)
(foo:scheme-hello)
(gnc:module-load "gnucash/bar" 0)
(foo-hello)
(foo:scheme-hello)
(bar-hello)
(bar:scheme-hello)
(g-log-remove-handler log-domain handler)
(exit 0)

View File

@ -1,14 +1,5 @@
(use-modules (tests unittest-support))
(define log-domain "gnc.module")
(define check (new-TestErrorStruct))
(define log-level (G-LOG-LEVEL-WARNING))
(define msg "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n")
(TestErrorStruct-log-domain-set check log-domain)
(TestErrorStruct-log-level-set check log-level)
(TestErrorStruct-msg-set check msg)
(define handler (test-set-checked-handler log-domain log-level check))
(use-modules (gnucash gnc-module))
(gnc:module-system-init)
(gnc:module-load "gnucash/foo" 0)
(exit (eq? 10 (foo-hello)))
(g-log-remove-handler log-domain handler)

View File

@ -30,6 +30,7 @@ gnc_add_test(test-modsysver
test-modsysver.c
GNC_MODULE_TEST_INCLUDE_DIRS
GNC_MODULE_TEST_LIBS
"GNC_MODULE_PATH=${LIBDIR_BUILD}/gnucash/test/future"
)
gnc_add_test(test-incompatdep
test-incompatdep.c

View File

@ -13,9 +13,14 @@ 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
set_target_properties(gncmod-agedver gncmod-incompatdep PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test)
set_target_properties(gncmod-futuremodsys PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test/future
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test/future
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test/future)
set_dist_list(misc_mods_DIST CMakeLists.txt agedver.c futuremodsys.c incompatdep.c)

View File

@ -16,6 +16,6 @@ target_include_directories(gncmod-ordinary PRIVATE
set_target_properties(ordinary gncmod-ordinary PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test)
set_dist_list(mod_ordinary_DIST CMakeLists.txt ordinary.c ordinary.h gnc-mod-ordinary.c)

View File

@ -22,6 +22,6 @@ target_include_directories(gncmod-withdep PRIVATE
set_target_properties(withdep gncmod-withdep PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
ARCHIVE_OUTPUT_DIRECTORY ${LIBDIR_BUILD}/gnucash/test
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/test)
set_dist_list(mod_withdep_DIST CMakeLists.txt withdep.c withdep.h gnc-mod-withdep.c)

View File

@ -29,12 +29,6 @@ int
main(int argc, char ** argv)
{
GNCModule testmod;
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;
TestErrorStruct check = { loglevel, logdomain, msg };
g_log_set_handler (logdomain, loglevel,
(GLogFunc)test_checked_handler, &check);
g_test_message(" test-agedver.c: asking for an old but supported interface ...");
gnc_module_system_init();

View File

@ -35,14 +35,8 @@ int
main(int argc, char ** argv)
{
GModule *gmodule;
gchar *msg = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
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)
{

View File

@ -29,14 +29,11 @@ int
main(int argc, char ** argv)
{
GNCModule foo;
gchar *msg1 = "Module '../../../libgnucash/gnc-module/test/misc-mods/.libs/libgncmod_futuremodsys.so' requires newer module system\n";
gchar *msg2 = "Could not locate module gnucash/incompatdep interface v.0";
gchar *msg = "Could not locate module gnucash/incompatdep interface v.0";
gchar *logdomain = "gnc.module";
guint loglevel = G_LOG_LEVEL_WARNING;
TestErrorStruct check1 = { loglevel, logdomain, msg1 };
TestErrorStruct check2 = { loglevel, logdomain, msg2 };
test_add_error (&check1);
test_add_error (&check2);
TestErrorStruct check = { loglevel, logdomain, msg };
test_add_error (&check);
g_log_set_handler (logdomain, loglevel,
(GLogFunc)test_list_handler, NULL);

View File

@ -32,12 +32,6 @@ main(int argc, char ** argv)
{
gint retval = 0;
GNCModule testmod;
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;
TestErrorStruct check = { loglevel, logdomain, msg };
g_log_set_handler (logdomain, loglevel,
(GLogFunc)test_checked_handler, &check);
gnc_module_system_init();