mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Fix some module versioning problems.
Distinguish between book full path and book logging path. Work on test infrastructure. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5437 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
71ff5cc313
commit
904b2c2acb
@ -19,9 +19,9 @@
|
||||
int gnc_module_system_interface = 0;
|
||||
|
||||
/* module versioning uses libtool semantics. */
|
||||
int gnc_module_current = 8;
|
||||
int gnc_module_current = 0;
|
||||
int gnc_module_revision = 0;
|
||||
int gnc_module_age = 1;
|
||||
int gnc_module_age = 0;
|
||||
|
||||
GNCModule engine;
|
||||
|
||||
|
@ -2,3 +2,4 @@ Makefile
|
||||
Makefile.in
|
||||
gnc_test
|
||||
test-db
|
||||
test-file-*
|
||||
|
@ -1,9 +1,9 @@
|
||||
TESTS = \
|
||||
test-load-module \
|
||||
test-db
|
||||
run-tests.sh
|
||||
|
||||
TESTS_ENVIRONMENT=\
|
||||
GNC_MODULE_PATH=${top_srcdir}/src/engine:${top_srcdir}/src/backend/postgres \
|
||||
GNC_MODULE_PATH=${top_srcdir}/src/engine::${top_srcdir}/src/backend/file:${top_srcdir}/src/backend/postgres \
|
||||
GUILE_LOAD_PATH=${G_WRAP_MODULE_DIR}:..:${top_srcdir}/src/gnc-module \
|
||||
LTDL_LIBRARY_PATH=${top_srcdir}/src/gnc-module \
|
||||
LD_LIBRARY_PATH=${top_srcdir}/src/gnc-module:${top_srcdir}/src/gnc-module/.libs:${top_srcdir}/src/engine:${top_srcdir}/src/engine/.libs
|
||||
|
13
src/backend/postgres/test/run-tests.sh
Executable file
13
src/backend/postgres/test/run-tests.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
exit 0
|
||||
|
||||
EXIT_VALUE=0
|
||||
|
||||
./db-control.sh create
|
||||
./db-control.sh start
|
||||
./test-db || EXIT_VALUE=1
|
||||
./db-control.sh stop
|
||||
#./db-control.sh destroy
|
||||
|
||||
exit $EXIT_VALUE
|
@ -1,10 +1,6 @@
|
||||
#include <glib.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Backend.h"
|
||||
@ -16,16 +12,64 @@
|
||||
#include "test-stuff.h"
|
||||
#include "test-engine-stuff.h"
|
||||
|
||||
static void
|
||||
test_book (GNCBook *book)
|
||||
{
|
||||
GNCBackendError io_err;
|
||||
char cwd[1024];
|
||||
char *filename;
|
||||
|
||||
getcwd (cwd, sizeof (cwd));
|
||||
|
||||
filename = g_strconcat ("file:/", cwd, "/test-file-1", NULL);
|
||||
gnc_book_begin (book, filename, FALSE, TRUE);
|
||||
g_free (filename);
|
||||
|
||||
io_err = gnc_book_get_error (book);
|
||||
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Beginning test-file-1"))
|
||||
return;
|
||||
|
||||
gnc_book_save (book);
|
||||
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Saving test-file-1"))
|
||||
return;
|
||||
|
||||
gnc_book_end (book);
|
||||
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Ending test-file-1"))
|
||||
return;
|
||||
|
||||
filename = g_strdup ("postgres://localhost:7777/gnc_test?mode=single-file");
|
||||
gnc_book_begin (book, filename, FALSE, TRUE);
|
||||
g_free (filename);
|
||||
|
||||
io_err = gnc_book_get_error (book);
|
||||
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Beginning gnc_test"))
|
||||
return;
|
||||
|
||||
gnc_book_save (book);
|
||||
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Saving gnc_test"))
|
||||
return;
|
||||
|
||||
gnc_book_end (book);
|
||||
if (!do_test (io_err == ERR_BACKEND_NO_ERR, "Ending gnc_test"))
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
guile_main (int argc, char **argv)
|
||||
{
|
||||
GNCBook *book;
|
||||
|
||||
gnc_module_system_init ();
|
||||
gnc_module_load ("gnucash/engine", 0);
|
||||
|
||||
gnc_engine_init (argc, argv);
|
||||
|
||||
xaccLogDisable ();
|
||||
|
||||
book = get_random_book ();
|
||||
|
||||
test_book (book);
|
||||
|
||||
gnc_book_destroy (book);
|
||||
|
||||
print_test_results ();
|
||||
exit (get_rv ());
|
||||
}
|
||||
@ -33,6 +77,9 @@ guile_main (int argc, char **argv)
|
||||
int
|
||||
main (int argc, char ** argv)
|
||||
{
|
||||
/* getchar (); */
|
||||
|
||||
gh_enter (argc, argv, guile_main);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -6,13 +6,10 @@ exec guile -s "$0"
|
||||
(use-modules (gnucash gnc-module))
|
||||
(gnc:module-system-init)
|
||||
|
||||
(if (gnc:module-load "gnucash/backend/postgres" 8)
|
||||
(if (gnc:module-load "gnucash/backend/postgres" 0)
|
||||
(begin
|
||||
(display "ok\n")
|
||||
(exit 0))
|
||||
(begin
|
||||
(display "failed\n")
|
||||
(exit -1)))
|
||||
|
||||
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
int gnc_module_system_interface = 0;
|
||||
|
||||
/* module versioning uses libtool semantics. */
|
||||
int gnc_module_current = 8;
|
||||
int gnc_module_current = 0;
|
||||
int gnc_module_revision = 0;
|
||||
int gnc_module_age = 1;
|
||||
int gnc_module_age = 0;
|
||||
|
||||
GNCModule engine;
|
||||
|
||||
|
@ -44,8 +44,6 @@
|
||||
#include "gnc-pricedb.h"
|
||||
#include "Group.h"
|
||||
|
||||
#define GNC_BACKEND_INTERFACE 0
|
||||
|
||||
struct gnc_book_struct
|
||||
{
|
||||
AccountGroup *topgroup;
|
||||
@ -76,6 +74,7 @@ struct gnc_book_struct
|
||||
char *error_message;
|
||||
|
||||
char *fullpath;
|
||||
char *logpath;
|
||||
|
||||
/* ---------------------------------------------------- */
|
||||
/* This struct member applies for network, rpc and SQL i/o */
|
||||
|
@ -133,6 +133,7 @@ gnc_book_init (GNCBook *book)
|
||||
book->book_id = NULL;
|
||||
gnc_book_clear_error (book);
|
||||
book->fullpath = NULL;
|
||||
book->logpath = NULL;
|
||||
book->backend = NULL;
|
||||
}
|
||||
|
||||
@ -288,6 +289,7 @@ book_sxns_mark_saved(GNCBook *book)
|
||||
NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_book_mark_saved(GNCBook *book)
|
||||
{
|
||||
@ -298,11 +300,8 @@ gnc_book_mark_saved(GNCBook *book)
|
||||
|
||||
xaccGroupMarkSaved(gnc_book_get_template_group(book));
|
||||
book_sxns_mark_saved(book);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
@ -311,6 +310,8 @@ gnc_book_int_backend_load_error(GNCBook *book, char *message, char *dll_err)
|
||||
PWARN (message, dll_err ? dll_err : "");
|
||||
g_free(book->fullpath);
|
||||
book->fullpath = NULL;
|
||||
g_free(book->logpath);
|
||||
book->logpath = NULL;
|
||||
g_free(book->book_id);
|
||||
book->book_id = NULL;
|
||||
gnc_book_push_error (book, ERR_BACKEND_NO_BACKEND, NULL);
|
||||
@ -325,7 +326,8 @@ gnc_book_load_backend(GNCBook * book, char * backend_name)
|
||||
Backend *(* be_new_func)(void);
|
||||
char * mod_name = g_strdup_printf("gnucash/backend/%s", backend_name);
|
||||
|
||||
mod = gnc_module_load(mod_name, GNC_BACKEND_INTERFACE);
|
||||
/* FIXME: this needs to be smarter with version numbers. */
|
||||
mod = gnc_module_load(mod_name, 0);
|
||||
if(mod)
|
||||
{
|
||||
be_new_func = gnc_module_lookup(mod, "gnc_backend_new");
|
||||
@ -378,7 +380,7 @@ gnc_book_begin (GNCBook *book, const char * book_id,
|
||||
/* Store the sessionid URL */
|
||||
book->book_id = g_strdup (book_id);
|
||||
|
||||
book->fullpath = xaccResolveFilePath(book_id);
|
||||
book->fullpath = xaccResolveURL(book_id);
|
||||
if (!book->fullpath)
|
||||
{
|
||||
gnc_book_push_error (book, ERR_FILEIO_FILE_NOT_FOUND, NULL);
|
||||
@ -386,7 +388,10 @@ gnc_book_begin (GNCBook *book, const char * book_id,
|
||||
return FALSE; /* ouch */
|
||||
}
|
||||
PINFO ("filepath=%s", book->fullpath ? book->fullpath : "(null)");
|
||||
|
||||
|
||||
book->logpath = xaccResolveFilePath(book->fullpath);
|
||||
PINFO ("logpath=%s", book->logpath ? book->logpath : "(null)");
|
||||
|
||||
/* check to see if this is a type we know how to handle */
|
||||
if (!g_strncasecmp(book_id, "file:", 5) ||
|
||||
*book->fullpath == '/')
|
||||
@ -425,6 +430,8 @@ gnc_book_begin (GNCBook *book, const char * book_id,
|
||||
{
|
||||
g_free(book->fullpath);
|
||||
book->fullpath = NULL;
|
||||
g_free(book->logpath);
|
||||
book->logpath = NULL;
|
||||
g_free(book->book_id);
|
||||
book->book_id = NULL;
|
||||
gnc_book_push_error (book, err, NULL);
|
||||
@ -460,7 +467,7 @@ gnc_book_load (GNCBook *book)
|
||||
gnc_pricedb_destroy(book->pricedb);
|
||||
book->pricedb = NULL;
|
||||
|
||||
xaccLogSetBaseName(book->fullpath);
|
||||
xaccLogSetBaseName(book->logpath);
|
||||
xaccLogEnable();
|
||||
|
||||
gnc_book_clear_error (book);
|
||||
@ -483,8 +490,8 @@ gnc_book_load (GNCBook *book)
|
||||
xaccLogDisable();
|
||||
if(be->book_load)
|
||||
{
|
||||
xaccLogSetBaseName(book->fullpath);
|
||||
|
||||
xaccLogSetBaseName(book->logpath);
|
||||
|
||||
book->topgroup = (be->book_load) (be);
|
||||
xaccGroupSetBackend (book->topgroup, be);
|
||||
gnc_book_push_error(book, xaccBackendGetError(be), NULL);
|
||||
|
@ -126,7 +126,7 @@ get_rv(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
do_test_call(
|
||||
gboolean result,
|
||||
const char* test_title,
|
||||
@ -138,6 +138,8 @@ do_test_call(
|
||||
} else {
|
||||
failure_args( test_title, filename, line, "" );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -45,7 +45,7 @@ Otherwise, only failures are printed out.
|
||||
* title describes the test
|
||||
* Tests are automatically identified by their source file and line.
|
||||
*/
|
||||
#define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ );
|
||||
#define do_test( result, title ) do_test_call( result, title, __FILE__, __LINE__ )
|
||||
#define success( title ) success_call( title, __FILE__, __LINE__ );
|
||||
#define failure( title ) failure_call( title, __FILE__, __LINE__ );
|
||||
|
||||
@ -58,7 +58,7 @@ Otherwise, only failures are printed out.
|
||||
/* Privately used to indicate a test result. You may use these if you
|
||||
* wish, but it's easier to use the do_test macro above.
|
||||
*/
|
||||
void do_test_call(
|
||||
gboolean do_test_call(
|
||||
gboolean result,
|
||||
const char* test_title,
|
||||
const char* filename,
|
||||
|
Loading…
Reference in New Issue
Block a user