aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/build_spec.lua2
-rw-r--r--spec/install_spec.lua21
-rw-r--r--spec/new_version_spec.lua8
-rw-r--r--spec/pack_spec.lua5
-rw-r--r--spec/remove_spec.lua7
-rw-r--r--test/test_environment.lua23
-rw-r--r--test/testfiles/invalid_validate-args-1.5.4-1.rockspec35
7 files changed, 75 insertions, 26 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..0b2ffb53 100644
--- a/spec/install_spec.lua
+++ b/spec/install_spec.lua
@@ -83,23 +83,24 @@ 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()) 86 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket"))
87 local output = run.luarocks("install --only-deps " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock") 87 local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")
88 assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") 88 assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1")
89 assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
90 end)
91
92 it("LuaRocks install reinstall", function()
93 assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket"))
94 assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
95 assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
96 assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
89 end) 97 end)
90 98
91 it("LuaRocks install binary rock of cprint", function() 99 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")) 100 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")) 101 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")) 102 assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock"))
96 end) 103 end)
97
98 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"))
101 assert.is_true(run.luarocks_bool("install --deps-mode=none " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. test_env.platform .. ".rock"))
102 end)
103 end) 104 end)
104 105
105 describe("New install functionality based on pull request 552", function() 106 describe("New install functionality based on pull request 552", function()
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua
index 4e4d5d27..c4185b1d 100644
--- a/spec/new_version_spec.lua
+++ b/spec/new_version_spec.lua
@@ -30,11 +30,19 @@ describe("LuaRocks new_version tests #blackbox #b_new_version", function()
30 it("LuaRocks new version invalid url", function() 30 it("LuaRocks new version invalid url", function()
31 assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.0")) 31 assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.0"))
32 assert.is_true(run.luarocks_bool("new_version abelhas-1.0-1.rockspec 1.1 http://luainvalid")) 32 assert.is_true(run.luarocks_bool("new_version abelhas-1.0-1.rockspec 1.1 http://luainvalid"))
33 assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec"))
33 test_env.remove_files(lfs.currentdir(), "abelhas--") 34 test_env.remove_files(lfs.currentdir(), "abelhas--")
34 end) 35 end)
35 end) 36 end)
36 37
37 describe("LuaRocks new_version more complex tests", function() 38 describe("LuaRocks new_version more complex tests", function()
39 it("LuaRocks new version with remote spec", function()
40 assert.is_true(run.luarocks_bool("new_version https://luarocks.org/manifests/luarocks/luasocket-2.0.2-6.rockspec"))
41 assert.is.truthy(lfs.attributes("luasocket-2.0.2-6.rockspec"))
42 assert.is.truthy(lfs.attributes("luasocket-2.0.2-7.rockspec"))
43 test_env.remove_files(lfs.currentdir(), "luasocket--")
44 end)
45
38 it("LuaRocks new_version of luacov", function() 46 it("LuaRocks new_version of luacov", function()
39 assert.is_true(run.luarocks_bool("download --rockspec luacov 0.11.0")) 47 assert.is_true(run.luarocks_bool("download --rockspec luacov 0.11.0"))
40 assert.is_true(run.luarocks_bool("new_version luacov-0.11.0-1.rockspec 0.2")) 48 assert.is_true(run.luarocks_bool("new_version luacov-0.11.0-1.rockspec 0.2"))
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
index 416184a8..aa827682 100644
--- a/spec/pack_spec.lua
+++ b/spec/pack_spec.lua
@@ -1,6 +1,7 @@
1local test_env = require("test/test_environment") 1local test_env = require("test/test_environment")
2local lfs = require("lfs") 2local lfs = require("lfs")
3local run = test_env.run 3local run = test_env.run
4local testing_paths = test_env.testing_paths
4 5
5test_env.unload_luarocks() 6test_env.unload_luarocks()
6 7
@@ -21,6 +22,10 @@ describe("LuaRocks pack tests #blackbox #b_pack", function()
21 assert.is_true(run.luarocks_bool("pack luacov")) 22 assert.is_true(run.luarocks_bool("pack luacov"))
22 assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) 23 assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-"))
23 end) 24 end)
25
26 it("LuaRocks pack invalid rockspec", function()
27 assert.is_false(run.luarocks_bool("pack " .. testing_paths.testing_dir .. "/testfiles/invaild_validate-args-1.5.4-1.rockspec"))
28 end)
24 29
25 it("LuaRocks pack src", function() 30 it("LuaRocks pack src", function()
26 assert.is_true(run.luarocks_bool("install luasec")) 31 assert.is_true(run.luarocks_bool("install luasec"))
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
14ARGUMENTS 14ARGUMENTS
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
96function test_env.set_args() 97function 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
407end 414end
408 415
409--- Helper function for tests which needs luasocket installed 416--- Test if required rock is installed if not, install it
410function test_env.need_luasocket() 417function 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
422end 423end
423 424
diff --git a/test/testfiles/invalid_validate-args-1.5.4-1.rockspec b/test/testfiles/invalid_validate-args-1.5.4-1.rockspec
new file mode 100644
index 00000000..0b4d807d
--- /dev/null
+++ b/test/testfiles/invalid_validate-args-1.5.4-1.rockspec
@@ -0,0 +1,35 @@
1package = 'validate-args'
2version = '1.5.4-1'
3source = {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{++{
4 url = "https://bitbucket.org/djerius/validate.args/downloads/validate-args-1.5.4.tar.gz"
5}
6
7description = {
8 summary = "Function argument validation",
9 detailed = [[
10 validate.args is a Lua module that provides a framework for
11 validation of arguments to Lua functions as well as complex data
12 structures. The included validate.inplace module provides "live"
13 validation during assignment of values to elements in tables. ]],
14 license = "GPL-3",
15
16}
17
18dependencies = {
19 "lua >= 5.1"
20}
21
22build = {
23
24 type = "builtin",
25
26 modules = {
27 ["validate.args"] = "validate/args.lua",
28 ["validate.inplace"] = "validate/inplace.lua",
29 },
30
31 copy_directories = {
32 "doc", "tests"
33 }
34
35}