From 714d887f99dad19d406de36e6d9d88739066f4f1 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Mon, 11 Sep 2017 13:05:20 +0300 Subject: Pass correct rockspec to upload tests that should fail for other reasons Most tests simply check that some command succeeds or fails. When failure is expected, failure reason is not checked. In this case, upload commands was failing because passed rockspec did not exist and not for reason tests planned. --- spec/upload_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/upload_spec.lua') diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index ff39cb96..cd175730 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -42,12 +42,12 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() end) it("LuaRocks upload api key invalid and skip-pack", function() - assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) + assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec")) end) it("LuaRocks upload force #unix", function() assert.is_true(run.luarocks_bool("install lua-cjson")) - assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) + assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec")) assert.is_true(run.luarocks_bool("install lua-cjson")) end) -- cgit v1.2.3-55-g6feb From 957149e4be48fe3f87b44f73984c5b20fd8d08f1 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Mon, 11 Sep 2017 13:14:02 +0300 Subject: Use dkjson instead of lua-cjson for upload test lua-cjson fails to build under LuaJIT 2.1.0-beta3. --- spec/upload_spec.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'spec/upload_spec.lua') diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index cd175730..8b3e0433 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -5,8 +5,6 @@ local testing_paths = test_env.testing_paths test_env.unload_luarocks() local extra_rocks = { - "/lua-cjson-2.1.0-1.src.rock", - -- rocks needed for mock-server "/copas-2.0.1-1.src.rock", "/coxpcall-1.16.0-1.src.rock", @@ -46,9 +44,8 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() end) it("LuaRocks upload force #unix", function() - assert.is_true(run.luarocks_bool("install lua-cjson")) + assert.is_true(test_env.need_rock("dkjson")) assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec")) - assert.is_true(run.luarocks_bool("install lua-cjson")) end) describe("LuaRocks upload tests with Xavante server #mock", function() -- cgit v1.2.3-55-g6feb From 85701e003241798e36b81ed1e3ed285f7bf5c7a0 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Mon, 11 Sep 2017 13:19:03 +0300 Subject: Clarify test_env.need_rock description wrt return value --- spec/upload_spec.lua | 2 +- test/test_environment.lua | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'spec/upload_spec.lua') diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index 8b3e0433..6ec8e302 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -50,7 +50,7 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() describe("LuaRocks upload tests with Xavante server #mock", function() before_each(function() - assert.is.truthy(test_env.need_rock("restserver-xavante")) + assert.is_true(test_env.need_rock("restserver-xavante")) local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables) os.execute(final_command) end) diff --git a/test/test_environment.lua b/test/test_environment.lua index c781af4b..bc1e5277 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua @@ -533,7 +533,9 @@ function test_env.setup_specs(extra_rocks) end end ---- Test if required rock is installed if not, install it +--- Test if required rock is installed and if not, install it. +-- Return `true` if the rock is already installed or has been installed successfully, +-- `false` if installation failed. function test_env.need_rock(rock) print("Check if " .. rock .. " is installed") if test_env.run.luarocks_noprint_nocov(test_env.quiet("show " .. rock)) then -- cgit v1.2.3-55-g6feb