From a312336f86a5d511512f4e01c3bd112ed0aeb782 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 27 Mar 2020 00:34:44 -0400 Subject: [PATCH] Add (placeholder) support for specifying which game mode tests should run in --- test/main.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/main.lua b/test/main.lua index 5d2d94732..717e3a13f 100644 --- a/test/main.lua +++ b/test/main.lua @@ -12,6 +12,8 @@ local TestStatus = { FAILED = 'failed', } +local VALID_MODES = utils.invert{'none', 'fortress'} + expect = {} function expect.true_(value, comment) return not not value, comment, 'expected true' @@ -42,6 +44,9 @@ end function build_test_env() local env = { test = utils.OrderedTable(), + config = { + mode = 'none', + }, expect = {}, delay = delay, } @@ -116,11 +121,16 @@ function load_tests(file, tests) dfhack.printerr('Error when running file: ' .. tostring(err)) return false else + if not VALID_MODES[env.config.mode] then + dfhack.printerr('Invalid config.mode: ' .. env.config.mode) + return false + end for name, test_func in pairs(env.test) do local test_data = { full_name = short_filename .. ':' .. name, func = test_func, private = env_private, + config = env.config, } test_data.name = test_data.full_name:gsub('test/', ''):gsub('.lua', '') table.insert(tests, test_data)