aboutsummaryrefslogtreecommitdiff
path: root/tests/common.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common.lua')
-rw-r--r--tests/common.lua18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/common.lua b/tests/common.lua
index 63d37c0..d712c83 100644
--- a/tests/common.lua
+++ b/tests/common.lua
@@ -40,7 +40,7 @@ function serialise_table(value, indent, depth)
40 end 40 end
41 depth = depth + 1 41 depth = depth + 1
42 if depth > 50 then 42 if depth > 50 then
43 return "ERROR: Too many nested tables" 43 return "Cannot serialise any further: too many nested tables"
44 end 44 end
45 45
46 local max = is_array(value) 46 local max = is_array(value)
@@ -228,14 +228,22 @@ function run_test(testname, func, input, should_work, output)
228end 228end
229 229
230function run_test_group(testgroup, tests) 230function run_test_group(testgroup, tests)
231 function run_config(configname, func)
232 local success, msg = pcall(func)
233 print(string.format("==> Config %s: %s", configname, msg))
234 print()
235 end
236
237 function test_id(group, id)
238 return string.format("%s [%d]", group, id)
239 end
240
231 for k, v in ipairs(tests) do 241 for k, v in ipairs(tests) do
232 if type(v) == "function" then 242 if type(v) == "function" then
233 -- Useful for changing configuration during a batch 243 -- Useful for changing configuration during a batch
234 msg = v() 244 run_config(test_id(testgroup, k), v)
235 print(string.format("==> Config %s [%d]: %s", testgroup, k, msg))
236 print()
237 elseif type(v) == "table" then 245 elseif type(v) == "table" then
238 run_test(testgroup .. " [" .. k .. "]", unpack(v)) 246 run_test(test_id(testgroup, k), unpack(v))
239 else 247 else
240 error("Testgroup can only contain functions and tables") 248 error("Testgroup can only contain functions and tables")
241 end 249 end