diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/tests.lua | 8 | ||||
-rw-r--r-- | test/rspamd_lua_test.c | 6 | ||||
-rw-r--r-- | test/rspamd_test_suite.c | 3 |
3 files changed, 16 insertions, 1 deletions
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 } }; |