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" "" "" "")
|
||||
|
||||
35
bindings/guile/test/mod-bar/CMakeLists.txt
Normal file
35
bindings/guile/test/mod-bar/CMakeLists.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
gnc_add_swig_guile_command (swig-bar-c
|
||||
SWIG_BAR_C swig-bar.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bar.i "" bar.h
|
||||
)
|
||||
|
||||
add_library(bar EXCLUDE_FROM_ALL bar.c bar.h)
|
||||
add_library(gncmod-bar EXCLUDE_FROM_ALL gnc-mod-bar.c)
|
||||
set_source_files_properties (gnc-mod-bar.c PROPERTY OBJECT_DEPENDS ${SWIG_BAR_C})
|
||||
|
||||
target_link_libraries(gncmod-bar bar gnc-module)
|
||||
target_include_directories(gncmod-bar PRIVATE
|
||||
${CMAKE_BINARY_DIR}/common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-mod-bar
|
||||
gnucash/bar.scm
|
||||
"tests/gnucash"
|
||||
gncmod-bar
|
||||
FALSE
|
||||
)
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
set_dist_list(mod_bar_DIST CMakeLists.txt bar.c gnucash/bar.scm bar.h bar.i gnc-mod-bar.c)
|
||||
33
bindings/guile/test/mod-bar/bar.c
Normal file
33
bindings/guile/test/mod-bar/bar.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* libfoo. this is a dependency-free client library, equivalent to
|
||||
* the engine or some other core component that's ignorant of guile
|
||||
* and the module system */
|
||||
/********************************************************************\
|
||||
* 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 "bar.h"
|
||||
|
||||
int
|
||||
bar_hello(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
28
bindings/guile/test/mod-bar/bar.h
Normal file
28
bindings/guile/test/mod-bar/bar.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* bar.h: header for a dependency-free, guile-free client lib */
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef BAR_H
|
||||
#define BAR_H
|
||||
|
||||
int bar_hello(void);
|
||||
|
||||
#endif
|
||||
33
bindings/guile/test/mod-bar/bar.i
Normal file
33
bindings/guile/test/mod-bar/bar.i
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
%module sw_bar
|
||||
%{
|
||||
#include <bar.h>
|
||||
%}
|
||||
#if defined(SWIGGUILE)
|
||||
%{
|
||||
#include "guile-mappings.h"
|
||||
|
||||
SCM scm_init_sw_bar_module (void);
|
||||
%}
|
||||
#endif
|
||||
|
||||
int bar_hello(void);
|
||||
63
bindings/guile/test/mod-bar/gnc-mod-bar.c
Normal file
63
bindings/guile/test/mod-bar/gnc-mod-bar.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/* gnc-mod-bar.c : the Gnucash plugin that wraps the library
|
||||
* 'libbar.so'. it does this by being linked against libbar.so */
|
||||
/********************************************************************\
|
||||
* 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 <config.h>
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module-api.h"
|
||||
#include "swig-bar.c"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmod_bar)
|
||||
|
||||
int libgncmod_bar_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_bar_gnc_module_current = 0;
|
||||
int libgncmod_bar_gnc_module_age = 0;
|
||||
int libgncmod_bar_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_bar_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/bar");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_bar_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a bar module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_bar_gnc_module_init(int refcount)
|
||||
{
|
||||
/* publish the wrapped Scheme bindings for libbar */
|
||||
scm_init_sw_bar_module();
|
||||
scm_c_eval_string("(use-modules (sw_bar))");
|
||||
|
||||
/* use the Scheme "bar" module */
|
||||
scm_c_eval_string("(use-modules (gnucash bar))");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
31
bindings/guile/test/mod-bar/gnucash/bar.scm
Normal file
31
bindings/guile/test/mod-bar/gnucash/bar.scm
Normal file
@@ -0,0 +1,31 @@
|
||||
;; test of a Scheme module called gnc-mod-bar, which should get
|
||||
;; loaded by the Gnucash module "bar"
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; 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
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(define-module (gnucash bar))
|
||||
|
||||
(export bar:scheme-hello)
|
||||
|
||||
(define (bar:scheme-hello)
|
||||
#t)
|
||||
|
||||
|
||||
|
||||
40
bindings/guile/test/mod-baz/CMakeLists.txt
Normal file
40
bindings/guile/test/mod-baz/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
gnc_add_swig_guile_command (swig-baz-c
|
||||
SWIG_BAZ_C 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}/bindings/guile/test/mod-foo
|
||||
)
|
||||
target_link_libraries(baz foo)
|
||||
|
||||
|
||||
add_library(gncmod-baz EXCLUDE_FROM_ALL gnc-mod-baz.c)
|
||||
set_source_files_properties (gnc-mod-baz.c PROPERTY OBJECT_DEPENDS ${SWIG_BAZ_C})
|
||||
|
||||
target_link_libraries(gncmod-baz baz gnc-module)
|
||||
target_include_directories(gncmod-baz PRIVATE
|
||||
${CMAKE_BINARY_DIR}/common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-mod-baz
|
||||
gnucash/baz.scm
|
||||
"tests/gnucash"
|
||||
gncmod-baz
|
||||
FALSE
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
set_dist_list(mod_baz_DIST CMakeLists.txt baz.c gnucash/baz.scm baz.h baz.i gnc-mod-baz.c)
|
||||
34
bindings/guile/test/mod-baz/baz.c
Normal file
34
bindings/guile/test/mod-baz/baz.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* libbaz. this library depends on foo */
|
||||
/********************************************************************\
|
||||
* 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 "baz.h"
|
||||
#include "foo.h"
|
||||
|
||||
int
|
||||
baz_hello(void)
|
||||
{
|
||||
foo_hello();
|
||||
return 1;
|
||||
}
|
||||
|
||||
28
bindings/guile/test/mod-baz/baz.h
Normal file
28
bindings/guile/test/mod-baz/baz.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* baz.h: header for a dependency-free, guile-free client lib */
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef BAZ_H
|
||||
#define BAZ_H
|
||||
|
||||
int baz_hello(void);
|
||||
|
||||
#endif
|
||||
33
bindings/guile/test/mod-baz/baz.i
Normal file
33
bindings/guile/test/mod-baz/baz.i
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
%module sw_baz
|
||||
%{
|
||||
#include <baz.h>
|
||||
%}
|
||||
#if defined(SWIGGUILE)
|
||||
%{
|
||||
#include "guile-mappings.h"
|
||||
|
||||
SCM scm_init_sw_baz_module (void);
|
||||
%}
|
||||
#endif
|
||||
|
||||
int baz_hello(void);
|
||||
72
bindings/guile/test/mod-baz/gnc-mod-baz.c
Normal file
72
bindings/guile/test/mod-baz/gnc-mod-baz.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/* gnc-mod-baz.c : the Gnucash plugin that wraps the library
|
||||
* 'libbaz.so'. it does this by being linked against libbaz.so */
|
||||
/********************************************************************\
|
||||
* 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 <config.h>
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module.h"
|
||||
#include "gnc-module-api.h"
|
||||
#include "swig-baz.c"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmod_baz)
|
||||
|
||||
int libgncmod_baz_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_baz_gnc_module_current = 0;
|
||||
int libgncmod_baz_gnc_module_age = 0;
|
||||
int libgncmod_baz_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_baz_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/baz");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_baz_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is the baz module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_baz_gnc_module_init(int refcount)
|
||||
{
|
||||
/* load libfoo */
|
||||
if (gnc_module_load("gnucash/foo", 0))
|
||||
{
|
||||
/* publish the wrapped Scheme bindings for libbaz */
|
||||
scm_init_sw_baz_module();
|
||||
scm_c_eval_string("(use-modules (sw_baz))");
|
||||
|
||||
/* use the Scheme "baz" module */
|
||||
scm_c_eval_string("(use-modules (gnucash baz))");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
31
bindings/guile/test/mod-baz/gnucash/baz.scm
Normal file
31
bindings/guile/test/mod-baz/gnucash/baz.scm
Normal file
@@ -0,0 +1,31 @@
|
||||
;; test of a Scheme module called gnc-mod-baz, which should get
|
||||
;; loaded by the Gnucash module "baz"
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; 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
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(define-module (gnucash baz))
|
||||
|
||||
(export baz:scheme-hello)
|
||||
|
||||
(define (baz:scheme-hello)
|
||||
#t)
|
||||
|
||||
|
||||
|
||||
34
bindings/guile/test/mod-foo/CMakeLists.txt
Normal file
34
bindings/guile/test/mod-foo/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
gnc_add_swig_guile_command (swig-foo-c
|
||||
SWIG_FOO_C swig-foo.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/foo.i "" foo.h
|
||||
)
|
||||
|
||||
add_library(foo EXCLUDE_FROM_ALL foo.c foo.h)
|
||||
add_library(gncmod-foo EXCLUDE_FROM_ALL gnc-mod-foo.c)
|
||||
set_source_files_properties (gnc-mod-foo.c PROPERTY OBJECT_DEPENDS ${SWIG_FOO_C})
|
||||
|
||||
target_link_libraries(gncmod-foo foo gnc-module)
|
||||
target_include_directories(gncmod-foo PRIVATE
|
||||
${CMAKE_BINARY_DIR}/common
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/common
|
||||
${CMAKE_SOURCE_DIR}/libgnucash/gnc-module
|
||||
${GLIB2_INCLUDE_DIRS}
|
||||
${GUILE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
gnc_add_scheme_test_targets(scm-mod-foo
|
||||
gnucash/foo.scm
|
||||
"tests/gnucash"
|
||||
gncmod-foo
|
||||
FALSE
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
set_dist_list(mod_foo_DIST CMakeLists.txt foo.i gnucash/foo.scm foo.c foo.h gnc-mod-foo.c)
|
||||
33
bindings/guile/test/mod-foo/foo.c
Normal file
33
bindings/guile/test/mod-foo/foo.c
Normal file
@@ -0,0 +1,33 @@
|
||||
/* libfoo. this is a dependency-free client library, equivalent to
|
||||
* the engine or some other core component that's ignorant of guile
|
||||
* and the module system */
|
||||
/********************************************************************\
|
||||
* 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 "foo.h"
|
||||
|
||||
int
|
||||
foo_hello(void)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
28
bindings/guile/test/mod-foo/foo.h
Normal file
28
bindings/guile/test/mod-foo/foo.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/* foo.h: header for a dependency-free, guile-free client lib */
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
|
||||
#ifndef FOO_H
|
||||
#define FOO_H
|
||||
|
||||
int foo_hello(void);
|
||||
|
||||
#endif
|
||||
33
bindings/guile/test/mod-foo/foo.i
Normal file
33
bindings/guile/test/mod-foo/foo.i
Normal file
@@ -0,0 +1,33 @@
|
||||
/********************************************************************\
|
||||
* 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 *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
%module sw_foo
|
||||
%{
|
||||
#include <foo.h>
|
||||
%}
|
||||
#if defined(SWIGGUILE)
|
||||
%{
|
||||
#include "guile-mappings.h"
|
||||
|
||||
SCM scm_init_sw_foo_module (void);
|
||||
%}
|
||||
#endif
|
||||
|
||||
int foo_hello(void);
|
||||
63
bindings/guile/test/mod-foo/gnc-mod-foo.c
Normal file
63
bindings/guile/test/mod-foo/gnc-mod-foo.c
Normal file
@@ -0,0 +1,63 @@
|
||||
/* gnc-mod-foo.c : the Gnucash plugin that wraps the library
|
||||
* 'libfoo.so'. it does this by being linked against libfoo.so */
|
||||
/********************************************************************\
|
||||
* 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 <config.h>
|
||||
#include <stdio.h>
|
||||
#include <gmodule.h>
|
||||
#include <libguile.h>
|
||||
|
||||
#include "gnc-module-api.h"
|
||||
#include "swig-foo.c"
|
||||
|
||||
GNC_MODULE_API_DECL(libgncmod_foo)
|
||||
|
||||
int libgncmod_foo_gnc_module_system_interface = 0;
|
||||
|
||||
int libgncmod_foo_gnc_module_current = 0;
|
||||
int libgncmod_foo_gnc_module_age = 0;
|
||||
int libgncmod_foo_gnc_module_revision = 0;
|
||||
|
||||
char *
|
||||
libgncmod_foo_gnc_module_path(void)
|
||||
{
|
||||
return g_strdup("gnucash/foo");
|
||||
}
|
||||
|
||||
char *
|
||||
libgncmod_foo_gnc_module_description(void)
|
||||
{
|
||||
return g_strdup("this is a foo module");
|
||||
}
|
||||
|
||||
int
|
||||
libgncmod_foo_gnc_module_init(int refcount)
|
||||
{
|
||||
/* publish the wrapped Scheme bindings for libfoo */
|
||||
scm_init_sw_foo_module();
|
||||
scm_c_eval_string("(use-modules (sw_foo))");
|
||||
|
||||
/* use the Scheme "foo" module */
|
||||
scm_c_eval_string("(use-modules (gnucash foo))");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
31
bindings/guile/test/mod-foo/gnucash/foo.scm
Normal file
31
bindings/guile/test/mod-foo/gnucash/foo.scm
Normal file
@@ -0,0 +1,31 @@
|
||||
;; test of a Scheme module called gnc-mod-foo, which should get
|
||||
;; loaded by the Gnucash module "foo"
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; 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
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
(define-module (gnucash foo))
|
||||
|
||||
(export foo:scheme-hello)
|
||||
|
||||
(define (foo:scheme-hello)
|
||||
#t)
|
||||
|
||||
|
||||
|
||||
22
bindings/guile/test/test-gnc-module-load-deps.scm
Executable file
22
bindings/guile/test/test-gnc-module-load-deps.scm
Executable file
@@ -0,0 +1,22 @@
|
||||
(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/baz" 0)
|
||||
|
||||
(baz-hello)
|
||||
(foo-hello)
|
||||
(baz:scheme-hello)
|
||||
(foo:scheme-hello)
|
||||
|
||||
(g-log-remove-handler log-domain handler)
|
||||
|
||||
(exit 0)
|
||||
14
bindings/guile/test/test-gnc-module-load-scm.scm
Executable file
14
bindings/guile/test/test-gnc-module-load-scm.scm
Executable file
@@ -0,0 +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)
|
||||
(g-log-remove-handler log-domain handler)
|
||||
(exit 0)
|
||||
2
bindings/guile/test/test-gnc-module-scm-dynload.scm
Executable file
2
bindings/guile/test/test-gnc-module-scm-dynload.scm
Executable file
@@ -0,0 +1,2 @@
|
||||
(dynamic-link "libgnc-module")
|
||||
(exit 0)
|
||||
15
bindings/guile/test/test-gnc-module-scm-init.scm
Executable file
15
bindings/guile/test/test-gnc-module-scm-init.scm
Executable file
@@ -0,0 +1,15 @@
|
||||
(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)
|
||||
14
bindings/guile/test/test-gnc-module-scm-module.scm
Executable file
14
bindings/guile/test/test-gnc-module-scm-module.scm
Executable file
@@ -0,0 +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)
|
||||
(if (not (gnc:module-load "gnucash/foo" 0)) (exit -1))
|
||||
(exit (foo:scheme-hello))
|
||||
(g-log-remove-handler log-domain handler)
|
||||
23
bindings/guile/test/test-gnc-module-scm-multi.scm
Executable file
23
bindings/guile/test/test-gnc-module-scm-multi.scm
Executable file
@@ -0,0 +1,23 @@
|
||||
(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)
|
||||
14
bindings/guile/test/test-gnc-module-swigged-c.scm
Executable file
14
bindings/guile/test/test-gnc-module-swigged-c.scm
Executable file
@@ -0,0 +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)
|
||||
(exit (eq? 10 (foo-hello)))
|
||||
(g-log-remove-handler log-domain handler)
|
||||
Reference in New Issue
Block a user