display "<1" instead of "0" for fast tests

develop
myk002 2021-06-10 10:00:47 -07:00
parent 95234aa8ee
commit ec74560bd3
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 7 additions and 2 deletions

@ -421,6 +421,10 @@ local function wrap_test(func)
) )
end end
local function get_elapsed_str(elapsed)
return elapsed < 1 and "<1" or tostring(elapsed)
end
local function run_test(test, status, counts) local function run_test(test, status, counts)
test.private.checks = 0 test.private.checks = 0
test.private.checks_ok = 0 test.private.checks_ok = 0
@ -437,7 +441,8 @@ local function run_test(test, status, counts)
elseif test.private.checks ~= test.private.checks_ok then elseif test.private.checks ~= test.private.checks_ok then
dfhack.printerr('test failed: ' .. test.name) dfhack.printerr('test failed: ' .. test.name)
else else
print(('test passed in %d ms: %s'):format(elapsed_ms, test.name)) local elapsed_str = get_elapsed_str(elapsed_ms)
print(('test passed in %s ms: %s'):format(elapsed_str, test.name))
passed = true passed = true
counts.tests_ok = counts.tests_ok + 1 counts.tests_ok = counts.tests_ok + 1
end end
@ -551,7 +556,7 @@ local function run_tests(tests, status, counts, config)
end end
status['*'] = status['*'] or TestStatus.PASSED status['*'] = status['*'] or TestStatus.PASSED
print(('\nTests completed in %d ms:'):format(elapsed_ms)) print(('\nTests completed in %s ms:'):format(get_elapsed_str(elapsed_ms)))
print_summary_line(counts.tests_ok == counts.tests, print_summary_line(counts.tests_ok == counts.tests,
('%d/%d tests passed'):format(counts.tests_ok, counts.tests)) ('%d/%d tests passed'):format(counts.tests_ok, counts.tests))
print_summary_line(counts.checks_ok == counts.checks, print_summary_line(counts.checks_ok == counts.checks,