Olivine-Labs/busted — pull request #245 by ajacksified (2014-06-02 18:48:40+00:00)
Title: <WIP: NOT READY> Busted v2

:warning: do not merge :warning: do not merge :warning:

A complete overhaul of busted.
---------------------------------------------

### Why?

Busted was getting more and more unwieldy; it started as a [137 line script](https://github.com/Olivine-Labs/busted/blob/61f98594a260236ffab7e3c7ce7aefdf293ce18e/busted.lua) and grew up into a real testing framework relied on by quite a few people. Over the course of that time, lots of subtle bugs have been introduced, and because it was written one hasty evening, it was hard to get away from the procedural hodgepodge it found itself in.

This overhaul moves busted towards a [mediator](https://github.com/Olivine-Labs/mediator_lua)-based system in which events are fired and captured by plugins, making busted much easier to decompose into individual components.

### Major changes

This fixes and closes most of the open issues. The only open issues remaining should be a few feature requests. Issues that will be closed by merging this PR:

* [ ] #243 - how to test out of order
* [x] #242 - C stack overflow
* [ ] #238 - Nested describe text
* [x] #231 - Crashes on test error
* [x] #229 - Sandboxing
* [ ] #225 - clean up luacov output
* [x] #223 - clean up whitespace
* [x] #220 - teardown() not called sometimes
* [ ] #200 - busted locks when error in before_each
* [x] #191 - see failures as test suite is running
* [x] #185 - add error handling for test steps
* [ ] #163 - clean dead code
* [ ] #142 - async api
* [x] #141 - refactor output handlers
* [ ] #128 odds in 18n
* [ ] #83 - randomize tests
* [ ] #57 - nested "Describe" info

Other issues, like #215, #204 will be fixed shortly after this release. Features such as #217, #62, #49, and #48 are now much more easily implementable and will follow as well.

Additionally, the async API will be cleaned up.

### Major changes to busted core developers

Most interaction with busted now happens through events. An example is:

```lua
busted.subscribe({ 'test', 'start' }, outputHandler.testStart)
```

In the above, busted emits a `{ 'test', 'start' }` event when a test is started (and an `end` when ended) that the output handler subscribes a function to. Other examples can be found throughout the code. Documentation will be released on developing busted core during or soon after this release.

### Remaining before this is RC

* [ ] Finish checking the above boxes
* [ ] Finish rewriting output handlers
* [ ] plain terminal
* [ ] TAP
* [ ] JSON
* [ ] sound
* [ ] clear up i18n odds and ends
* [ ] clear up async API
* [ ] :beers: :balloon: :cake: