Skip to content

Commit

Permalink
feat(busted): add keep-going option
Browse files Browse the repository at this point in the history
  • Loading branch information
rish987 committed Jul 27, 2021
1 parent 8bae2c1 commit e863240
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lua/plenary/busted.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ local current_description = {}
local current_before_each = {}
local current_after_each = {}

local abort = false
local run_opts = {}

local add_description = function(desc)
table.insert(current_description, desc)

Expand Down Expand Up @@ -104,6 +107,7 @@ end
local SUCCESS = color_string("green", "Success")
local FAIL = color_string("red", "Fail")
local PENDING = color_string("yellow", "Pending")
local ABORTED = color_string("yellow", "Aborted")

local HEADER = string.rep("=", 40)

Expand Down Expand Up @@ -174,6 +178,11 @@ local run_each = function(tbl)
end

mod.it = function(desc, func)
if abort then
print(ABORTED, "||", table.concat(current_description, " "), desc)
return
end

run_each(current_before_each)
local ok, msg, desc_stack = call_inner(desc, func)
run_each(current_after_each)
Expand All @@ -193,6 +202,10 @@ mod.it = function(desc, func)

print(FAIL, "||", table.concat(test_result.descriptions, " "))
print(indent(msg, 12))

if not run_opts.keep_going then
abort = true
end
else
to_insert = results.pass
print(SUCCESS, "||", table.concat(test_result.descriptions, " "))
Expand All @@ -218,7 +231,21 @@ after_each = mod.after_each
clear = mod.clear
assert = require("luassert")

mod.run = function(file)
function mod.run_command(command)
local split_string = vim.split(command, " ")
local file = table.remove(split_string, 1)

local opts = {}
if #split_string > 0 then
opts = assert(loadstring('return ' .. table.concat(split_string, " ")))()
end

return mod.run(file, opts)
end

mod.run = function(file, opts)
run_opts = opts or {}

print("\n" .. HEADER)
print("Testing: ", file)

Expand Down

0 comments on commit e863240

Please sign in to comment.