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