Olivine-Labs/busted — pull request #118 by lipp (2013-04-23 09:37:14+00:00)
Title: Async support 2

# Changes

## Allow async tests

Specifying `before_each`,`after_each`,`setup`,`teardown` and `it` to run async:

```lua
local ev = require'ev'
local timer = function(on_timeout)
ev.Timer.new(function()
on_timeout()
end,0.01):start(ev.Loop.default)
end

-- specify the loop framework ('copas' or 'ev')
setloop('ev')

describe('Some async stuff',function()
before(
async,-- Specify "async" as first arg / replacement for the busted callback.
function(done)-- The following arg is the async busted callback.
timer(-- Setup an async before action.
function()
done()-- The async callback must call "done" to proceed
end
)
end)

it('make some async test',async,function(done)
timer(-- Sets up an async callback
guard(-- The callback must be wrapped in "guard",
-- to allow busted to keep track of all errors etc
function()
assert.is_true(true)-- Use any assertion library
done()-- Call "done" to proceed with the next test step.
-- This might be calling "after_each",
-- "before_each","it" .. depending on your suite.
end)
)
end)
end)

```
At the moment lua-ev and copas are supported.

## More tests

Checkout https://github.com/lipp/busted/blob/async-test-support/spec/execution_order_ev_spec.lua and other newly added specs.

# Implementation Notes

- run loop reimplementation
- Interface to output modules' `header` and `footer` method have changes
- based on this PR: https://github.com/Olivine-Labs/busted/pull/98