Tests: harmonize test initialization

In particular, use qof_init instead of g_type_init. The former
calls the latter by default. Also our current engine code is
heavily dependent on gobject, so it makes sense to initialize it
as early on as possible. Having once central place to do so
will make it easier to fix this if ever we move away from gobject.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22943 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens 2013-05-03 12:03:53 +00:00
parent eb409ecd35
commit 84b2428192
8 changed files with 12 additions and 15 deletions

View File

@ -194,7 +194,6 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
g_setenv ("GNC_UNINSTALLED", "1", TRUE); g_setenv ("GNC_UNINSTALLED", "1", TRUE);
g_type_init();
qof_init(); qof_init();
gnc_engine_init(0, NULL); gnc_engine_init(0, NULL);

View File

@ -35,11 +35,10 @@ int
main (int argc, main (int argc,
char *argv[]) char *argv[])
{ {
g_type_init(); /* Initialize the GObject system */ qof_init(); /* equally initializes gobject system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
qof_log_init_filename_special("stderr"); /* Init the log system */ qof_log_init_filename_special("stderr"); /* Init the log system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */ g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */
qof_init();
cashobjects_register(); cashobjects_register();
g_assert (qof_load_backend_library ("../.libs/", GNC_LIB_NAME)); g_assert (qof_load_backend_library ("../.libs/", GNC_LIB_NAME));
g_assert (qof_load_backend_library ("../../xml/.libs", g_assert (qof_load_backend_library ("../../xml/.libs",

View File

@ -31,9 +31,9 @@ int
main (int argc, main (int argc,
char *argv[]) char *argv[])
{ {
g_type_init(); /* Initialize the GObject system */ qof_init(); /* Initialize the GObject system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
qof_log_init_filename_special("stderr"); /* Init the log system */ qof_log_init_filename_special("stderr"); /* Init the log system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */ g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */
test_suite_gnc_backend_sql (); test_suite_gnc_backend_sql ();

View File

@ -115,7 +115,6 @@ main (int argc, char ** argv)
const char *location = g_getenv("GNC_TEST_FILES"); const char *location = g_getenv("GNC_TEST_FILES");
GDir *xml2_dir; GDir *xml2_dir;
g_type_init();
qof_init(); qof_init();
cashobjects_register(); cashobjects_register();
do_test(qof_load_backend_library ("../.libs/", GNC_LIB_NAME), do_test(qof_load_backend_library ("../.libs/", GNC_LIB_NAME),

View File

@ -35,9 +35,9 @@ int
main (int argc, main (int argc,
char *argv[]) char *argv[])
{ {
g_type_init(); /* Initialize the GObject system */ qof_init(); /* Initialize the GObject system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
qof_log_init_filename_special("stderr"); /* Init the log system */ qof_log_init_filename_special("stderr"); /* Init the log system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
//qof_log_set_level("gnc", G_LOG_LEVEL_DEBUG); //qof_log_set_level("gnc", G_LOG_LEVEL_DEBUG);
g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */ g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */

View File

@ -37,9 +37,9 @@ int
main (int argc, main (int argc,
char *argv[]) char *argv[])
{ {
g_type_init(); /* Initialize the GObject system */ qof_init(); /* Initialize the GObject system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
qof_log_init_filename_special("stderr"); /* Init the log system */ qof_log_init_filename_special("stderr"); /* Init the log system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
// g_log_set_always_fatal (0); // g_log_set_always_fatal (0);
g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */ g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */

View File

@ -42,9 +42,9 @@ int
main (int argc, main (int argc,
char *argv[]) char *argv[])
{ {
g_type_init(); /* Initialize the GObject system */ qof_init(); /* Initialize the GObject system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
qof_log_init_filename_special("stderr"); /* Init the log system */ qof_log_init_filename_special("stderr"); /* Init the log system */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */ g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */
// Initialize glibmm // Initialize glibmm

View File

@ -34,13 +34,13 @@ int
main (int argc, main (int argc,
char *argv[]) char *argv[])
{ {
g_type_init(); /* You may or may not need this, depending on qof_init(); /* You may or may not need this, depending on
* whether the module you're testing or any * whether the module you're testing or any
* dependencies use GObject. */ * dependencies use GObject. */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
qof_log_init_filename_special("/dev/null"); /* Initialize the qof_log_init_filename_special("/dev/null"); /* Initialize the
* gnucash logging system. Your tests will * gnucash logging system. Your tests will
* crash on the first logging call otherwise */ * crash on the first logging call otherwise */
g_test_init ( &argc, &argv, NULL ); /* initialize test program */
test_suite_module1(); /* Call each suite assembly function */ test_suite_module1(); /* Call each suite assembly function */
test_suite_module2(); test_suite_module2();
test_suite_module3(); test_suite_module3();