From 2efec770b1b1b27a4b15c3b06a2f5fcadc0b546d Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 16 Mar 2021 14:55:11 -0300 Subject: repos: double-check that all files from a rock are installed Ensure that `luarocks` fails if an installation does not successfully deploy all files registered in the `rock_manifest`. See #1276. --- spec/remove_spec.lua | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 91b6a460..21a39696 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua @@ -2,6 +2,7 @@ local test_env = require("spec.util.test_env") local lfs = require("lfs") local run = test_env.run local testing_paths = test_env.testing_paths +local env_variables = test_env.env_variables test_env.unload_luarocks() @@ -9,7 +10,9 @@ local extra_rocks = { "/abelhas-1.1-1.src.rock", "/copas-2.0.1-1.src.rock", "/coxpcall-1.16.0-1.src.rock", - "/coxpcall-1.16.0-1.rockspec" + "/coxpcall-1.16.0-1.rockspec", + "/luafilesystem-1.7.0-1.src.rock", + "/luafilesystem-1.6.3-2.src.rock", } describe("luarocks remove #integration", function() @@ -80,6 +83,36 @@ describe("luarocks remove #integration", function() assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/coxpcall")) assert.is.falsy(output:find("Checking stability of dependencies")) end) + + it("restores old versions", function() + assert.is_true(run.luarocks_bool("install luafilesystem 1.6.3")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) + + if test_env.TEST_TARGET_OS ~= "windows" then + local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") + assert(fd:read("*a"):match("LuaFileSystem 1.6.3", 1, true)) + fd:close() + end + + assert.is_true(run.luarocks_bool("install luafilesystem 1.7.0 --keep")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_2-lfs."..test_env.lib_extension)) + + if test_env.TEST_TARGET_OS ~= "windows" then + local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") + assert(fd:read("*a"):match("LuaFileSystem 1.7.0", 1, true)) + fd:close() + end + + assert.is_true(run.luarocks_bool("remove luafilesystem 1.7.0")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) + + if test_env.TEST_TARGET_OS ~= "windows" then + local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") + assert(fd:read("*a"):match("LuaFileSystem 1.6.3", 1, true)) + fd:close() + end + end) end) it("#admin remove #ssh", function() -- cgit v1.2.3-55-g6feb