rerun all tests by default

introduce and use --resume option for ci
develop
myk002 2021-03-22 10:06:03 -07:00
parent d5d41cd374
commit 3e5a2c8d7c
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 13 additions and 13 deletions

@ -24,22 +24,23 @@ Options:
-h, --help display this help message and exit. -h, --help display this help message and exit.
-d, --test_dir specifies which directory to look in for tests. defaults to -d, --test_dir specifies which directory to look in for tests. defaults to
the "hack/scripts/test" folder in your DF installation. the "hack/scripts/test" folder in your DF installation.
-n, --nocache don't skip tests marked as completed in test_status.json.
-m, --modes only run tests in the given comma separated list of modes. -m, --modes only run tests in the given comma separated list of modes.
valid modes are 'none' (test can be run on any screen) and valid modes are 'none' (test can be run on any screen) and
'title' (test must be run on the DF title screen). if not 'title' (test must be run on the DF title screen). if not
specified, no modes are filtered. specified, no modes are filtered.
-r, --resume skip tests that have already been run. remove the
test_status.json file to reset the record.
-t, --tests only run tests that match one of the comma separated list of -t, --tests only run tests that match one of the comma separated list of
patterns. if not specified, no tests are filtered. patterns. if not specified, no tests are filtered.
Examples: Examples:
test/main runs all tests that haven't been run before test/main runs all tests
test/main -n reruns all tests test/main -r runs all tests that haven't been run before
test/main -nm none reruns tests that don't need the game to be in a test/main -m none runs tests that don't need the game to be in a
specific mode specific mode
test/main -nt quickfort reruns quickfort tests test/main -t quickfort runs quickfort tests
test/main -nd /path/to/dfhack-scripts/repo/test test/main -d /path/to/dfhack-scripts/repo/test
runs tests in your in-development branch of the runs tests in your in-development branch of the
scripts repo scripts repo
@ -49,10 +50,9 @@ arrays. For example:
{ {
"test_dir": "/home/myk/src/dfhack-scripts/test", "test_dir": "/home/myk/src/dfhack-scripts/test",
"nocache": true,
"modes": [ "none" ], "modes": [ "none" ],
"tests": [ "quickfort", "devel" ], "tests": [ "quickfort", "devel" ],
"done_command": "devel/luacov" "done_command": "devel/luacov -c"
} }
]====] ]====]
@ -428,7 +428,7 @@ local function filter_tests(tests, config)
end end
local status = {} local status = {}
if not config.nocache then if config.resume then
status = load_test_status() or status status = load_test_status() or status
for i = #tests, 1, -1 do for i = #tests, 1, -1 do
local test = tests[i] local test = tests[i]
@ -462,15 +462,15 @@ local function run_tests(tests, status, counts)
end end
local function main(args) local function main(args)
local help, nocache, test_dir, mode_filter, test_filter = local help, resume, test_dir, mode_filter, test_filter =
false, false, nil, {}, {} false, false, nil, {}, {}
local other_args = utils.processArgsGetopt(args, { local other_args = utils.processArgsGetopt(args, {
{'h', 'help', handler=function() help = true end}, {'h', 'help', handler=function() help = true end},
{'d', 'test_dir', hasArg=true, {'d', 'test_dir', hasArg=true,
handler=function(arg) test_dir = arg end}, handler=function(arg) test_dir = arg end},
{'n', 'nocache', handler=function() nocache = true end},
{'m', 'modes', hasArg=true, {'m', 'modes', hasArg=true,
handler=function(arg) mode_filter = arg:split(',') end}, handler=function(arg) mode_filter = arg:split(',') end},
{'r', 'resume', handler=function() resume = true end},
{'t', 'tests', hasArg=true, {'t', 'tests', hasArg=true,
handler=function(arg) test_filter = arg:split(',') end}, handler=function(arg) test_filter = arg:split(',') end},
}) })
@ -482,7 +482,7 @@ local function main(args)
-- override config with any params specified on the commandline -- override config with any params specified on the commandline
if test_dir then config.test_dir = test_dir end if test_dir then config.test_dir = test_dir end
if nocache then config.nocache = true end if resume then config.resume = true end
if #mode_filter > 0 then config.modes = mode_filter end if #mode_filter > 0 then config.modes = mode_filter end
if #test_filter > 0 then config.tests = test_filter end if #test_filter > 0 then config.tests = test_filter end
if #done_command > 0 then config.done_command = done_command end if #done_command > 0 then config.done_command = done_command end

@ -73,7 +73,7 @@ with open(test_init_file, 'w') as f:
f.write(''' f.write('''
devel/dump-rpc dfhack-rpc.txt devel/dump-rpc dfhack-rpc.txt
:lua dfhack.internal.addScriptPath(dfhack.getHackPath()) :lua dfhack.internal.addScriptPath(dfhack.getHackPath())
test/main "lua scr.breakdown_level=df.interface_breakdown_types.%s" test/main --resume "lua scr.breakdown_level=df.interface_breakdown_types.%s"
''' % ('NONE' if args.no_quit else 'QUIT')) ''' % ('NONE' if args.no_quit else 'QUIT'))
test_config_file = 'test_config.json' test_config_file = 'test_config.json'