aboutsummaryrefslogtreecommitdiffstats
path: root/test/rspamd_lua_test.c
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-19 15:42:38 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-19 15:42:38 +0100
commit57d19346b6ff61c360ce5d1653d1e25118277c88 (patch)
tree8cc845db0d615031b3dbe1831fc28419287aa236 /test/rspamd_lua_test.c
parent50d51fca34585b51c1e6ecd168bda6e9e48b0bb2 (diff)
downloadrspamd-57d19346b6ff61c360ce5d1653d1e25118277c88.tar.gz
rspamd-57d19346b6ff61c360ce5d1653d1e25118277c88.zip
[Test] Added key to run specifig lua-test
example: $ ./test/rspamd-test -p /rspamd/lua -t selectors.lua no way to run two test suites atm
Diffstat (limited to 'test/rspamd_lua_test.c')
-rw-r--r--test/rspamd_lua_test.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/rspamd_lua_test.c b/test/rspamd_lua_test.c
index 0c785e9e6..b87df0f58 100644
--- a/test/rspamd_lua_test.c
+++ b/test/rspamd_lua_test.c
@@ -24,6 +24,8 @@
#endif
static const char *lua_src = BUILDROOT "/test/lua/tests.lua";
+extern gchar *lua_test;
+extern struct rspamd_main *rspamd_main;
static int
traceback (lua_State *L)
@@ -61,6 +63,8 @@ rspamd_lua_test_func (void)
glob_t globbuf;
gint i, len;
+ rspamd_lua_set_globals (rspamd_main->cfg, L, NULL);
+
rspamd_printf ("Starting lua tests\n");
if ((rp = realpath (lua_src, rp_buf)) == NULL) {
@@ -90,11 +94,27 @@ rspamd_lua_test_func (void)
pattern = g_malloc (len);
rspamd_snprintf (pattern, len, "%s/unit/%s", dir, "*.lua");
+ gint lua_test_len = 0;
+ gint inserted_file = 1;
+ gint path_start;
+ if (lua_test) {
+ lua_test_len = strlen (lua_test);
+ }
if (glob (pattern, GLOB_DOOFFS, NULL, &globbuf) == 0) {
for (i = 0; i < (gint)globbuf.gl_pathc; i++) {
- lua_pushinteger (L, i + 1);
+ if (lua_test) {
+ path_start = strlen (globbuf.gl_pathv[i]) - lua_test_len;
+ if (path_start < 0 ||
+ strncmp (globbuf.gl_pathv[i] + path_start, lua_test, lua_test_len) != 0) {
+ continue;
+ }
+ }
+
+ lua_pushinteger (L, inserted_file);
lua_pushstring (L, globbuf.gl_pathv[i]);
lua_settable (L, -3);
+
+ inserted_file ++;
}
globfree (&globbuf);
g_free (pattern);