From d7fa89c8b0e4e51e8cd53aa62304343f20bdbd80 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 24 Nov 2021 17:55:04 +0000 Subject: [PATCH] [Test] One more fix --- test/lua/rspamd_test_helper.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/lua/rspamd_test_helper.lua b/test/lua/rspamd_test_helper.lua index 4d58d261a..537344831 100644 --- a/test/lua/rspamd_test_helper.lua +++ b/test/lua/rspamd_test_helper.lua @@ -6,18 +6,17 @@ void rspamd_url_init (const char *tld_file); ]] local exports = {} -function exports.init_url_parser(file) - if not file then - local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1") - file = string.format('%s/unit/%s', test_dir, "test_tld.dat") - end +local function default_tld_file() + local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1") + return string.format('%s/unit/%s', test_dir, "test_tld.dat") +end - ffi.C.rspamd_url_init(file) +function exports.init_url_parser(file) + ffi.C.rspamd_url_init(file or default_tld_file()) end function exports.default_config() - local test_dir = string.gsub(debug.getinfo(1).source, "^@(.+/)[^/]+$", "%1") - local tld_file = string.format('%s/%s', test_dir, "test_tld.dat") + local tld_file = default_tld_file() local config = { options = { -- 2.39.5