From 292a274fd02b88a729d474b544829c53e138a57b Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 6 Jun 2022 15:27:10 -0300 Subject: test: perform variable substitutions in test.flags --- src/luarocks/cmd/test.lua | 4 ++-- src/luarocks/test.lua | 11 +++++++++++ src/luarocks/test/busted.lua | 7 ------- src/luarocks/test/command.lua | 7 ------- 4 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src') 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.]], cmd:argument("args", "Test suite arguments.") :args("*") cmd:flag("--prepare", "Only install dependencies needed for testing only, but do not run the test") - + cmd:option("--test-type", "Specify the test suite type manually if it was ".. "not specified in the rockspec and it could not be auto-detected.") :argname("") @@ -41,7 +41,7 @@ function cmd_test.command(args) if not rockspec then return nil, err end - + return test.run_test_suite(rockspec, args.test_type, args.args, args.prepare) end 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 = {} local fetch = require("luarocks.fetch") local deps = require("luarocks.deps") +local util = require("luarocks.util") local test_types = { "busted", @@ -71,6 +72,16 @@ function test.run_test_suite(rockspec_arg, test_type, args, prepare) if prepare then return test_mod.run_tests(rockspec_arg, {"--version"}) else + local flags = rockspec.test and rockspec.test.flags + if type(flags) == "table" then + util.variable_substitutions(flags, rockspec.variables) + + -- insert any flags given in test.flags at the front of args + for i = 1, #flags do + table.insert(args, i, flags[i]) + end + end + return test_mod.run_tests(rockspec.test, args) end end 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) end end - if type(test.flags) == "table" then - -- insert any flags given in test.flags at the front of args - for i = 1, #test.flags do - table.insert(args, i, test.flags[i]) - end - end - local err ok, err = fs.execute(busted_exe, unpack(args)) 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) test.script = "test.lua" end - if type(test.flags) == "table" then - -- insert any flags given in test.flags at the front of args - for i = 1, #test.flags do - table.insert(args, i, test.flags[i]) - end - end - local ok if test.script then -- cgit v1.2.3-55-g6feb