aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2022-06-06 15:27:10 -0300
committerHisham Muhammad <hisham@gobolinux.org>2022-06-06 17:14:52 -0300
commit292a274fd02b88a729d474b544829c53e138a57b (patch)
tree1bf99dc562bf6682d3e131a922b3e5d2172258ca
parent4ef2c181d9f76d01c1a6b58232e5d0dfe8679bf7 (diff)
downloadluarocks-292a274fd02b88a729d474b544829c53e138a57b.tar.gz
luarocks-292a274fd02b88a729d474b544829c53e138a57b.tar.bz2
luarocks-292a274fd02b88a729d474b544829c53e138a57b.zip
test: perform variable substitutions in test.flags
-rw-r--r--src/luarocks/cmd/test.lua4
-rw-r--r--src/luarocks/test.lua11
-rw-r--r--src/luarocks/test/busted.lua7
-rw-r--r--src/luarocks/test/command.lua7
4 files changed, 13 insertions, 16 deletions
diff --git a/src/luarocks/cmd/test.lua b/src/luarocks/cmd/test.lua
index be9a5dfb..b353bd80 100644
--- a/src/luarocks/cmd/test.lua
+++ b/src/luarocks/cmd/test.lua
@@ -24,7 +24,7 @@ to separate LuaRocks arguments from test suite arguments.]],
24 cmd:argument("args", "Test suite arguments.") 24 cmd:argument("args", "Test suite arguments.")
25 :args("*") 25 :args("*")
26 cmd:flag("--prepare", "Only install dependencies needed for testing only, but do not run the test") 26 cmd:flag("--prepare", "Only install dependencies needed for testing only, but do not run the test")
27 27
28 cmd:option("--test-type", "Specify the test suite type manually if it was ".. 28 cmd:option("--test-type", "Specify the test suite type manually if it was "..
29 "not specified in the rockspec and it could not be auto-detected.") 29 "not specified in the rockspec and it could not be auto-detected.")
30 :argname("<type>") 30 :argname("<type>")
@@ -41,7 +41,7 @@ function cmd_test.command(args)
41 if not rockspec then 41 if not rockspec then
42 return nil, err 42 return nil, err
43 end 43 end
44 44
45 return test.run_test_suite(rockspec, args.test_type, args.args, args.prepare) 45 return test.run_test_suite(rockspec, args.test_type, args.args, args.prepare)
46end 46end
47 47
diff --git a/src/luarocks/test.lua b/src/luarocks/test.lua
index cf475fd3..ef801a9d 100644
--- a/src/luarocks/test.lua
+++ b/src/luarocks/test.lua
@@ -3,6 +3,7 @@ local test = {}
3 3
4local fetch = require("luarocks.fetch") 4local fetch = require("luarocks.fetch")
5local deps = require("luarocks.deps") 5local deps = require("luarocks.deps")
6local util = require("luarocks.util")
6 7
7local test_types = { 8local test_types = {
8 "busted", 9 "busted",
@@ -71,6 +72,16 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare)
71 if prepare then 72 if prepare then
72 return test_mod.run_tests(rockspec_arg, {"--version"}) 73 return test_mod.run_tests(rockspec_arg, {"--version"})
73 else 74 else
75 local flags = rockspec.test and rockspec.test.flags
76 if type(flags) == "table" then
77 util.variable_substitutions(flags, rockspec.variables)
78
79 -- insert any flags given in test.flags at the front of args
80 for i = 1, #flags do
81 table.insert(args, i, flags[i])
82 end
83 end
84
74 return test_mod.run_tests(rockspec.test, args) 85 return test_mod.run_tests(rockspec.test, args)
75 end 86 end
76end 87end
diff --git a/src/luarocks/test/busted.lua b/src/luarocks/test/busted.lua
index 8fa78804..c73909cf 100644
--- a/src/luarocks/test/busted.lua
+++ b/src/luarocks/test/busted.lua
@@ -40,13 +40,6 @@ function busted.run_tests(test, args)
40 end 40 end
41 end 41 end
42 42
43 if type(test.flags) == "table" then
44 -- insert any flags given in test.flags at the front of args
45 for i = 1, #test.flags do
46 table.insert(args, i, test.flags[i])
47 end
48 end
49
50 local err 43 local err
51 ok, err = fs.execute(busted_exe, unpack(args)) 44 ok, err = fs.execute(busted_exe, unpack(args))
52 if ok then 45 if ok then
diff --git a/src/luarocks/test/command.lua b/src/luarocks/test/command.lua
index 1795c4e9..58fa22cb 100644
--- a/src/luarocks/test/command.lua
+++ b/src/luarocks/test/command.lua
@@ -25,13 +25,6 @@ function command.run_tests(test, args)
25 test.script = "test.lua" 25 test.script = "test.lua"
26 end 26 end
27 27
28 if type(test.flags) == "table" then
29 -- insert any flags given in test.flags at the front of args
30 for i = 1, #test.flags do
31 table.insert(args, i, test.flags[i])
32 end
33 end
34
35 local ok 28 local ok
36 29
37 if test.script then 30 if test.script then