aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-04-23 10:59:52 -0300
committerHisham Muhammad <hisham@gobolinux.org>2018-05-07 19:27:37 -0300
commite287f492cafc0fb7ec6b1e1a3c64ad8fa290a224 (patch)
tree8fb0c859aff813bd7432139372f647d19fce3a4f
parent40792c08eaed0ca44b00aae04885e43c3de0701d (diff)
downloadluarocks-e287f492cafc0fb7ec6b1e1a3c64ad8fa290a224.tar.gz
luarocks-e287f492cafc0fb7ec6b1e1a3c64ad8fa290a224.tar.bz2
luarocks-e287f492cafc0fb7ec6b1e1a3c64ad8fa290a224.zip
test: auto-install busted if not found
-rw-r--r--src/luarocks/test/busted.lua28
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 @@
2local busted = {} 2local busted = {}
3 3
4local fs = require("luarocks.fs") 4local fs = require("luarocks.fs")
5local deps = require("luarocks.deps")
6local path = require("luarocks.path")
7local dir = require("luarocks.dir")
8local queries = require("luarocks.queries")
5 9
6local unpack = table.unpack or unpack 10local 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
28end 52end
29 53
30 54