diff options
-rw-r--r-- | spec/build_spec.lua | 2 | ||||
-rw-r--r-- | spec/install_spec.lua | 3 | ||||
-rw-r--r-- | spec/remove_spec.lua | 7 | ||||
-rw-r--r-- | test/test_environment.lua | 23 |
4 files changed, 16 insertions, 19 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 1ce99089..682c6dcf 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
@@ -169,12 +169,10 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
169 | end) | 169 | end) |
170 | 170 | ||
171 | it("LuaRocks build missing external", function() | 171 | it("LuaRocks build missing external", function() |
172 | assert.is_true(test_env.need_luasocket()) | ||
173 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) | 172 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) |
174 | end) | 173 | end) |
175 | 174 | ||
176 | it("LuaRocks build invalid patch", function() | 175 | it("LuaRocks build invalid patch", function() |
177 | assert.is_true(test_env.need_luasocket()) | ||
178 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | 176 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) |
179 | end) | 177 | end) |
180 | end) | 178 | end) |
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 0e406e22..9bc11e87 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -83,20 +83,17 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
83 | end) | 83 | end) |
84 | 84 | ||
85 | it("LuaRocks install only-deps of luasocket packed rock", function() | 85 | it("LuaRocks install only-deps of luasocket packed rock", function() |
86 | assert.is_true(test_env.need_luasocket()) | ||
87 | local output = run.luarocks("install --only-deps " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock") | 86 | local output = run.luarocks("install --only-deps " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock") |
88 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") | 87 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") |
89 | end) | 88 | end) |
90 | 89 | ||
91 | it("LuaRocks install binary rock of cprint", function() | 90 | it("LuaRocks install binary rock of cprint", function() |
92 | assert.is_true(test_env.need_luasocket()) | ||
93 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) | 91 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) |
94 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) | 92 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) |
95 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) | 93 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) |
96 | end) | 94 | end) |
97 | 95 | ||
98 | it("LuaRocks install reinstall", function() | 96 | it("LuaRocks install reinstall", function() |
99 | assert.is_true(test_env.need_luasocket()) | ||
100 | assert.is_true(run.luarocks_bool("install " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 97 | assert.is_true(run.luarocks_bool("install " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) |
101 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) | 98 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) |
102 | end) | 99 | end) |
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 41c6348a..c7f83b95 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua | |||
@@ -44,8 +44,11 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() | |||
44 | end) | 44 | end) |
45 | 45 | ||
46 | describe("LuaRocks remove more complex tests", function() | 46 | describe("LuaRocks remove more complex tests", function() |
47 | before_each(function() | ||
48 | assert.is_true(test_env.need_rock("luasocket")) | ||
49 | end) | ||
50 | |||
47 | it("LuaRocks remove fail, break dependencies", function() | 51 | it("LuaRocks remove fail, break dependencies", function() |
48 | assert.is_true(test_env.need_luasocket()) | ||
49 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | 52 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) |
50 | assert.is_true(run.luarocks_bool("build lualogging")) | 53 | assert.is_true(run.luarocks_bool("build lualogging")) |
51 | 54 | ||
@@ -54,7 +57,6 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() | |||
54 | end) | 57 | end) |
55 | 58 | ||
56 | it("LuaRocks remove force", function() | 59 | it("LuaRocks remove force", function() |
57 | assert.is_true(test_env.need_luasocket()) | ||
58 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | 60 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) |
59 | assert.is_true(run.luarocks_bool("build lualogging")) | 61 | assert.is_true(run.luarocks_bool("build lualogging")) |
60 | 62 | ||
@@ -64,7 +66,6 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() | |||
64 | end) | 66 | end) |
65 | 67 | ||
66 | it("LuaRocks remove force fast", function() | 68 | it("LuaRocks remove force fast", function() |
67 | assert.is_true(test_env.need_luasocket()) | ||
68 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | 69 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) |
69 | assert.is_true(run.luarocks_bool("build lualogging")) | 70 | assert.is_true(run.luarocks_bool("build lualogging")) |
70 | 71 | ||
diff --git a/test/test_environment.lua b/test/test_environment.lua index 6de7a4e2..eb545a47 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
@@ -14,6 +14,7 @@ USAGE | |||
14 | ARGUMENTS | 14 | ARGUMENTS |
15 | env=<type> Set type of environment to use ("minimal" or "full", | 15 | env=<type> Set type of environment to use ("minimal" or "full", |
16 | default: "minimal"). | 16 | default: "minimal"). |
17 | noreset Don't reset environment after each test | ||
17 | clean Remove existing testing environment. | 18 | clean Remove existing testing environment. |
18 | travis Add if running on TravisCI. | 19 | travis Add if running on TravisCI. |
19 | os=<type> Set OS ("linux", "osx", or "windows"). | 20 | os=<type> Set OS ("linux", "osx", or "windows"). |
@@ -96,10 +97,13 @@ end | |||
96 | function test_env.set_args() | 97 | function test_env.set_args() |
97 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables | 98 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables |
98 | test_env.TYPE_TEST_ENV = "minimal" | 99 | test_env.TYPE_TEST_ENV = "minimal" |
100 | test_env.RESET_ENV = true | ||
99 | 101 | ||
100 | for _, argument in ipairs(arg) do | 102 | for _, argument in ipairs(arg) do |
101 | if argument:find("^env=") then | 103 | if argument:find("^env=") then |
102 | test_env.TYPE_TEST_ENV = argument:match("^env=(.*)$") | 104 | test_env.TYPE_TEST_ENV = argument:match("^env=(.*)$") |
105 | elseif argument == "noreset" then | ||
106 | test_env.RESET_ENV = false | ||
103 | elseif argument == "clean" then | 107 | elseif argument == "clean" then |
104 | test_env.TEST_ENV_CLEAN = true | 108 | test_env.TEST_ENV_CLEAN = true |
105 | elseif argument == "travis" then | 109 | elseif argument == "travis" then |
@@ -333,6 +337,7 @@ local function reset_environment(testing_paths, md5sums) | |||
333 | test_env.remove_dir(testing_paths.testing_tree) | 337 | test_env.remove_dir(testing_paths.testing_tree) |
334 | execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) | 338 | execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) |
335 | end | 339 | end |
340 | |||
336 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | 341 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then |
337 | test_env.remove_dir(testing_paths.testing_sys_tree) | 342 | test_env.remove_dir(testing_paths.testing_sys_tree) |
338 | execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) | 343 | execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) |
@@ -403,21 +408,17 @@ function test_env.setup_specs(extra_rocks) | |||
403 | end | 408 | end |
404 | end | 409 | end |
405 | 410 | ||
406 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) | 411 | if test_env.RESET_ENV then |
412 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) | ||
413 | end | ||
407 | end | 414 | end |
408 | 415 | ||
409 | --- Helper function for tests which needs luasocket installed | 416 | --- Test if required rock is installed if not, install it |
410 | function test_env.need_luasocket() | 417 | function test_env.need_rock(rock) |
411 | if test_env.run.luarocks_nocov("show luasocket") then | 418 | if test_env.run.luarocks_nocov("show " .. rock) then |
412 | return true | 419 | return true |
413 | else | 420 | else |
414 | local testing_cache = test_env.testing_paths.testing_cache .. "/" | 421 | return test_env.run.luarocks_nocov("install " .. rock) |
415 | local luasocket_rock = "luasocket-3.0rc1-1." .. test_env.platform .. ".rock" | ||
416 | if not exists(testing_cache .. luasocket_rock) then | ||
417 | test_env.run.luarocks_nocov("build --pack-binary-rock luasocket 3.0rc1-1") | ||
418 | os.rename(luasocket_rock, testing_cache .. luasocket_rock) | ||
419 | end | ||
420 | return test_env.run.luarocks_nocov("install " .. testing_cache .. luasocket_rock) | ||
421 | end | 422 | end |
422 | end | 423 | end |
423 | 424 | ||