From 0384fa9175c3b0e8f7671ffc2a5b1292c4cd5874 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Fri, 21 Aug 2015 19:54:51 +0300 Subject: [PATCH] add python test for glib and test against lib print->print_message is caused because GI does print->print_ in python bindings which is not good. Signed-off-by: Igor Gnatenko --- .../frameworks/7 gnome/gir/meson-sample.c | 18 ++++++++++++++++- .../frameworks/7 gnome/gir/meson-sample.h | 4 ++-- test cases/frameworks/7 gnome/gir/meson.build | 20 +++++++++++++++---- test cases/frameworks/7 gnome/gir/prog.c | 4 ++-- test cases/frameworks/7 gnome/gir/prog.py | 6 ++++++ .../frameworks/7 gnome/installed_files.txt | 1 + 6 files changed, 44 insertions(+), 9 deletions(-) create mode 100755 test cases/frameworks/7 gnome/gir/prog.py diff --git a/test cases/frameworks/7 gnome/gir/meson-sample.c b/test cases/frameworks/7 gnome/gir/meson-sample.c index 8f467085f..dbf3625db 100644 --- a/test cases/frameworks/7 gnome/gir/meson-sample.c +++ b/test cases/frameworks/7 gnome/gir/meson-sample.c @@ -17,6 +17,14 @@ enum { static GParamSpec *gParamSpecs [LAST_PROP]; +/** + * meson_sample_new: + * @msg: The message to set. + * + * Allocates a new #MesonSample. + * + * Returns: (transfer full): a #MesonSample. + */ MesonSample * meson_sample_new (const gchar *msg) { @@ -99,8 +107,16 @@ meson_sample_init (MesonSample *self) { } +/** + * meson_sample_print_message: + * @self: a #MesonSample. + * + * Prints the message. + * + * Returns: Nothing. + */ void -meson_sample_print (MesonSample *self) +meson_sample_print_message (MesonSample *self) { g_return_if_fail (MESON_IS_SAMPLE (self)); diff --git a/test cases/frameworks/7 gnome/gir/meson-sample.h b/test cases/frameworks/7 gnome/gir/meson-sample.h index 0bbe9dbfb..cd2bbc6a6 100644 --- a/test cases/frameworks/7 gnome/gir/meson-sample.h +++ b/test cases/frameworks/7 gnome/gir/meson-sample.h @@ -13,8 +13,8 @@ G_BEGIN_DECLS G_DECLARE_FINAL_TYPE (MesonSample, meson_sample, MESON, SAMPLE, GObject) -MesonSample *meson_sample_new (const gchar *msg); -void meson_sample_print (MesonSample *self); +MesonSample *meson_sample_new (const gchar *msg); +void meson_sample_print_message (MesonSample *self); G_END_DECLS diff --git a/test cases/frameworks/7 gnome/gir/meson.build b/test cases/frameworks/7 gnome/gir/meson.build index c5fce63b8..32884dbfa 100644 --- a/test cases/frameworks/7 gnome/gir/meson.build +++ b/test cases/frameworks/7 gnome/gir/meson.build @@ -1,13 +1,21 @@ libsources = ['meson-sample.c', 'meson-sample.h'] +girlib = shared_library( + 'girlib', + sources : libsources, + dependencies : gobj, + install : true +) + girexe = executable( 'girprog', - sources : [libsources, 'prog.c'], - dependencies : [glib, gobj, gir] + sources : 'prog.c', + dependencies : [glib, gobj, gir], + link_with : girlib ) gnome.generate_gir( - girexe, + girlib, sources : libsources, nsversion : '1.0', namespace : 'Meson', @@ -17,4 +25,8 @@ gnome.generate_gir( install : true ) -test('gobject introspection', girexe) +test('gobject introspection/c', girexe) +test('gobject introspection/py', find_program('prog.py'), + env : ['GI_TYPELIB_PATH=@0@'.format(meson.current_build_dir()), + 'LD_LIBRARY_PATH=@0@'.format(meson.current_build_dir()), + ]) diff --git a/test cases/frameworks/7 gnome/gir/prog.c b/test cases/frameworks/7 gnome/gir/prog.c index 64e3cdc58..1116285dd 100644 --- a/test cases/frameworks/7 gnome/gir/prog.c +++ b/test cases/frameworks/7 gnome/gir/prog.c @@ -16,8 +16,8 @@ main (gint argc, return 1; } - g_autoptr(MesonSample) i = meson_sample_new ("Hello, meson!"); - meson_sample_print (i); + g_autoptr(MesonSample) i = meson_sample_new ("Hello, meson/c!"); + meson_sample_print_message (i); return 0; } diff --git a/test cases/frameworks/7 gnome/gir/prog.py b/test cases/frameworks/7 gnome/gir/prog.py new file mode 100755 index 000000000..717d08a86 --- /dev/null +++ b/test cases/frameworks/7 gnome/gir/prog.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 +from gi.repository import Meson + +if __name__ == "__main__": + s = Meson.Sample.new("Hello, meson/py!") + s.print_message() diff --git a/test cases/frameworks/7 gnome/installed_files.txt b/test cases/frameworks/7 gnome/installed_files.txt index 846483988..741d9b80c 100644 --- a/test cases/frameworks/7 gnome/installed_files.txt +++ b/test cases/frameworks/7 gnome/installed_files.txt @@ -1,3 +1,4 @@ usr/lib/girepository-1.0/Meson-1.0.typelib +usr/lib/libgirlib.so usr/share/gir-1.0/Meson-1.0.gir usr/share/glib-2.0/schemas/com.github.meson.gschema.xml