From 3d8a9fffacec6bbd3be6429f6e849d82d3812827 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 23 Apr 2018 10:55:24 -0300 Subject: test: add --test-type flag for not auto-detected test types --- src/luarocks/cmd/test.lua | 11 ++++++++--- src/luarocks/test.lua | 10 +++++++--- src/luarocks/util.lua | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/luarocks/cmd/test.lua b/src/luarocks/cmd/test.lua index e8a05f09..66c6f4ab 100644 --- a/src/luarocks/cmd/test.lua +++ b/src/luarocks/cmd/test.lua @@ -7,7 +7,7 @@ local util = require("luarocks.util") local test = require("luarocks.test") cmd_test.help_summary = "Run the test suite in the current directory." -cmd_test.help_arguments = "[] [-- ]" +cmd_test.help_arguments = "[--test-type=] [] [-- ]" cmd_test.help = [[ Run the test suite for the Lua project in the current directory. If the first argument is a rockspec, it will use it to determine @@ -18,6 +18,11 @@ Any additional arguments are forwarded to the test suite. To make sure that any flags passed in are not interpreted as LuaRocks flags, use -- to separate LuaRocks arguments from test suite arguments. + +--test-type= Specify the test suite type manually if it was not + specified in the rockspec and it could not be + auto-detected. + ]]..util.deps_mode_help() --- Driver function for "build" command. @@ -34,7 +39,7 @@ function cmd_test.command(flags, arg, ...) local args = { ... } if arg and arg:match("rockspec$") then - return test.run_test_suite(arg, args) + return test.run_test_suite(arg, flags["test-type"], args) end table.insert(args, 1, arg) @@ -44,7 +49,7 @@ function cmd_test.command(flags, arg, ...) return nil, err end - return test.run_test_suite(rockspec, args) + return test.run_test_suite(rockspec, flags["test-type"], args) end return cmd_test diff --git a/src/luarocks/test.lua b/src/luarocks/test.lua index c7e3e013..c550c5b8 100644 --- a/src/luarocks/test.lua +++ b/src/luarocks/test.lua @@ -33,7 +33,7 @@ local function get_test_type(rockspec) end -- Run test suite as configured in rockspec in the current directory. -function test.run_test_suite(rockspec_arg, args) +function test.run_test_suite(rockspec_arg, test_type, args) local rockspec if type(rockspec_arg) == "string" then local err, errcode @@ -46,10 +46,14 @@ function test.run_test_suite(rockspec_arg, args) rockspec = rockspec_arg end - local test_type, err = get_test_type(rockspec) if not test_type then - return nil, err + local err + test_type, err = get_test_type(rockspec, test_type) + if not test_type then + return nil, err + end end + assert(test_type) if next(rockspec.test_dependencies) then local ok, err, errcode = deps.fulfill_dependencies(rockspec, "test_dependencies", "all") diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index f96f5c32..85c83744 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua @@ -141,6 +141,7 @@ local supported_flags = { ["summary"] = "\"\"", ["system-config"] = true, ["tag"] = "", + ["test-type"] = "", ["temp-key"] = "", ["timeout"] = "", ["to"] = "", -- cgit v1.2.3-55-g6feb