From 5dcdad4db724adc12a6f927e0fba4bfa5bfc8504 Mon Sep 17 00:00:00 2001 From: Ashok Sidipotu Date: Tue, 22 Nov 2022 06:50:47 +0530 Subject: [PATCH] lua tests: give a label to the current Lua script tests This allows for Lua test scripts to be grouped into a label. So that they can be treated different in terms of the init infrastructure that the script-tester lays out for those tests. --- tests/wplua/meson.build | 14 +++++++------- tests/wplua/script-tester.c | 11 +++++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/wplua/meson.build b/tests/wplua/meson.build index 94d2f62b..0918cc7c 100644 --- a/tests/wplua/meson.build +++ b/tests/wplua/meson.build @@ -22,42 +22,42 @@ script_tester = executable('script-tester', test( 'test-lua-pod', script_tester, - args: ['pod.lua'], + args: ['lua-api-tests', 'pod.lua'], env: common_env, ) test( 'test-lua-json', script_tester, - args: ['json.lua'], + args: ['lua-api-tests', 'json.lua'], env: common_env, ) test( 'test-lua-monitor-rules', script_tester, - args: ['monitor-rules.lua'], + args: ['lua-api-tests', 'monitor-rules.lua'], env: common_env, ) test( 'test-lua-require', script_tester, - args: ['require.lua'], + args: ['lua-api-tests', 'require.lua'], env: common_env, ) test( 'test-lua-async-activation', script_tester, - args: ['async-activation.lua'], + args: ['lua-api-tests', 'async-activation.lua'], env: common_env, ) test( 'test-lua-settings', script_tester, - args: ['settings.lua'], + args: ['lua-api-tests', 'settings.lua'], env: common_env, ) test( 'test-lua-event-hooks', script_tester, - args: ['event-hooks.lua'], + args: ['lua-api-tests', 'event-hooks.lua'], env: common_env, ) diff --git a/tests/wplua/script-tester.c b/tests/wplua/script-tester.c index 566dfa2d..02a249b7 100644 --- a/tests/wplua/script-tester.c +++ b/tests/wplua/script-tester.c @@ -30,11 +30,14 @@ script_runner_teardown (ScriptRunnerFixture *f, gconstpointer data) } static void -script_run (ScriptRunnerFixture *f, gconstpointer data) +script_run (ScriptRunnerFixture *f, gconstpointer argv) { g_autoptr (WpPlugin) plugin = NULL; g_autoptr (GError) error = NULL; g_autofree gchar *pluginname = NULL; + gchar **args = (gchar **) argv; + gchar *test_type = args [1]; + gchar *test_script = args [2]; /* TODO: we could do some more stuff here to provide the test script with an API to deal with the main loop and test asynchronous stuff, if necessary */ @@ -60,11 +63,11 @@ script_run (ScriptRunnerFixture *f, gconstpointer data) NULL, (GAsyncReadyCallback) test_object_activate_finish_cb, f); g_main_loop_run (f->base.loop); } - wp_core_load_component (f->base.core, (const gchar *) data, "script/lua", + wp_core_load_component (f->base.core, (const gchar *) test_script, "script/lua", NULL, &error); g_assert_no_error (error); - pluginname = g_strdup_printf ("script:%s", (const gchar *) data); + pluginname = g_strdup_printf ("script:%s", (const gchar *) test_script); plugin = wp_plugin_find (f->base.core, pluginname); g_assert_nonnull (plugin); @@ -81,7 +84,7 @@ main (gint argc, gchar *argv[]) g_assert_cmpint (argc, >=, 1); - g_test_add ("/lua/script/run", ScriptRunnerFixture, argv[1], + g_test_add ("/lua/script/run", ScriptRunnerFixture, argv, script_runner_setup, script_run, script_runner_teardown); return g_test_run ();