From 9037ffe0f3ab419554903de6f12d00ee74f2f3ff Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Fri, 12 Jul 2013 18:05:06 +0900 Subject: [PATCH] build: fix make check This contains several fixes to the current tests: - Remove glib mem profiler call from src/tests, which is known not to work with the latest glib release: https://bugzilla.gnome.org/show_bug.cgi?id=701694 valgrind could be used instead. - Replace g_type_init() call in tests with ibus_init(). - Fix ibus-bus test after the DBus property change (commit 458945e7). no global engine may be set in the test environment. Also add more assertions to check the return values. - Fix pygobject test to use LOG_COMPILER and move sys.path adjustment into the test script itself. - Add new files to po/POTFILES.in. BUG= R=takao.fujiwara1@gmail.com Review URL: https://codereview.appspot.com/11156043 --- bindings/pygobject/Makefile.am | 3 +- bindings/pygobject/gi/__init__.py | 4 -- bindings/pygobject/gi/overrides/__init__.py | 4 -- bindings/pygobject/test-override-ibus.py | 10 ++++ po/POTFILES.in | 2 +- po/POTFILES.skip | 6 +++ src/tests/ibus-bus.c | 13 ++++- src/tests/ibus-configservice.c | 6 +-- src/tests/ibus-engine.c | 20 ++++--- src/tests/ibus-factory.c | 6 +-- src/tests/ibus-global-engine.c | 81 ++++++++++++++--------------- src/tests/ibus-inputcontext-create.c | 2 +- src/tests/ibus-inputcontext.c | 2 +- src/tests/ibus-keymap.c | 6 +-- src/tests/ibus-keynames.c | 5 +- src/tests/ibus-proxy.c | 26 +++++---- src/tests/ibus-registry.c | 5 +- src/tests/ibus-serializable.c | 6 +-- src/tests/ibus-share.c | 6 +-- 19 files changed, 106 insertions(+), 107 deletions(-) diff --git a/bindings/pygobject/Makefile.am b/bindings/pygobject/Makefile.am index 6360397..d4389c3 100644 --- a/bindings/pygobject/Makefile.am +++ b/bindings/pygobject/Makefile.am @@ -37,9 +37,10 @@ TESTS_ENVIRONMENT = \ PYTHONPATH=$(top_srcdir)/tests:$${PYTHONPATH:+:$$PYTHONPATH} \ LD_LIBRARY_PATH=$(top_builddir)/src/.libs:$$LD_LIBRARY_PATH \ GI_TYPELIB_PATH=$(top_builddir)/src:$$GI_TYPELIB_PATH \ - $(PYTHON) -B \ $(NULL) +LOG_COMPILER = $(PYTHON) -B + EXTRA_DIST = \ gi/__init__.py \ gi/overrides/__init__.py \ diff --git a/bindings/pygobject/gi/__init__.py b/bindings/pygobject/gi/__init__.py index 3ae00c3..4730fc9 100644 --- a/bindings/pygobject/gi/__init__.py +++ b/bindings/pygobject/gi/__init__.py @@ -22,7 +22,3 @@ from pkgutil import extend_path __path__ = extend_path(__path__, __name__) - -__path__.reverse() -from __init__ import * -__path__.reverse() diff --git a/bindings/pygobject/gi/overrides/__init__.py b/bindings/pygobject/gi/overrides/__init__.py index 3ae00c3..4730fc9 100644 --- a/bindings/pygobject/gi/overrides/__init__.py +++ b/bindings/pygobject/gi/overrides/__init__.py @@ -22,7 +22,3 @@ from pkgutil import extend_path __path__ = extend_path(__path__, __name__) - -__path__.reverse() -from __init__ import * -__path__.reverse() diff --git a/bindings/pygobject/test-override-ibus.py b/bindings/pygobject/test-override-ibus.py index d222ecf..5492268 100644 --- a/bindings/pygobject/test-override-ibus.py +++ b/bindings/pygobject/test-override-ibus.py @@ -21,6 +21,16 @@ # Boston, MA 02110-1301 USA import unittest + +import os +import sys + +# move the script path at the end, so the necessary modules in system +# pygobject can be loaded first +tests_builddir = os.path.abspath(os.path.dirname(__file__)) +sys.path = [path for path in sys.path if path != tests_builddir] +sys.path.append(tests_builddir) + from gi.repository import GLib, IBus class TestOverride(unittest.TestCase): diff --git a/po/POTFILES.in b/po/POTFILES.in index ff6e8b4..29b3b76 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -5,7 +5,6 @@ bus/dbusimpl.c bus/engineproxy.c bus/inputcontext.c bus/panelproxy.c -bus/registry.c data/ibus.schemas.in ibus/__init__.py ibus/_config.py.in @@ -47,6 +46,7 @@ src/ibusinputcontext.c src/ibusobject.c src/ibuspanelservice.c src/ibusproxy.c +src/ibusregistry.c src/ibusservice.c src/ibusutil.c src/keyname-table.h diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 99d0823..8708231 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -1,7 +1,13 @@ # Files with translatable strings. # Please keep this file in alphabetical order. +# Files under ui/gtk2/ are not shipped in the distribution, but kept +# in the git repository for reference. ibus/_config.py tools/main.c +ui/gtk2/candidatepanel.py +ui/gtk2/engineabout.py +ui/gtk2/languagebar.py +ui/gtk2/panel.py ui/gtk3/application.c ui/gtk3/candidatearea.c ui/gtk3/candidatepanel.c diff --git a/src/tests/ibus-bus.c b/src/tests/ibus-bus.c index e370eb2..3492c43 100644 --- a/src/tests/ibus-bus.c +++ b/src/tests/ibus-bus.c @@ -575,14 +575,23 @@ test_get_global_engine (void) GVariant *result, *obj; IBusEngineDesc *desc = NULL; + if (!ibus_bus_set_global_engine (bus, "xkb:us::eng")) + return; + result = ibus_bus_get_ibus_property (bus, "GlobalEngine"); + g_assert (result); + obj = g_variant_get_variant (result); + g_assert (obj); + desc = IBUS_ENGINE_DESC (ibus_serializable_deserialize (obj)); + g_assert (desc); + g_assert_cmpstr (ibus_engine_desc_get_name (desc), ==, "xkb:us::eng"); + g_variant_unref (obj); g_variant_unref (result); - if (desc) - g_object_unref (desc); + g_object_unref (desc); } static void diff --git a/src/tests/ibus-configservice.c b/src/tests/ibus-configservice.c index c05e096..718e13a 100644 --- a/src/tests/ibus-configservice.c +++ b/src/tests/ibus-configservice.c @@ -33,10 +33,8 @@ gint main (gint argc, gchar **argv) { - g_mem_set_vtable (glib_mem_profiler_table); -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); + g_test_init (&argc, &argv, NULL); g_test_add_func ("/ibus/configservice", test_configservice); diff --git a/src/tests/ibus-engine.c b/src/tests/ibus-engine.c index 1c29611..225328d 100644 --- a/src/tests/ibus-engine.c +++ b/src/tests/ibus-engine.c @@ -3,17 +3,15 @@ int main() { -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); - GMainLoop *mainloop; - IBusConnection *connection; - IBusService *service; + GMainLoop *mainloop; + IBusConnection *connection; + IBusService *service; - mainloop = g_main_loop_new (NULL, FALSE); - connection = ibus_connection_open ("unix:path=/tmp/ibus-phuang/ibus--0.0"); - service = IBUS_SERVICE (ibus_engine_new ("/a/Engine", connection)); - g_main_loop_run (mainloop); - return 0; + mainloop = g_main_loop_new (NULL, FALSE); + connection = ibus_connection_open ("unix:path=/tmp/ibus-phuang/ibus--0.0"); + service = IBUS_SERVICE (ibus_engine_new ("/a/Engine", connection)); + g_main_loop_run (mainloop); + return 0; } diff --git a/src/tests/ibus-factory.c b/src/tests/ibus-factory.c index c9a6f03..7b54598 100644 --- a/src/tests/ibus-factory.c +++ b/src/tests/ibus-factory.c @@ -33,10 +33,8 @@ gint main (gint argc, gchar **argv) { - g_mem_set_vtable (glib_mem_profiler_table); -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); + g_test_init (&argc, &argv, NULL); g_test_add_func ("/ibus/factory", test_factory); diff --git a/src/tests/ibus-global-engine.c b/src/tests/ibus-global-engine.c index fd6d61a..9007af2 100644 --- a/src/tests/ibus-global-engine.c +++ b/src/tests/ibus-global-engine.c @@ -8,71 +8,68 @@ static GList *current_engine = NULL; void global_engine_changed_cb (IBusBus *bus) { - IBusEngineDesc *global_engine = ibus_bus_get_global_engine (bus); - const gchar *name = NULL; + IBusEngineDesc *global_engine = ibus_bus_get_global_engine (bus); + const gchar *name = NULL; - g_assert (global_engine); + g_assert (global_engine); - name = ibus_engine_desc_get_name (global_engine); - g_debug ("%s (id:%s, icon:%s)", - ibus_engine_desc_get_longname (global_engine), - name, - ibus_engine_desc_get_icon (global_engine)); - IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (current_engine->data); + name = ibus_engine_desc_get_name (global_engine); + g_debug ("%s (id:%s, icon:%s)", + ibus_engine_desc_get_longname (global_engine), + name, + ibus_engine_desc_get_icon (global_engine)); + IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (current_engine->data); - g_assert (strcmp (name, - ibus_engine_desc_get_name (engine_desc)) == 0); - g_object_unref (global_engine); + g_assert (strcmp (name, + ibus_engine_desc_get_name (engine_desc)) == 0); + g_object_unref (global_engine); } gboolean change_global_engine_cb (IBusBus *bus) { - if (!current_engine) - current_engine = engines; - else - current_engine = g_list_next (current_engine); + if (!current_engine) + current_engine = engines; + else + current_engine = g_list_next (current_engine); - if (!current_engine) { - ibus_quit(); - return FALSE; - } + if (!current_engine) { + ibus_quit(); + return FALSE; + } - IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (current_engine->data); + IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (current_engine->data); - ibus_bus_set_global_engine (bus, - ibus_engine_desc_get_name (engine_desc)); + ibus_bus_set_global_engine (bus, + ibus_engine_desc_get_name (engine_desc)); - return TRUE; + return TRUE; } int main() { - IBusBus *bus; + IBusBus *bus; -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif - IBUS_TYPE_ENGINE_DESC; + ibus_init (); - bus = ibus_bus_new (); - engines = ibus_bus_list_active_engines (bus); - g_assert (engines); + bus = ibus_bus_new (); + engines = ibus_bus_list_active_engines (bus); + g_assert (engines); - g_debug ("===== Global engine:"); - if (ibus_bus_get_use_global_engine (bus) == FALSE) + g_debug ("===== Global engine:"); + if (ibus_bus_get_use_global_engine (bus) == FALSE) return 0; - g_signal_connect (bus, "global-engine-changed", - G_CALLBACK (global_engine_changed_cb), bus); + g_signal_connect (bus, "global-engine-changed", + G_CALLBACK (global_engine_changed_cb), bus); - g_idle_add ((GSourceFunc)change_global_engine_cb, bus); + g_idle_add ((GSourceFunc)change_global_engine_cb, bus); - ibus_main(); + ibus_main(); - g_debug ("Test ibusbus.c's global engine api: passed."); - g_list_free (engines); - g_object_unref (bus); + g_debug ("Test ibusbus.c's global engine api: passed."); + g_list_free (engines); + g_object_unref (bus); - return 0; + return 0; } diff --git a/src/tests/ibus-inputcontext-create.c b/src/tests/ibus-inputcontext-create.c index a086f43..aca653a 100644 --- a/src/tests/ibus-inputcontext-create.c +++ b/src/tests/ibus-inputcontext-create.c @@ -10,7 +10,7 @@ * * This library 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public diff --git a/src/tests/ibus-inputcontext.c b/src/tests/ibus-inputcontext.c index f1565b0..fb6fabb 100644 --- a/src/tests/ibus-inputcontext.c +++ b/src/tests/ibus-inputcontext.c @@ -10,7 +10,7 @@ * * This library 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 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public diff --git a/src/tests/ibus-keymap.c b/src/tests/ibus-keymap.c index 24fefc4..ede5bb3 100644 --- a/src/tests/ibus-keymap.c +++ b/src/tests/ibus-keymap.c @@ -23,14 +23,12 @@ int main (int argc, char **argv) gint fd; struct input_event e; -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); IBusKeymap *keymap = ibus_keymap_get (argc > 1 ? argv[1] : "us"); g_object_unref (keymap); - return 0; + return 0; fd = open (KEYBOARDPATH, O_RDONLY); diff --git a/src/tests/ibus-keynames.c b/src/tests/ibus-keynames.c index 5809550..0793e7b 100644 --- a/src/tests/ibus-keynames.c +++ b/src/tests/ibus-keynames.c @@ -11,9 +11,8 @@ gint main (gint argc, gchar **argv) { -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); + g_test_init (&argc, &argv, NULL); g_test_add_func ("/ibus/keyname", test_keyname); diff --git a/src/tests/ibus-proxy.c b/src/tests/ibus-proxy.c index 1f46ab6..dbfb79d 100644 --- a/src/tests/ibus-proxy.c +++ b/src/tests/ibus-proxy.c @@ -4,26 +4,24 @@ static _value_changed_cb (IBusConfig *config, gchar *section, gchar *name, GValue *value, gpointer data) { - g_debug ("value-changed %s %s", section, name); + g_debug ("value-changed %s %s", section, name); } int main() { - IBusBus *bus; - IBusConfig *config; + IBusBus *bus; + IBusConfig *config; -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); - bus = ibus_bus_new (); - config = ibus_bus_get_config (bus); + bus = ibus_bus_new (); + config = ibus_bus_get_config (bus); - g_signal_connect (config, - "value-changed", - G_CALLBACK (_value_changed_cb), - NULL); - g_main_loop_run (g_main_loop_new (NULL, FALSE)); + g_signal_connect (config, + "value-changed", + G_CALLBACK (_value_changed_cb), + NULL); + g_main_loop_run (g_main_loop_new (NULL, FALSE)); - return 0; + return 0; } diff --git a/src/tests/ibus-registry.c b/src/tests/ibus-registry.c index c1cfd8a..4c61292 100644 --- a/src/tests/ibus-registry.c +++ b/src/tests/ibus-registry.c @@ -2,9 +2,8 @@ int main() { -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); + IBusRegistry *registry = ibus_registry_new (); g_object_unref (registry); return 0; diff --git a/src/tests/ibus-serializable.c b/src/tests/ibus-serializable.c index a5d8af9..82e0862 100644 --- a/src/tests/ibus-serializable.c +++ b/src/tests/ibus-serializable.c @@ -183,10 +183,8 @@ gint main (gint argc, gchar **argv) { - g_mem_set_vtable (glib_mem_profiler_table); -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); + g_test_init (&argc, &argv, NULL); g_test_add_func ("/ibus/varianttypeinfo", test_varianttypeinfo); g_test_add_func ("/ibus/attrlist", test_attr_list); diff --git a/src/tests/ibus-share.c b/src/tests/ibus-share.c index b1098ba..6ff9c2d 100644 --- a/src/tests/ibus-share.c +++ b/src/tests/ibus-share.c @@ -15,10 +15,8 @@ gint main (gint argc, gchar **argv) { - g_mem_set_vtable (glib_mem_profiler_table); -#if !GLIB_CHECK_VERSION(2,35,0) - g_type_init (); -#endif + ibus_init (); + g_test_init (&argc, &argv, NULL); g_test_add_func ("/ibus/marchine-id", test_machine_id); -- 2.7.4