aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-06-25 22:47:00 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-06-25 22:47:00 -0400
commit44307c6e2bd88cb2a4c0a27d7e9a58a10a3ebdf6 (patch)
tree5f8d1d1c763a8c89a5f1eca99e633ed0d26f7a73
parent1ed04b43a69c0c10d9df49c3fd5e34c98aff8fdf (diff)
downloadtextadept-44307c6e2bd88cb2a4c0a27d7e9a58a10a3ebdf6.tar.gz
textadept-44307c6e2bd88cb2a4c0a27d7e9a58a10a3ebdf6.zip
Report LuaCov coverage after running tests if it is enabled.
Uncomment the lines near the top of *core/init.lua* to enable LuaCov.
-rw-r--r--test/test.lua25
1 files changed, 14 insertions, 11 deletions
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()