Skip to content

Commit

Permalink
Really suppress pending
Browse files Browse the repository at this point in the history
  • Loading branch information
ajacksified committed Aug 15, 2014
1 parent 7d1828e commit 52f9e58
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
30 changes: 18 additions & 12 deletions busted/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,30 +72,36 @@ return function(busted)
busted.publish({ 'describe', 'end' }, describe, parent)
end

local it = function(it)
local it = function(element)
local finally

if not it.env then it.env = {} end
if not element.env then element.env = {} end

it.env.finally = function(fn)
element.env.finally = function(fn)
finally = fn
end

local parent = busted.context.parent(it)
local parent = busted.context.parent(element)

execAll('before_each', parent, true)
busted.publish({ 'test', 'start' }, it, parent)
local res = busted.safe('it', it.run, it)
if not it.env.done then
busted.publish({ 'test', 'end' }, it, parent, res and 'success' or 'failure')
if finally then busted.safe('finally', finally, it) end

busted.publish({ 'test', 'start' }, element, parent)
busted.publish({ 'test', 'foo' }, element, parent)

local res = busted.safe('element', element.run, element)
if not element.env.done then
local trace = busted.getTrace(element, 3)
busted.publish({ 'test', 'end' }, element, parent, res and 'success' or 'failure', trace)
if finally then busted.safe('finally', finally, element) end
dexecAll('after_each', parent, true)
end
end

local pending = function(pending)
local trace = busted.getTrace(pending, 3)
busted.publish({ 'test', 'end' }, pending, busted.context.parent(pending), 'pending', trace)
local pending = function(element)
local parent = busted.context.parent(pending)
local trace = busted.getTrace(element, 3)
busted.publish({ 'test', 'start' }, element, parent)
busted.publish({ 'test', 'end' }, element, parent, 'pending', trace)
end

busted.register('file', file)
Expand Down
14 changes: 12 additions & 2 deletions busted/outputHandlers/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ return function(busted)
inProgress = {}
}

handler.cancelOnPending = function(element)
return not (element.descriptor == 'pending' and handler.options.suppressPending)
end

handler.subscribe = function(handler, options)
require('busted.languages.en')
handler.options = options

if options.language ~= 'en' then
require('busted.languages.' .. options.language)
end

busted.subscribe({ 'suite', 'start' }, handler.baseSuiteStart)
busted.subscribe({ 'suite', 'end' }, handler.baseSuiteEnd)
busted.subscribe({ 'test', 'start' }, handler.baseTestStart)
busted.subscribe({ 'test', 'end' }, handler.baseTestEnd)
busted.subscribe({ 'test', 'start' }, handler.baseTestStart, { predicate = handler.cancelOnPending })
busted.subscribe({ 'test', 'end' }, handler.baseTestEnd, { predicate = handler.cancelOnPending })
busted.subscribe({ 'error' }, handler.baseError)
end

Expand Down Expand Up @@ -72,11 +77,16 @@ return function(busted)
end

handler.baseTestStart = function(element, parent)
if element.descriptor == 'pending' and handler.options.suppressPending then
return nil, false
end

handler.inProgress[tostring(element)] = {}
return nil, true
end

handler.baseTestEnd = function(element, parent, status, debug)

local insertTable
local id = tostring(element)

Expand Down
2 changes: 1 addition & 1 deletion busted/outputHandlers/junit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ return function(options, busted)

busted.subscribe({ 'suite', 'start' }, handler.suiteStart)
busted.subscribe({ 'suite', 'end' }, handler.suiteEnd)
busted.subscribe({ 'test', 'end' }, handler.testEnd)
busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending })
busted.subscribe({ 'error', 'file' }, handler.errorFile)

return handler
Expand Down
2 changes: 1 addition & 1 deletion busted/outputHandlers/plainTerminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ return function(options, busted)
return nil, true
end

busted.subscribe({ 'test', 'end' }, handler.testEnd)
busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending })
busted.subscribe({ 'suite', 'end' }, handler.suiteEnd)
busted.subscribe({ 'error', 'file' }, handler.error)
busted.subscribe({ 'error', 'describe' }, handler.error)
Expand Down
2 changes: 1 addition & 1 deletion busted/outputHandlers/utfTerminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ return function(options, busted)
return nil, true
end

busted.subscribe({ 'test', 'end' }, handler.testEnd)
local s = busted.subscribe({ 'test', 'end' }, handler.testEnd, { predicate = handler.cancelOnPending })
busted.subscribe({ 'suite', 'end' }, handler.suiteEnd)
busted.subscribe({ 'error', 'file' }, handler.error)
busted.subscribe({ 'error', 'describe' }, handler.error)
Expand Down

0 comments on commit 52f9e58

Please sign in to comment.