diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2022-04-11 19:16:10 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2022-04-12 13:19:12 -0300 |
commit | 238ba6b21cfcb1af56f1e70dd50de201fc3482a7 (patch) | |
tree | c948b6d3e12e3a518a69d0c844e016c590b31825 /spec/install_spec.lua | |
parent | df8a3cd3c957db337bfc3ab4d404c33066a24923 (diff) | |
download | luarocks-238ba6b21cfcb1af56f1e70dd50de201fc3482a7.tar.gz luarocks-238ba6b21cfcb1af56f1e70dd50de201fc3482a7.tar.bz2 luarocks-238ba6b21cfcb1af56f1e70dd50de201fc3482a7.zip |
tests: avoid repeated hardcoded package version numbers all over
Diffstat (limited to 'spec/install_spec.lua')
-rw-r--r-- | spec/install_spec.lua | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index ea6e1d3f..24dbdb30 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -5,23 +5,24 @@ local testing_paths = test_env.testing_paths | |||
5 | local env_variables = test_env.env_variables | 5 | local env_variables = test_env.env_variables |
6 | local write_file = test_env.write_file | 6 | local write_file = test_env.write_file |
7 | local git_repo = require("spec.util.git_repo") | 7 | local git_repo = require("spec.util.git_repo") |
8 | local V = test_env.V | ||
8 | 9 | ||
9 | test_env.unload_luarocks() | 10 | test_env.unload_luarocks() |
10 | 11 | ||
11 | local extra_rocks = { | 12 | local extra_rocks = { |
12 | "/cprint-0.1-2.src.rock", | 13 | "/cprint-0.1-2.src.rock", |
13 | "/cprint-0.1-2.rockspec", | 14 | "/cprint-0.1-2.rockspec", |
14 | "/lpeg-0.12-1.src.rock", | 15 | "/lpeg-${LPEG}.src.rock", |
15 | "/luassert-1.7.0-1.src.rock", | 16 | "/luassert-1.7.0-1.src.rock", |
16 | "/luasocket-3.0rc1-2.src.rock", | 17 | "/luasocket-${LUASOCKET}.src.rock", |
17 | "/luasocket-3.0rc1-2.rockspec", | 18 | "/luasocket-${LUASOCKET}.rockspec", |
18 | "/lxsh-0.8.6-2.src.rock", | 19 | "/lxsh-${LXSH}.src.rock", |
19 | "/lxsh-0.8.6-2.rockspec", | 20 | "/lxsh-${LXSH}.rockspec", |
20 | "/say-1.2-1.src.rock", | 21 | "/say-1.2-1.src.rock", |
21 | "/say-1.0-1.src.rock", | 22 | "/say-1.0-1.src.rock", |
22 | "/wsapi-1.6-1.src.rock", | 23 | "/wsapi-1.6-1.src.rock", |
23 | "/luafilesystem-1.6.3-2.src.rock", | 24 | "/luafilesystem-${LUAFILESYSTEM}.src.rock", |
24 | "/luafilesystem-1.6.3-1.src.rock", | 25 | "/luafilesystem-${LUAFILESYSTEM_OLD}.src.rock", |
25 | "spec/fixtures/a_repo/has_build_dep-1.0-1.all.rock", | 26 | "spec/fixtures/a_repo/has_build_dep-1.0-1.all.rock", |
26 | "spec/fixtures/a_repo/a_build_dep-1.0-1.all.rock", | 27 | "spec/fixtures/a_repo/a_build_dep-1.0-1.all.rock", |
27 | "spec/fixtures/a_repo/a_rock-1.0-1.src.rock", | 28 | "spec/fixtures/a_repo/a_rock-1.0-1.src.rock", |
@@ -78,7 +79,7 @@ describe("luarocks install #integration", function() | |||
78 | end) | 79 | end) |
79 | 80 | ||
80 | it("only-deps of lxsh show there is no lxsh", function() | 81 | it("only-deps of lxsh show there is no lxsh", function() |
81 | assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2 --only-deps")) | 82 | assert.is_true(run.luarocks_bool("install lxsh ${LXSH} --only-deps")) |
82 | assert.is_false(run.luarocks_bool("show lxsh")) | 83 | assert.is_false(run.luarocks_bool("show lxsh")) |
83 | end) | 84 | end) |
84 | 85 | ||
@@ -170,16 +171,20 @@ describe("luarocks install #integration", function() | |||
170 | end) | 171 | end) |
171 | 172 | ||
172 | it('handle versioned modules when installing another version with --keep #268', function() | 173 | it('handle versioned modules when installing another version with --keep #268', function() |
174 | local libdir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION | ||
175 | |||
173 | assert.is_true(run.luarocks_bool("install luafilesystem")) | 176 | assert.is_true(run.luarocks_bool("install luafilesystem")) |
174 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) | 177 | assert.is.truthy(lfs.attributes(libdir .."/lfs."..test_env.lib_extension)) |
178 | |||
179 | local suffix = (V"${LUAFILESYSTEM_OLD}"):gsub("[%.%-]", "_") | ||
175 | 180 | ||
176 | assert.is_true(run.luarocks_bool("install luafilesystem 1.6.3-1 --keep")) | 181 | assert.is_true(run.luarocks_bool("install luafilesystem ${LUAFILESYSTEM_OLD} --keep")) |
177 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) | 182 | assert.is.truthy(lfs.attributes(libdir .. "/lfs."..test_env.lib_extension)) |
178 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_1-lfs."..test_env.lib_extension)) | 183 | assert.is.truthy(lfs.attributes(libdir .. "/luafilesystem_"..suffix.."-lfs."..test_env.lib_extension)) |
179 | 184 | ||
180 | assert.is_true(run.luarocks_bool("install luafilesystem")) | 185 | assert.is_true(run.luarocks_bool("install luafilesystem")) |
181 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) | 186 | assert.is.truthy(lfs.attributes(libdir .. "/lfs."..test_env.lib_extension)) |
182 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_1-lfs."..test_env.lib_extension)) | 187 | assert.is.falsy(lfs.attributes(libdir .. "/luafilesystem_"..suffix.."-lfs."..test_env.lib_extension)) |
183 | end) | 188 | end) |
184 | 189 | ||
185 | it('handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function() | 190 | it('handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function() |
@@ -193,21 +198,21 @@ describe("luarocks install #integration", function() | |||
193 | end) | 198 | end) |
194 | 199 | ||
195 | it("only-deps of luasocket packed rock", function() | 200 | it("only-deps of luasocket packed rock", function() |
196 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) | 201 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket ${LUASOCKET}")) |
197 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") | 202 | local output = run.luarocks("install --only-deps " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock") |
198 | assert.match("Successfully installed dependencies for luasocket 3.0rc1-2", output, 1, true) | 203 | assert.match(V"Successfully installed dependencies for luasocket ${LUASOCKET}", output, 1, true) |
199 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 204 | assert.is_true(os.remove("luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")) |
200 | end) | 205 | end) |
201 | 206 | ||
202 | it("reinstall", function() | 207 | it("reinstall", function() |
203 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) | 208 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket ${LUASOCKET}")) |
204 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 209 | assert.is_true(run.luarocks_bool("install " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")) |
205 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 210 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")) |
206 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 211 | assert.is_true(os.remove("luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")) |
207 | end) | 212 | end) |
208 | 213 | ||
209 | it("installation rolls back on failure", function() | 214 | it("installation rolls back on failure", function() |
210 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) | 215 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket ${LUASOCKET}")) |
211 | local luadir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION | 216 | local luadir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION |
212 | lfs.mkdir(luadir) | 217 | lfs.mkdir(luadir) |
213 | 218 | ||
@@ -219,7 +224,7 @@ describe("luarocks install #integration", function() | |||
219 | fd:close() | 224 | fd:close() |
220 | 225 | ||
221 | -- try to install and fail | 226 | -- try to install and fail |
222 | assert.is_false(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 227 | assert.is_false(run.luarocks_bool("install " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")) |
223 | 228 | ||
224 | -- file is still there | 229 | -- file is still there |
225 | assert.is.truthy(lfs.attributes(luadir .. "/socket")) | 230 | assert.is.truthy(lfs.attributes(luadir .. "/socket")) |
@@ -230,13 +235,13 @@ describe("luarocks install #integration", function() | |||
230 | assert.is_true(os.remove(luadir .. "/socket")) | 235 | assert.is_true(os.remove(luadir .. "/socket")) |
231 | 236 | ||
232 | -- try again and succeed | 237 | -- try again and succeed |
233 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 238 | assert.is_true(run.luarocks_bool("install " .. "luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")) |
234 | 239 | ||
235 | -- files installed successfully | 240 | -- files installed successfully |
236 | assert.is.truthy(lfs.attributes(luadir .. "/socket/ftp.lua")) | 241 | assert.is.truthy(lfs.attributes(luadir .. "/socket/ftp.lua")) |
237 | assert.is.truthy(lfs.attributes(luadir .. "/mime.lua")) | 242 | assert.is.truthy(lfs.attributes(luadir .. "/mime.lua")) |
238 | 243 | ||
239 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 244 | assert.is_true(os.remove("luasocket-${LUASOCKET}." .. test_env.platform .. ".rock")) |
240 | end) | 245 | end) |
241 | 246 | ||
242 | it("binary rock of cprint", function() | 247 | it("binary rock of cprint", function() |
@@ -246,11 +251,11 @@ describe("luarocks install #integration", function() | |||
246 | end) | 251 | end) |
247 | 252 | ||
248 | it("accepts --no-manifest flag", function() | 253 | it("accepts --no-manifest flag", function() |
249 | assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2")) | 254 | assert.is_true(run.luarocks_bool("install lxsh ${LXSH}")) |
250 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest")) | 255 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest")) |
251 | assert.is.truthy(os.remove(testing_paths.testing_sys_rocks .. "/manifest")) | 256 | assert.is.truthy(os.remove(testing_paths.testing_sys_rocks .. "/manifest")) |
252 | 257 | ||
253 | assert.is_true(run.luarocks_bool("install --no-manifest lxsh 0.8.6-2")) | 258 | assert.is_true(run.luarocks_bool("install --no-manifest lxsh ${LXSH}")) |
254 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest")) | 259 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/manifest")) |
255 | end) | 260 | end) |
256 | end) | 261 | end) |