diff options
author | Deepak Singh Rathore <dsrdeepak8@gmail.com> | 2021-06-23 01:56:56 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-22 17:26:56 -0300 |
commit | a9ea4395bca05516e8297588ec943c648f726345 (patch) | |
tree | 2c3106d2841e72acf999a324d84f34ee5f37bb39 /src | |
parent | 7e6bfb6d8c1d45d62ceb4bbe8e89a184d4c96ffb (diff) | |
download | luarocks-a9ea4395bca05516e8297588ec943c648f726345.tar.gz luarocks-a9ea4395bca05516e8297588ec943c648f726345.tar.bz2 luarocks-a9ea4395bca05516e8297588ec943c648f726345.zip |
luarocks test: add --prepare flag (#1314)
* Added prepare flag in test command
* Added test for prepare flag in spec/test_spec.lua
Fixes #1303
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cmd/test.lua | 9 | ||||
-rw-r--r-- | src/luarocks/test.lua | 8 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/luarocks/cmd/test.lua b/src/luarocks/cmd/test.lua index 21838c90..be9a5dfb 100644 --- a/src/luarocks/cmd/test.lua +++ b/src/luarocks/cmd/test.lua | |||
@@ -23,7 +23,8 @@ to separate LuaRocks arguments from test suite arguments.]], | |||
23 | :args("?") | 23 | :args("?") |
24 | cmd:argument("args", "Test suite arguments.") | 24 | cmd:argument("args", "Test suite arguments.") |
25 | :args("*") | 25 | :args("*") |
26 | 26 | cmd:flag("--prepare", "Only install dependencies needed for testing only, but do not run the test") | |
27 | |||
27 | 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 ".. |
28 | "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.") |
29 | :argname("<type>") | 30 | :argname("<type>") |
@@ -31,7 +32,7 @@ end | |||
31 | 32 | ||
32 | function cmd_test.command(args) | 33 | function cmd_test.command(args) |
33 | if args.rockspec and args.rockspec:match("rockspec$") then | 34 | if args.rockspec and args.rockspec:match("rockspec$") then |
34 | return test.run_test_suite(args.rockspec, args.test_type, args.args) | 35 | return test.run_test_suite(args.rockspec, args.test_type, args.args, args.prepare) |
35 | end | 36 | end |
36 | 37 | ||
37 | table.insert(args.args, 1, args.rockspec) | 38 | table.insert(args.args, 1, args.rockspec) |
@@ -40,8 +41,8 @@ function cmd_test.command(args) | |||
40 | if not rockspec then | 41 | if not rockspec then |
41 | return nil, err | 42 | return nil, err |
42 | end | 43 | end |
43 | 44 | ||
44 | return test.run_test_suite(rockspec, args.test_type, args.args) | 45 | return test.run_test_suite(rockspec, args.test_type, args.args, args.prepare) |
45 | end | 46 | end |
46 | 47 | ||
47 | return cmd_test | 48 | return cmd_test |
diff --git a/src/luarocks/test.lua b/src/luarocks/test.lua index 15eca234..cf475fd3 100644 --- a/src/luarocks/test.lua +++ b/src/luarocks/test.lua | |||
@@ -33,7 +33,7 @@ local function get_test_type(rockspec) | |||
33 | end | 33 | end |
34 | 34 | ||
35 | -- Run test suite as configured in rockspec in the current directory. | 35 | -- Run test suite as configured in rockspec in the current directory. |
36 | function test.run_test_suite(rockspec_arg, test_type, args) | 36 | function test.run_test_suite(rockspec_arg, test_type, args, prepare) |
37 | local rockspec | 37 | local rockspec |
38 | if type(rockspec_arg) == "string" then | 38 | if type(rockspec_arg) == "string" then |
39 | local err, errcode | 39 | local err, errcode |
@@ -68,7 +68,11 @@ function test.run_test_suite(rockspec_arg, test_type, args) | |||
68 | return nil, "failed loading test execution module " .. mod_name | 68 | return nil, "failed loading test execution module " .. mod_name |
69 | end | 69 | end |
70 | 70 | ||
71 | return test_mod.run_tests(rockspec.test, args) | 71 | if prepare then |
72 | return test_mod.run_tests(rockspec_arg, {"--version"}) | ||
73 | else | ||
74 | return test_mod.run_tests(rockspec.test, args) | ||
75 | end | ||
72 | end | 76 | end |
73 | 77 | ||
74 | return test | 78 | return test |