From 636773639ffa3a1da2b535148d13c6c895a45bc9 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 16 Jul 2018 15:31:14 +0200 Subject: [PATCH] fix(cli) fail if LuaCov is specified but unavailable 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. --- busted/modules/luacov.lua | 3 ++- busted/runner.lua | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/busted/modules/luacov.lua b/busted/modules/luacov.lua index 99cfc8f5..51a9ad33 100644 --- a/busted/modules/luacov.lua +++ b/busted/modules/luacov.lua @@ -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 @@ -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 diff --git a/busted/runner.lua b/busted/runner.lua index eefac142..6605eec1 100644 --- a/busted/runner.lua +++ b/busted/runner.lua @@ -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