From 84b2428192d77dbd2c2053fd917c42f41be6d3be Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 3 May 2013 12:03:53 +0000 Subject: [PATCH] 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 --- src/app-utils/test/test-sx.c | 1 - src/backend/dbi/test/test-backend-dbi.c | 5 ++--- src/backend/sql/test/test-sqlbe.c | 4 ++-- src/backend/xml/test/test-load-xml2.c | 1 - src/engine/test/test-engine.c | 4 ++-- src/libqof/qof/test/test-qof.c | 4 ++-- src/optional/gtkmm/test/test-gtkmm.cpp | 4 ++-- test-templates/test-module.c | 4 ++-- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/app-utils/test/test-sx.c b/src/app-utils/test/test-sx.c index 1337f7b468..0cd4e8e769 100644 --- a/src/app-utils/test/test-sx.c +++ b/src/app-utils/test/test-sx.c @@ -194,7 +194,6 @@ int main(int argc, char **argv) { g_setenv ("GNC_UNINSTALLED", "1", TRUE); - g_type_init(); qof_init(); gnc_engine_init(0, NULL); diff --git a/src/backend/dbi/test/test-backend-dbi.c b/src/backend/dbi/test/test-backend-dbi.c index d444c559ae..97ca5333cc 100644 --- a/src/backend/dbi/test/test-backend-dbi.c +++ b/src/backend/dbi/test/test-backend-dbi.c @@ -35,11 +35,10 @@ int main (int argc, char *argv[]) { - g_type_init(); /* Initialize the GObject system */ - g_test_init ( &argc, &argv, NULL ); /* initialize test program */ + qof_init(); /* equally initializes gobject 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 */ - qof_init(); cashobjects_register(); g_assert (qof_load_backend_library ("../.libs/", GNC_LIB_NAME)); g_assert (qof_load_backend_library ("../../xml/.libs", diff --git a/src/backend/sql/test/test-sqlbe.c b/src/backend/sql/test/test-sqlbe.c index 7de476ebf5..328e102505 100644 --- a/src/backend/sql/test/test-sqlbe.c +++ b/src/backend/sql/test/test-sqlbe.c @@ -31,9 +31,9 @@ int main (int argc, char *argv[]) { - g_type_init(); /* Initialize the GObject system */ - g_test_init ( &argc, &argv, NULL ); /* initialize test program */ + qof_init(); /* Initialize the GObject 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 */ test_suite_gnc_backend_sql (); diff --git a/src/backend/xml/test/test-load-xml2.c b/src/backend/xml/test/test-load-xml2.c index ef9ea4ac2e..33ee0309ea 100644 --- a/src/backend/xml/test/test-load-xml2.c +++ b/src/backend/xml/test/test-load-xml2.c @@ -115,7 +115,6 @@ main (int argc, char ** argv) const char *location = g_getenv("GNC_TEST_FILES"); GDir *xml2_dir; - g_type_init(); qof_init(); cashobjects_register(); do_test(qof_load_backend_library ("../.libs/", GNC_LIB_NAME), diff --git a/src/engine/test/test-engine.c b/src/engine/test/test-engine.c index 2caca9e1ca..e7850118f3 100644 --- a/src/engine/test/test-engine.c +++ b/src/engine/test/test-engine.c @@ -35,9 +35,9 @@ int main (int argc, char *argv[]) { - g_type_init(); /* Initialize the GObject system */ - g_test_init ( &argc, &argv, NULL ); /* initialize test program */ + qof_init(); /* Initialize the GObject 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); g_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */ diff --git a/src/libqof/qof/test/test-qof.c b/src/libqof/qof/test/test-qof.c index 37f2611b9d..d48961ea1c 100644 --- a/src/libqof/qof/test/test-qof.c +++ b/src/libqof/qof/test/test-qof.c @@ -37,9 +37,9 @@ int main (int argc, char *argv[]) { - g_type_init(); /* Initialize the GObject system */ - g_test_init ( &argc, &argv, NULL ); /* initialize test program */ + qof_init(); /* Initialize the GObject 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_test_bug_base("https://bugzilla.gnome.org/show_bug.cgi?id="); /* init the bugzilla URL */ diff --git a/src/optional/gtkmm/test/test-gtkmm.cpp b/src/optional/gtkmm/test/test-gtkmm.cpp index da85164413..7556c6e1f8 100644 --- a/src/optional/gtkmm/test/test-gtkmm.cpp +++ b/src/optional/gtkmm/test/test-gtkmm.cpp @@ -42,9 +42,9 @@ int main (int argc, char *argv[]) { - g_type_init(); /* Initialize the GObject system */ - g_test_init ( &argc, &argv, NULL ); /* initialize test program */ + qof_init(); /* Initialize the GObject 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 */ // Initialize glibmm diff --git a/test-templates/test-module.c b/test-templates/test-module.c index e826ba64e4..5e1fdf213a 100644 --- a/test-templates/test-module.c +++ b/test-templates/test-module.c @@ -34,13 +34,13 @@ int main (int argc, 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 * dependencies use GObject. */ - g_test_init ( &argc, &argv, NULL ); /* initialize test program */ qof_log_init_filename_special("/dev/null"); /* Initialize the * gnucash logging system. Your tests will * 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_module2(); test_suite_module3();