Skip to content

Commit

Permalink
fix(cli) fail if LuaCov is specified but unavailable
Browse files Browse the repository at this point in the history
Fails with an error (to stderr) if `-c` was specified, but LuaCov
is not available.
Previously it would just print to stdout and continue without
coverage reporting.
  • Loading branch information
Tieske committed Jul 16, 2018
1 parent 997514a commit 6367736
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion busted/modules/luacov.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ return function()
local result, luacov = pcall(require, 'luacov.runner')

if not result then
return print('LuaCov not found on the system, try running without --coverage option, or install LuaCov first')
return nil, 'LuaCov not found on the system, try running without --coverage option, or install LuaCov first'
end

-- call it to start
Expand All @@ -16,6 +16,7 @@ return function()
table.insert(luacov.configuration.exclude, 'luassert%.')
table.insert(luacov.configuration.exclude, 'say%.')
table.insert(luacov.configuration.exclude, 'pl%.')
return true
end

return loadLuaCov
Expand Down
6 changes: 5 additions & 1 deletion busted/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ return function(options)

-- If coverage arg is passed in, load LuaCovsupport
if cliArgs.coverage then
luacov()
local ok, err = luacov()
if not ok then
io.stderr:write(appName .. ': error: ' .. err .. '\n')
exit(1, forceExit)
end
end

-- If auto-insulate is disabled, re-register file without insulation
Expand Down

0 comments on commit 6367736

Please sign in to comment.