diff options
Diffstat (limited to 'spec/install_spec.lua')
-rw-r--r-- | spec/install_spec.lua | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/spec/install_spec.lua b/spec/install_spec.lua new file mode 100644 index 00000000..bd480c21 --- /dev/null +++ b/spec/install_spec.lua | |||
@@ -0,0 +1,129 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | local run = test_env.run | ||
4 | local testing_paths = test_env.testing_paths | ||
5 | local env_variables = test_env.env_variables | ||
6 | |||
7 | test_env.unload_luarocks() | ||
8 | |||
9 | local extra_rocks = { | ||
10 | "/cprint-0.1-2.src.rock", | ||
11 | "/cprint-0.1-2.rockspec", | ||
12 | "/lpeg-0.12-1.src.rock", | ||
13 | "/luasec-0.6-1.rockspec", | ||
14 | "/luassert-1.7.0-1.src.rock", | ||
15 | "/luasocket-3.0rc1-1.src.rock", | ||
16 | "/luasocket-3.0rc1-1.rockspec", | ||
17 | "/lxsh-0.8.6-2.src.rock", | ||
18 | "/lxsh-0.8.6-2.rockspec", | ||
19 | "/say-1.2-1.src.rock", | ||
20 | "/say-1.0-1.src.rock", | ||
21 | "/wsapi-1.6-1.src.rock" | ||
22 | } | ||
23 | |||
24 | describe("LuaRocks install tests #blackbox #b_install", function() | ||
25 | |||
26 | before_each(function() | ||
27 | test_env.setup_specs(extra_rocks) | ||
28 | end) | ||
29 | |||
30 | describe("LuaRocks install - basic tests", function() | ||
31 | it("LuaRocks install with no flags/arguments", function() | ||
32 | assert.is_false(run.luarocks_bool("install")) | ||
33 | end) | ||
34 | |||
35 | it("LuaRocks install with invalid argument", function() | ||
36 | assert.is_false(run.luarocks_bool("install invalid")) | ||
37 | end) | ||
38 | |||
39 | it("LuaRocks install invalid patch", function() | ||
40 | assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
41 | end) | ||
42 | |||
43 | it("LuaRocks install invalid rock", function() | ||
44 | assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) | ||
45 | end) | ||
46 | |||
47 | it("LuaRocks install with local flag as root", function() | ||
48 | assert.is_false(run.luarocks_bool("install --local luasocket", { USER = "root" } )) | ||
49 | end) | ||
50 | |||
51 | it("LuaRocks install not a zip file", function() | ||
52 | assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/not_a_zipfile-1.0-1.src.rock")) | ||
53 | end) | ||
54 | |||
55 | it("LuaRocks install only-deps of lxsh show there is no lxsh", function() | ||
56 | assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2 --only-deps")) | ||
57 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
58 | end) | ||
59 | |||
60 | it("LuaRocks install incompatible architecture", function() | ||
61 | assert.is_false(run.luarocks_bool("install \"foo-1.0-1.impossible-x86.rock\" ")) | ||
62 | end) | ||
63 | |||
64 | it("LuaRocks install wsapi with bin", function() | ||
65 | run.luarocks_bool("install wsapi") | ||
66 | end) | ||
67 | |||
68 | it("LuaRocks install luasec and show luasocket (dependency)", function() | ||
69 | assert.is_true(run.luarocks_bool("install luasec")) | ||
70 | assert.is_true(run.luarocks_bool("show luasocket")) | ||
71 | end) | ||
72 | end) | ||
73 | |||
74 | describe("LuaRocks install - more complex tests", function() | ||
75 | it('LuaRocks install luasec with skipping dependency checks', function() | ||
76 | run.luarocks_bool(test_env.quiet(" install luasec --nodeps")) | ||
77 | assert.is_true(run.luarocks_bool(test_env.quiet("show luasec"))) | ||
78 | if env_variables.TYPE_TEST_ENV == "minimal" then | ||
79 | assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) | ||
80 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
81 | end | ||
82 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | ||
83 | end) | ||
84 | |||
85 | it("LuaRocks install only-deps of luasocket packed rock", function() | ||
86 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) | ||
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") | ||
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(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) | ||
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")) | ||
97 | end) | ||
98 | |||
99 | it("LuaRocks install binary rock of cprint", function() | ||
100 | assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock cprint"))) | ||
101 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) | ||
102 | assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) | ||
103 | end) | ||
104 | end) | ||
105 | |||
106 | describe("New install functionality based on pull request 552", function() | ||
107 | it("LuaRocks install break dependencies warning", function() | ||
108 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
109 | assert.is_true(run.luarocks_bool("install luassert")) | ||
110 | assert.is_true(run.luarocks_bool("install say 1.0")) | ||
111 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
112 | end) | ||
113 | it("LuaRocks install break dependencies force", function() | ||
114 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
115 | assert.is_true(run.luarocks_bool("install luassert")) | ||
116 | local output = run.luarocks("install --force say 1.0") | ||
117 | assert.is.truthy(output:find("Checking stability of dependencies")) | ||
118 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
119 | end) | ||
120 | it("LuaRocks install break dependencies force fast", function() | ||
121 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
122 | assert.is_true(run.luarocks_bool("install luassert")) | ||
123 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
124 | local output = run.luarocks("install --force-fast say 1.0") | ||
125 | assert.is.falsy(output:find("Checking stability of dependencies")) | ||
126 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.0-1")) | ||
127 | end) | ||
128 | end) | ||
129 | end) | ||