Olivine-Labs/busted — pull request #122 by leafo (2013-04-26 06:37:30+00:00)
Title: Fix error message when there are no test files

Right now if you run busted in some random directly with no tests it does this:

```
luajit: /home/leafo/.luarocks/share/lua/5.1/busted/core.lua:393: attempt to index upvalue 'current_context' (a nil value)
stack traceback:
/home/leafo/.luarocks/share/lua/5.1/busted/core.lua:393: in function 'describe'
/home/leafo/.luarocks/share/lua/5.1/busted/core.lua:32: in function 'internal_error'
/home/leafo/.luarocks/share/lua/5.1/busted/core.lua:89: in function 'gettestfiles'
/home/leafo/.luarocks/share/lua/5.1/busted/core.lua:606: in function 'busted'
/home/leafo/.luarocks/bin/busted_bootstrap:119: in main chunk
[C]: at 0x00404f90

```

This patch makes it do what you probably intended:

```
$ > busted
●
0 successes / 1 failure / 0 pending : 0.01 seconds.

Failure → /home/leafo/.luarocks/share/lua/5.1/busted/core.lua @ 38
Getting test files
/home/leafo/.luarocks/share/lua/5.1/busted/core.lua:39: No test files found for path './spec' and pattern `_spec.lua$`. Please review your commandline, re-run with `--help` for usage.
```

There are two changes, I made sure a context exists when calling `internal_error`. Second, I made it so `busted.run` runs the suite if it already has tests. I don't know if this breaks anything else, are there any circumstances where `busted.run` is executed multiple times?