aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/install_spec.lua35
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"))