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/remove_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/remove_spec.lua')
-rw-r--r-- | spec/remove_spec.lua | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 21a39696..a67db591 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua | |||
@@ -3,16 +3,17 @@ local lfs = require("lfs") | |||
3 | local run = test_env.run | 3 | local run = test_env.run |
4 | local testing_paths = test_env.testing_paths | 4 | 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 V = test_env.V | ||
6 | 7 | ||
7 | test_env.unload_luarocks() | 8 | test_env.unload_luarocks() |
8 | 9 | ||
9 | local extra_rocks = { | 10 | local extra_rocks = { |
10 | "/abelhas-1.1-1.src.rock", | 11 | "/abelhas-1.1-1.src.rock", |
11 | "/copas-2.0.1-1.src.rock", | 12 | "/copas-${COPAS}.src.rock", |
12 | "/coxpcall-1.16.0-1.src.rock", | 13 | "/coxpcall-1.16.0-1.src.rock", |
13 | "/coxpcall-1.16.0-1.rockspec", | 14 | "/coxpcall-1.16.0-1.rockspec", |
14 | "/luafilesystem-1.7.0-1.src.rock", | 15 | "/luafilesystem-${LUAFILESYSTEM}.src.rock", |
15 | "/luafilesystem-1.6.3-2.src.rock", | 16 | "/luafilesystem-${LUAFILESYSTEM_OLD}.src.rock", |
16 | } | 17 | } |
17 | 18 | ||
18 | describe("luarocks remove #integration", function() | 19 | describe("luarocks remove #integration", function() |
@@ -85,31 +86,35 @@ describe("luarocks remove #integration", function() | |||
85 | end) | 86 | end) |
86 | 87 | ||
87 | it("restores old versions", function() | 88 | it("restores old versions", function() |
88 | assert.is_true(run.luarocks_bool("install luafilesystem 1.6.3")) | 89 | local libdir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION |
89 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) | 90 | |
91 | assert.is_true(run.luarocks_bool("install luafilesystem ${LUAFILESYSTEM_OLD_V}")) | ||
92 | assert.is.truthy(lfs.attributes(libdir.."/lfs."..test_env.lib_extension)) | ||
90 | 93 | ||
91 | if test_env.TEST_TARGET_OS ~= "windows" then | 94 | if test_env.TEST_TARGET_OS ~= "windows" then |
92 | local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") | 95 | local fd = io.open(libdir.."/lfs."..test_env.lib_extension, "r") |
93 | assert(fd:read("*a"):match("LuaFileSystem 1.6.3", 1, true)) | 96 | assert(fd:read("*a"):match(V"LuaFileSystem ${LUAFILESYSTEM_OLD_V}", 1, true)) |
94 | fd:close() | 97 | fd:close() |
95 | end | 98 | end |
96 | 99 | ||
97 | assert.is_true(run.luarocks_bool("install luafilesystem 1.7.0 --keep")) | 100 | local suffix = (V"${LUAFILESYSTEM_OLD}"):gsub("[%.%-]", "_") |
98 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) | 101 | |
99 | 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)) | 102 | assert.is_true(run.luarocks_bool("install luafilesystem ${LUAFILESYSTEM_V} --keep")) |
103 | assert.is.truthy(lfs.attributes(libdir.."/lfs."..test_env.lib_extension)) | ||
104 | assert.is.truthy(lfs.attributes(libdir.."/luafilesystem_"..suffix.."-lfs."..test_env.lib_extension)) | ||
100 | 105 | ||
101 | if test_env.TEST_TARGET_OS ~= "windows" then | 106 | if test_env.TEST_TARGET_OS ~= "windows" then |
102 | local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") | 107 | local fd = io.open(libdir.."/lfs."..test_env.lib_extension, "r") |
103 | assert(fd:read("*a"):match("LuaFileSystem 1.7.0", 1, true)) | 108 | assert(fd:read("*a"):match(V"LuaFileSystem ${LUAFILESYSTEM_V}", 1, true)) |
104 | fd:close() | 109 | fd:close() |
105 | end | 110 | end |
106 | 111 | ||
107 | assert.is_true(run.luarocks_bool("remove luafilesystem 1.7.0")) | 112 | assert.is_true(run.luarocks_bool("remove luafilesystem ${LUAFILESYSTEM_V}")) |
108 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) | 113 | assert.is.truthy(lfs.attributes(libdir.."/lfs."..test_env.lib_extension)) |
109 | 114 | ||
110 | if test_env.TEST_TARGET_OS ~= "windows" then | 115 | if test_env.TEST_TARGET_OS ~= "windows" then |
111 | local fd = io.open(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension, "r") | 116 | local fd = io.open(libdir.."/lfs."..test_env.lib_extension, "r") |
112 | assert(fd:read("*a"):match("LuaFileSystem 1.6.3", 1, true)) | 117 | assert(fd:read("*a"):match(V"LuaFileSystem ${LUAFILESYSTEM_OLD_V}", 1, true)) |
113 | fd:close() | 118 | fd:close() |
114 | end | 119 | end |
115 | end) | 120 | end) |