From: Mikhail Galanin Date: Thu, 20 Sep 2018 10:26:36 +0000 (+0100) Subject: [Test] Pass test-case patten into test engine X-Git-Tag: 1.8.0~55^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=99b68e8e51215eab50d33b5af0e0e12b1b497e1e;p=rspamd.git [Test] Pass test-case patten into test engine So that now we can set which test cases should be runned: $ ./test/rspamd-test -p /rspamd/lua -t selectors.lua -c "case .* rcpts" $ ./test/rspamd-test -p /rspamd/lua -c "case 1st rcpts" -c accepts Lua-pattern --- diff --git a/test/lua/tests.lua b/test/lua/tests.lua index 99d509de0..6c05e02e0 100644 --- a/test/lua/tests.lua +++ b/test/lua/tests.lua @@ -8,8 +8,14 @@ local contexts = {} for _,t in ipairs(tests_list) do telescope.load_contexts(t, contexts) end +local function test_filter(test) + return test.name:match(test_pattern) +end +if not test_pattern then + test_filter = function(_) return true end +end local buffer = {} -local results = telescope.run(contexts, callbacks, test_pattern) +local results = telescope.run(contexts, callbacks, test_filter) local summary, data = telescope.summary_report(contexts, results) table.insert(buffer, telescope.test_report(contexts, results)) diff --git a/test/rspamd_lua_test.c b/test/rspamd_lua_test.c index b87df0f58..15dd3923b 100644 --- a/test/rspamd_lua_test.c +++ b/test/rspamd_lua_test.c @@ -25,6 +25,7 @@ static const char *lua_src = BUILDROOT "/test/lua/tests.lua"; extern gchar *lua_test; +extern gchar *lua_test_case; extern struct rspamd_main *rspamd_main; static int @@ -65,6 +66,11 @@ rspamd_lua_test_func (void) rspamd_lua_set_globals (rspamd_main->cfg, L, NULL); + if (lua_test_case) { + lua_pushstring (L, lua_test_case); + lua_setglobal (L, "test_pattern"); + } + rspamd_printf ("Starting lua tests\n"); if ((rp = realpath (lua_src, rp_buf)) == NULL) { diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c index 0be3091d9..10a5d941b 100644 --- a/test/rspamd_test_suite.c +++ b/test/rspamd_test_suite.c @@ -8,12 +8,15 @@ struct event_base *base = NULL; worker_t *workers[] = { NULL }; gchar *lua_test = NULL; +gchar *lua_test_case = NULL; gboolean verbose = FALSE; static GOptionEntry entries[] = { { "test", 't', 0, G_OPTION_ARG_STRING, &lua_test, "Lua test to run (i.e. selectors.lua)", NULL }, + { "test-case", 'c', 0, G_OPTION_ARG_STRING, &lua_test_case, + "Lua test to run, lua pattern i.e. \"case .* rcpts\"", NULL }, { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } };