From 44307c6e2bd88cb2a4c0a27d7e9a58a10a3ebdf6 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Thu, 25 Jun 2020 22:47:00 -0400 Subject: Report LuaCov coverage after running tests if it is enabled. Uncomment the lines near the top of *core/init.lua* to enable LuaCov. --- test/test.lua | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'test/test.lua') diff --git a/test/test.lua b/test/test.lua index f65fc921..a1ec5935 100644 --- a/test/test.lua +++ b/test/test.lua @@ -3747,14 +3747,17 @@ end print(string.format('%d tests run, %d unexpected failures, %d expected failures', tests_run, tests_failed - tests_failed_expected, tests_failed_expected)) ---if package.loaded['luacov'] then --- require('luacov').save_stats() -- TODO: this crashes every other run --- os.execute('luacov') --- local f = assert(io.open('luacov.report.out')) --- buffer:append_text(f:read('a'):match('\nSummary.+$')) --- f:close() ---else --- buffer:new_line() --- buffer:append_text('No LuaCov coverage to report.') ---end ---buffer:set_save_point() +-- Note: stock luacov crashes on hook.lua lines 51 and 58 every other run. +-- `file.max` and `file.max_hits` are both `nil`, so change comparisons to be +-- `(file.max or 0)` and `(file.max_hits or 0)`, respectively. +if package.loaded['luacov'] then + require('luacov').save_stats() + os.execute('luacov') + local f = assert(io.open('luacov.report.out')) + buffer:append_text(f:read('a'):match('\nSummary.+$')) + f:close() +else + buffer:new_line() + buffer:append_text('No LuaCov coverage to report.') +end +buffer:set_save_point() -- cgit v1.2.3