diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-10-18 06:35:36 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-18 06:35:36 -0300 |
commit | 3a3f2cbaa50d353f4c26b39f59c015a20f28c4ae (patch) | |
tree | b39dd87b9180654f5724ca0cd624db0391ee23b6 /spec | |
parent | 879c6ef01f94df18a8457a3eb78aeafc4fe0a003 (diff) | |
download | luarocks-3a3f2cbaa50d353f4c26b39f59c015a20f28c4ae.tar.gz luarocks-3a3f2cbaa50d353f4c26b39f59c015a20f28c4ae.tar.bz2 luarocks-3a3f2cbaa50d353f4c26b39f59c015a20f28c4ae.zip |
repos: rollback on installation failure (#1101)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/install_spec.lua | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 3b0b22fb..9b082ab8 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -81,7 +81,7 @@ describe("luarocks install #integration", function() | |||
81 | assert.is_true(run.luarocks_bool("show luasocket")) | 81 | assert.is_true(run.luarocks_bool("show luasocket")) |
82 | end) | 82 | end) |
83 | 83 | ||
84 | it("installs a package without its documentation #only", function() | 84 | it("installs a package without its documentation", function() |
85 | assert.is_true(run.luarocks_bool("install wsapi 1.6 --no-doc")) | 85 | assert.is_true(run.luarocks_bool("install wsapi 1.6 --no-doc")) |
86 | assert.is_true(run.luarocks_bool("show wsapi 1.6")) | 86 | assert.is_true(run.luarocks_bool("show wsapi 1.6")) |
87 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/wsapi/1.6-1/doc")) | 87 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/wsapi/1.6-1/doc")) |
@@ -195,6 +195,39 @@ describe("luarocks install #integration", function() | |||
195 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 195 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
196 | end) | 196 | end) |
197 | 197 | ||
198 | it("installation rolls back on failure", function() | ||
199 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) | ||
200 | local luadir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION | ||
201 | lfs.mkdir(luadir) | ||
202 | |||
203 | run.luarocks_bool("remove " .. "luasocket") | ||
204 | |||
205 | -- create a file where a folder should be | ||
206 | local fd = io.open(luadir .. "/socket", "w") | ||
207 | fd:write("\n") | ||
208 | fd:close() | ||
209 | |||
210 | -- try to install and fail | ||
211 | assert.is_false(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | ||
212 | |||
213 | -- file is still there | ||
214 | assert.is.truthy(lfs.attributes(luadir .. "/socket")) | ||
215 | -- no left overs from failed installation | ||
216 | assert.is.falsy(lfs.attributes(luadir .. "/mime.lua")) | ||
217 | |||
218 | -- remove file | ||
219 | assert.is_true(os.remove(luadir .. "/socket")) | ||
220 | |||
221 | -- try again and succeed | ||
222 | assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | ||
223 | |||
224 | -- files installed successfully | ||
225 | assert.is.truthy(lfs.attributes(luadir .. "/socket/ftp.lua")) | ||
226 | assert.is.truthy(lfs.attributes(luadir .. "/mime.lua")) | ||
227 | |||
228 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | ||
229 | end) | ||
230 | |||
198 | it("binary rock of cprint", function() | 231 | it("binary rock of cprint", function() |
199 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) | 232 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) |
200 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) | 233 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) |