mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add test-scm-print-import and test-print-queries
(The latter is not actually run, but is useful to me now) git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6945 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
d66d0583d9
commit
146d414c73
@ -25,13 +25,14 @@ TESTS = \
|
|||||||
test-group-vs-book \
|
test-group-vs-book \
|
||||||
test-object \
|
test-object \
|
||||||
test-period \
|
test-period \
|
||||||
test-query \
|
|
||||||
test-querynew \
|
test-querynew \
|
||||||
|
test-query \
|
||||||
test-resolve-file-path \
|
test-resolve-file-path \
|
||||||
test-split-vs-account \
|
test-split-vs-account \
|
||||||
test-transaction-voiding \
|
test-transaction-voiding \
|
||||||
test-freq-spec \
|
test-freq-spec \
|
||||||
test-scm-query
|
test-scm-query \
|
||||||
|
test-scm-query-import
|
||||||
|
|
||||||
GNC_TEST_DEPS := \
|
GNC_TEST_DEPS := \
|
||||||
--gnc-module-dir ${top_builddir}/src/gnc-module \
|
--gnc-module-dir ${top_builddir}/src/gnc-module \
|
||||||
@ -59,11 +60,14 @@ noinst_PROGRAMS = \
|
|||||||
test-resolve-file-path \
|
test-resolve-file-path \
|
||||||
test-scm-query \
|
test-scm-query \
|
||||||
test-split-vs-account \
|
test-split-vs-account \
|
||||||
test-transaction-voiding
|
test-transaction-voiding \
|
||||||
|
test-print-queries
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
test-create-account \
|
test-create-account \
|
||||||
test-create-account.scm
|
test-create-account.scm \
|
||||||
|
test-scm-query-import \
|
||||||
|
test-scm-query-import.scm
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f translog.*
|
rm -f translog.*
|
||||||
|
65
src/engine/test/test-print-queries.c
Normal file
65
src/engine/test/test-print-queries.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <guile/gh.h>
|
||||||
|
|
||||||
|
#include "engine-helpers.h"
|
||||||
|
#include "gnc-module.h"
|
||||||
|
#include "test-engine-stuff.h"
|
||||||
|
#include "test-stuff.h"
|
||||||
|
#include "Query.h"
|
||||||
|
#include "TransLog.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_query (Query *q)
|
||||||
|
{
|
||||||
|
SCM scm_q;
|
||||||
|
scm_q = gnc_query2scm (q);
|
||||||
|
gh_display (scm_q); gh_newline (); gh_newline ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run_tests (int count)
|
||||||
|
{
|
||||||
|
Query *q;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
q = get_random_query ();
|
||||||
|
test_query (q);
|
||||||
|
xaccFreeQuery (q);
|
||||||
|
}
|
||||||
|
success ("");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
main_helper (int argc, char **argv)
|
||||||
|
{
|
||||||
|
int count = 50;
|
||||||
|
|
||||||
|
gnc_module_load("gnucash/engine", 0);
|
||||||
|
|
||||||
|
if (argc > 1)
|
||||||
|
count = atoi (argv[1]);
|
||||||
|
|
||||||
|
if (count < 0)
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
xaccLogDisable ();
|
||||||
|
|
||||||
|
/* scm conversion doesn't handle binary atm */
|
||||||
|
kvp_exclude_type (KVP_TYPE_BINARY);
|
||||||
|
|
||||||
|
run_tests (count);
|
||||||
|
|
||||||
|
print_test_results ();
|
||||||
|
|
||||||
|
exit (get_rv ());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
gh_enter (argc, argv, main_helper);
|
||||||
|
return 0;
|
||||||
|
}
|
2
src/engine/test/test-scm-query-import
Executable file
2
src/engine/test/test-scm-query-import
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
guile -l $SRCDIR/test-scm-query-import.scm -c "(exit (run-test))"
|
32
src/engine/test/test-scm-query-import.scm
Normal file
32
src/engine/test/test-scm-query-import.scm
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
;; test-scm-query-import.scm
|
||||||
|
;; load the engine and test the import of some old-style scheme queries
|
||||||
|
|
||||||
|
(use-modules (gnucash gnc-module))
|
||||||
|
|
||||||
|
(define query-list
|
||||||
|
(list
|
||||||
|
'((terms (((pd-account pr-account #t acct-match-any ("39d55759e0561fe7c7a5b6a99deb17a0"))))) (primary-sort by-standard) (secondary-sort by-none) (tertiary-sort by-none) (primary-increasing #t) (secondary-increasing #t) (tertiary-increasing #t) (max-splits -1))
|
||||||
|
))
|
||||||
|
|
||||||
|
(define (run-test)
|
||||||
|
(gnc:module-system-init)
|
||||||
|
(gnc:module-load "gnucash/engine" 0)
|
||||||
|
|
||||||
|
(let* ((session (gnc:session-new))
|
||||||
|
(book (gnc:session-get-book session))
|
||||||
|
(failures #f))
|
||||||
|
|
||||||
|
(for-each
|
||||||
|
(lambda (query-scm)
|
||||||
|
(let* ((q (gnc:scm->query query-scm))
|
||||||
|
(q2 (gnc:query->scm q)))
|
||||||
|
(if (or (null? q) (not q))
|
||||||
|
(begin
|
||||||
|
(set! failures #t)
|
||||||
|
(display query-scm)
|
||||||
|
(display "\n")
|
||||||
|
(display q2)
|
||||||
|
(display "\n")))))
|
||||||
|
query-list)
|
||||||
|
|
||||||
|
(not failures)))
|
Loading…
Reference in New Issue
Block a user