Clean up test skipping logic

develop
lethosor 2020-03-27 00:49:34 -04:00
parent 82aa467c66
commit e6c9db0a18
1 changed files with 25 additions and 23 deletions

@ -141,7 +141,6 @@ function load_tests(file, tests)
end end
function run_test(test, status, counts) function run_test(test, status, counts)
if status[test.full_name] == TestStatus.PENDING then
test.private.checks = 0 test.private.checks = 0
test.private.checks_ok = 0 test.private.checks_ok = 0
counts.tests = counts.tests + 1 counts.tests = counts.tests + 1
@ -158,11 +157,7 @@ function run_test(test, status, counts)
end end
counts.checks = counts.checks + (tonumber(test.private.checks) or 0) counts.checks = counts.checks + (tonumber(test.private.checks) or 0)
counts.checks_ok = counts.checks_ok + (tonumber(test.private.checks_ok) or 0) counts.checks_ok = counts.checks_ok + (tonumber(test.private.checks_ok) or 0)
status[test.full_name] = passed and TestStatus.PASSED or TestStatus.FAILED return passed
save_test_status(status)
else
print('test skipped: ' .. test.name .. ' (state = ' .. status[test.full_name] .. ')')
end
end end
function main() function main()
@ -201,16 +196,23 @@ function main()
end end
end end
print('Filtering tests')
local status = load_test_status() or {} local status = load_test_status() or {}
for _, test in pairs(tests) do for i = #tests, 1, -1 do
local test = tests[i]
if not status[test.full_name] then if not status[test.full_name] then
status[test.full_name] = TestStatus.PENDING status[test.full_name] = TestStatus.PENDING
elseif status[test.full_name] ~= TestStatus.PENDING then
print('skipping test: ' .. test.name .. ': state = ' .. status[test.full_name] .. ')')
table.remove(tests, i)
end end
end end
print('Running tests') print('Running ' .. #tests .. ' tests')
for _, test in pairs(tests) do for _, test in pairs(tests) do
run_test(test, status, counts) local passed = run_test(test, status, counts)
status[test.full_name] = passed and TestStatus.PASSED or TestStatus.FAILED
save_test_status(status)
end end
print('\nTest summary:') print('\nTest summary:')