diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-23 10:59:52 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-07 19:27:37 -0300 |
| commit | e287f492cafc0fb7ec6b1e1a3c64ad8fa290a224 (patch) | |
| tree | 8fb0c859aff813bd7432139372f647d19fce3a4f /src | |
| parent | 40792c08eaed0ca44b00aae04885e43c3de0701d (diff) | |
| download | luarocks-e287f492cafc0fb7ec6b1e1a3c64ad8fa290a224.tar.gz luarocks-e287f492cafc0fb7ec6b1e1a3c64ad8fa290a224.tar.bz2 luarocks-e287f492cafc0fb7ec6b1e1a3c64ad8fa290a224.zip | |
test: auto-install busted if not found
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/test/busted.lua | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/luarocks/test/busted.lua b/src/luarocks/test/busted.lua index 989f283f..a3aaed08 100644 --- a/src/luarocks/test/busted.lua +++ b/src/luarocks/test/busted.lua | |||
| @@ -2,6 +2,10 @@ | |||
| 2 | local busted = {} | 2 | local busted = {} |
| 3 | 3 | ||
| 4 | local fs = require("luarocks.fs") | 4 | local fs = require("luarocks.fs") |
| 5 | local deps = require("luarocks.deps") | ||
| 6 | local path = require("luarocks.path") | ||
| 7 | local dir = require("luarocks.dir") | ||
| 8 | local queries = require("luarocks.queries") | ||
| 5 | 9 | ||
| 6 | local unpack = table.unpack or unpack | 10 | local unpack = table.unpack or unpack |
| 7 | 11 | ||
| @@ -16,7 +20,22 @@ function busted.run_tests(test, args) | |||
| 16 | if not test then | 20 | if not test then |
| 17 | test = {} | 21 | test = {} |
| 18 | end | 22 | end |
| 19 | 23 | ||
| 24 | local ok, bustedver, where = deps.fulfill_dependency(queries.new("busted")) | ||
| 25 | if not ok then | ||
| 26 | return nil, bustedver | ||
| 27 | end | ||
| 28 | |||
| 29 | local busted_exe | ||
| 30 | if test.busted_executable then | ||
| 31 | busted_exe = test.busted_executable | ||
| 32 | else | ||
| 33 | busted_exe = dir.path(path.root_dir(where), "bin", "busted") | ||
| 34 | if not fs.exists(busted_exe) then | ||
| 35 | return nil, "'busted' executable failed to be installed" | ||
| 36 | end | ||
| 37 | end | ||
| 38 | |||
| 20 | if type(test.flags) == "table" then | 39 | if type(test.flags) == "table" then |
| 21 | -- insert any flags given in test.flags at the front of args | 40 | -- insert any flags given in test.flags at the front of args |
| 22 | for i = 1, #test.flags do | 41 | for i = 1, #test.flags do |
| @@ -24,7 +43,12 @@ function busted.run_tests(test, args) | |||
| 24 | end | 43 | end |
| 25 | end | 44 | end |
| 26 | 45 | ||
| 27 | return fs.execute("busted", unpack(args)) | 46 | local ok, err = fs.execute(busted_exe, unpack(args)) |
| 47 | if ok then | ||
| 48 | return true | ||
| 49 | else | ||
| 50 | return nil, err or "test suite failed." | ||
| 51 | end | ||
| 28 | end | 52 | end |
| 29 | 53 | ||
| 30 | 54 | ||
