Diff options
Diffstat (limited to 'tests/extensions/harness.lua')
| -rw-r--r-- | tests/extensions/harness.lua | 16 |
1 file changed, 16 insertions, 0 deletions
diff --git a/tests/extensions/harness.lua b/tests/extensions/harness.lua index 8c1ba6c..b54f727 100644 --- a/tests/extensions/harness.lua +++ b/tests/extensions/harness.lua @@ -82,6 +82,22 @@ function harness.load(script) dofile(script) end +-- The mode a t05xx script names after the script path, which has to be one +-- of those given, so a misspelt mode fails instead of quietly running +-- another one. Lua 5.1 gives a function taking ... a local arg of its own, +-- nil here, so the script's arguments are read from the global table. +function harness.mode(...) + local known = { ... } + local wanted = _G.arg[2] + for _, mode in ipairs(known) do + if wanted == mode then + return mode + end + end + error("unknown mode " .. tostring(wanted) .. ", wanted one of " .. + table.concat(known, ", ")) +end + -- Load a script with some of its own text replaced first, for checks that -- need the commented-out examples of its configuration switched on. Each -- replacement has to match exactly once, so a reworded example fails here |
