gplugin/gplugin

Get the test harness to pass for vala plugins
feature/vala
2019-07-17, Gary Kramlich
69ac46771479
Parents fb76a67952da
Children 147a92cc705e
Get the test harness to pass for vala plugins
--- a/gplugin/meson.build Wed Jul 17 08:49:43 2019 -0500
+++ b/gplugin/meson.build Wed Jul 17 10:38:15 2019 -0500
@@ -245,6 +245,7 @@
GPLUGIN_PUBLIC_BUILT_SOURCES +
GPLUGIN_PUBLIC_BUILT_HEADERS,
includes : ['GModule-2.0', 'GObject-2.0'],
+ header : 'gplugin.h',
namespace : 'GPlugin',
symbol_prefix : 'gplugin',
nsversion : '@0@.0'.format(GPLUGIN_MAJOR_VERSION),
--- a/vala/meson.build Wed Jul 17 08:49:43 2019 -0500
+++ b/vala/meson.build Wed Jul 17 10:38:15 2019 -0500
@@ -3,19 +3,12 @@
error('Vala generation requires GObject Introspection.')
endif
- vapigen = find_program('vapigen')
+ add_languages('vala')
- # regular gplugin vapi
- custom_target(
- 'gplugin.vapi',
- command : [
- vapigen,
- '--library', 'gplugin',
- '--directory', meson.current_build_dir(),
- gplugin_gir,
- ],
- output : 'gplugin.vapi',
+ gplugin_vapi = gnome.generate_vapi('gplugin',
+ sources : gplugin_gir[0],
install : true,
- install_dir : join_paths(get_option('datadir'), 'vala', 'vapi'),
)
+
+ subdir('tests')
endif # vala
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/meson.build Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,14 @@
+if get_option('vapi')
+
+e = executable('test-vala-loading', 'test-vala-loading.c',
+ include_directories : include_directories('.'),
+ c_args : [
+ '-DVALA_PLUGIN_DIR="@0@/plugins"'.format(meson.current_build_dir()),
+ ],
+ link_with : gplugin_loader_tests,
+ dependencies : [GLIB, GOBJECT, gplugin_dep])
+test('Vala loading', e)
+
+subdir('plugins')
+
+endif # vapi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/basic.vala Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class BasicPluginInfo : GPlugin.PluginInfo {
+ public BasicPluginInfo() {
+ string[] authors = {"author1"};
+
+ Object(
+ id: "gplugin/vala-basic-plugin",
+ abi_version: 0x01020304,
+ name: "basic plugin",
+ authors: authors,
+ category: "test",
+ version: "version",
+ license_id: "license",
+ summary: "summary",
+ website: "website",
+ description: "description"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ return new BasicPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ return true;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/dependent.vala Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class DependentPluginInfo : GPlugin.PluginInfo {
+ public DependentPluginInfo() {
+ string[] dependencies = {"dependency1", "dependency2"};
+
+ Object(
+ id: "gplugin/vala-dependent-plugin",
+ dependencies: dependencies
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ return new DependentPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ return true;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ return false;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/load-exception.vala Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class LoadExceptionPluginInfo : GPlugin.PluginInfo {
+ public LoadExceptionPluginInfo() {
+ Object(
+ id: "gplugin/vala-load-exception"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ return new LoadExceptionPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ error = new Error(Quark.from_string("gplugin"), 0, "explode");
+
+ return false;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/load-failed.vala Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class LoadFailedPluginInfo : GPlugin.PluginInfo {
+ public LoadFailedPluginInfo() {
+ Object(
+ id: "gplugin/vala-load-failed"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ return new LoadFailedPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ return false;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ return true;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/meson.build Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,17 @@
+if get_option('vapi')
+ shared_library('vala-basic-plugin', 'basic.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-dependent-plugin', 'dependent.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-load-exception', 'load-exception.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-load-failed', 'load-failed.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+ shared_library('vala-unload-failed', 'unload-failed.vala',
+ name_prefix : '',
+ dependencies : [gplugin_dep, gplugin_vapi])
+endif # vapi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/plugins/unload-failed.vala Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+using GPlugin;
+
+public class UnloadFailedPluginInfo : GPlugin.PluginInfo {
+ public UnloadFailedPluginInfo() {
+ Object(
+ id: "gplugin/vala-unload-failed"
+ );
+ }
+}
+
+public GPlugin.PluginInfo gplugin_query(out Error error) {
+ return new UnloadFailedPluginInfo();
+}
+
+public bool gplugin_load(GPlugin.Plugin plugin, out Error error) {
+ return true;
+}
+
+public bool gplugin_unload(GPlugin.Plugin plugin, out Error error) {
+ return false;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/vala/tests/test-vala-loading.c Wed Jul 17 10:38:15 2019 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011-2019 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <gplugin.h>
+
+#include <gplugin/gplugin-loader-tests.h>
+
+/******************************************************************************
+ * Main
+ *****************************************************************************/
+gint
+main(gint argc, gchar **argv) {
+ g_test_init(&argc, &argv, NULL);
+
+ gplugin_loader_tests_main(NULL, VALA_PLUGIN_DIR, "vala");
+
+ return g_test_run();
+}
+