aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-09-03 17:48:03 +0200
committerHisham Muhammad <hisham@gobolinux.org>2018-09-04 18:11:12 +0200
commitb8abb27f98e3c674bd3bca4944a53d10a1a2025d (patch)
treed66cc0f63a0b82591e799a50fed2c99ecfd00863
parentc2fde487834c6d7505d7e803256e8764237d4476 (diff)
downloadluarocks-b8abb27f98e3c674bd3bca4944a53d10a1a2025d.tar.gz
luarocks-b8abb27f98e3c674bd3bca4944a53d10a1a2025d.tar.bz2
luarocks-b8abb27f98e3c674bd3bca4944a53d10a1a2025d.zip
Tests: add test cases for rocks with conflicting module names
This tests the behavior of upgrades and downgrades on rocks that deploy both foo.lua and foo.so
-rw-r--r--spec/fixtures/double_deploy_type/ddt.c6
-rw-r--r--spec/fixtures/double_deploy_type/ddt1.lua1
-rw-r--r--spec/fixtures/double_deploy_type/ddt2.lua1
-rw-r--r--spec/fixtures/double_deploy_type/ddt_file1
-rw-r--r--spec/fixtures/double_deploy_type/double_deploy_type-0.1.0-1.rockspec22
-rw-r--r--spec/fixtures/double_deploy_type/double_deploy_type-0.2.0-1.rockspec22
-rw-r--r--spec/make_spec.lua105
-rw-r--r--spec/remove_spec.lua2
8 files changed, 159 insertions, 1 deletions
diff --git a/spec/fixtures/double_deploy_type/ddt.c b/spec/fixtures/double_deploy_type/ddt.c
new file mode 100644
index 00000000..f9050a4a
--- /dev/null
+++ b/spec/fixtures/double_deploy_type/ddt.c
@@ -0,0 +1,6 @@
1#include "lua.h"
2
3int luaopen_ddt(lua_State *L) {
4 lua_pushstring(L, "ddt.c");
5 return 1;
6}
diff --git a/spec/fixtures/double_deploy_type/ddt1.lua b/spec/fixtures/double_deploy_type/ddt1.lua
new file mode 100644
index 00000000..ea1dafed
--- /dev/null
+++ b/spec/fixtures/double_deploy_type/ddt1.lua
@@ -0,0 +1 @@
return "ddt1"
diff --git a/spec/fixtures/double_deploy_type/ddt2.lua b/spec/fixtures/double_deploy_type/ddt2.lua
new file mode 100644
index 00000000..b1fa5d78
--- /dev/null
+++ b/spec/fixtures/double_deploy_type/ddt2.lua
@@ -0,0 +1 @@
return "ddt2"
diff --git a/spec/fixtures/double_deploy_type/ddt_file b/spec/fixtures/double_deploy_type/ddt_file
new file mode 100644
index 00000000..988bbfb6
--- /dev/null
+++ b/spec/fixtures/double_deploy_type/ddt_file
@@ -0,0 +1 @@
return "ddt_file"
diff --git a/spec/fixtures/double_deploy_type/double_deploy_type-0.1.0-1.rockspec b/spec/fixtures/double_deploy_type/double_deploy_type-0.1.0-1.rockspec
new file mode 100644
index 00000000..ff13df03
--- /dev/null
+++ b/spec/fixtures/double_deploy_type/double_deploy_type-0.1.0-1.rockspec
@@ -0,0 +1,22 @@
1package = "double_deploy_type"
2version = "0.1.0-1"
3source = {
4 url = "http://example.com"
5}
6description = {
7 homepage = "http://example.com",
8 license = "*** please specify a license ***"
9}
10dependencies = {}
11build = {
12 type = "builtin",
13 modules = {
14 ddt = "ddt/ddt.c"
15 },
16 install = {
17 lua = {
18 ddt = "ddt/ddt1.lua",
19 ddt_file = "ddt/ddt_file",
20 }
21 }
22}
diff --git a/spec/fixtures/double_deploy_type/double_deploy_type-0.2.0-1.rockspec b/spec/fixtures/double_deploy_type/double_deploy_type-0.2.0-1.rockspec
new file mode 100644
index 00000000..15f0c15c
--- /dev/null
+++ b/spec/fixtures/double_deploy_type/double_deploy_type-0.2.0-1.rockspec
@@ -0,0 +1,22 @@
1package = "double_deploy_type"
2version = "0.2.0-1"
3source = {
4 url = "http://example.com"
5}
6description = {
7 homepage = "http://example.com",
8 license = "*** please specify a license ***"
9}
10dependencies = {}
11build = {
12 type = "builtin",
13 modules = {
14 ddt = "ddt/ddt.c"
15 },
16 install = {
17 lua = {
18 ddt = "ddt/ddt2.lua",
19 ddt_file = "ddt/ddt_file",
20 }
21 }
22}
diff --git a/spec/make_spec.lua b/spec/make_spec.lua
index 6df0ab23..0fc5cd93 100644
--- a/spec/make_spec.lua
+++ b/spec/make_spec.lua
@@ -109,6 +109,109 @@ describe("LuaRocks make tests #integration", function()
109 end) 109 end)
110 end) 110 end)
111 111
112 describe("#ddt LuaRocks make upgrading rockspecs with double deploy types", function()
113 local deploy_lib_dir = testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION
114 local deploy_lua_dir = testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION
115 local so = test_env.lib_extension
116
117 before_each(function()
118 test_env.copy_dir(testing_paths.fixtures_dir .. "/double_deploy_type", "ddt")
119 end)
120
121 after_each(function()
122 test_env.remove_dir("ddt")
123 os.remove("ddt."..test_env.lib_extension)
124 end)
125
126 it("when upgrading", function()
127 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.1.0-1.rockspec"))
128 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
129 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
130 assert.same("ddt1", loadfile(deploy_lua_dir.."/ddt.lua")())
131 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
132 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
133 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
134 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
135
136 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.2.0-1.rockspec"))
137 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
138 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
139 assert.same("ddt2", loadfile(deploy_lua_dir.."/ddt.lua")())
140 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
141 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
142 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
143 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
144 end)
145
146 it("modules with same name from lua/ and lib/ when upgrading with --keep", function()
147 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.1.0-1.rockspec"))
148 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
149 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
150 assert.same("ddt1", loadfile(deploy_lua_dir.."/ddt.lua")())
151 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
152 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
153 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
154 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
155
156 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.2.0-1.rockspec --keep"))
157 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
158 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
159 assert.same("ddt2", loadfile(deploy_lua_dir.."/ddt.lua")())
160 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
161 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
162 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
163 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
164 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/double_deploy_type_0_1_0_1-ddt."..so))
165 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/double_deploy_type_0_1_0_1-ddt.lua"))
166 assert.same("ddt1", loadfile(deploy_lua_dir.."/double_deploy_type_0_1_0_1-ddt.lua")())
167 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/double_deploy_type_0_1_0_1-ddt_file"))
168 end)
169
170 it("modules with same name from lua/ and lib/ when downgrading", function()
171 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.2.0-1.rockspec"))
172 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
173 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
174 assert.same("ddt2", loadfile(deploy_lua_dir.."/ddt.lua")())
175 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
176 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
177 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
178 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
179
180 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.1.0-1.rockspec"))
181 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
182 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
183 assert.same("ddt1", loadfile(deploy_lua_dir.."/ddt.lua")())
184 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
185 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
186 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
187 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
188 end)
189
190 it("modules with same name from lua/ and lib/ when downgrading with --keep", function()
191 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.2.0-1.rockspec"))
192 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
193 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
194 assert.same("ddt2", loadfile(deploy_lua_dir.."/ddt.lua")())
195 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
196 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
197 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
198 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
199
200 assert.is_true(run.luarocks_bool("make ddt/double_deploy_type-0.1.0-1.rockspec --keep"))
201 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/ddt."..so))
202 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt.lua"))
203 assert.same("ddt2", loadfile(deploy_lua_dir.."/ddt.lua")())
204 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/ddt_file"))
205 assert.is.falsy(lfs.attributes(deploy_lib_dir.."/ddt."..so.."~"))
206 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt.lua~"))
207 assert.is.falsy(lfs.attributes(deploy_lua_dir.."/ddt_file~"))
208 assert.is.truthy(lfs.attributes(deploy_lib_dir.."/double_deploy_type_0_1_0_1-ddt."..so))
209 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/double_deploy_type_0_1_0_1-ddt.lua"))
210 assert.same("ddt1", loadfile(deploy_lua_dir.."/double_deploy_type_0_1_0_1-ddt.lua")())
211 assert.is.truthy(lfs.attributes(deploy_lua_dir.."/double_deploy_type_0_1_0_1-ddt_file"))
212 end)
213 end)
214
112 describe("LuaRocks make upgrading rockspecs with mixed deploy types", function() 215 describe("LuaRocks make upgrading rockspecs with mixed deploy types", function()
113 before_each(function() 216 before_each(function()
114 test_env.copy_dir(testing_paths.fixtures_dir .. "/mixed_deploy_type", "mdt") 217 test_env.copy_dir(testing_paths.fixtures_dir .. "/mixed_deploy_type", "mdt")
@@ -159,6 +262,8 @@ describe("LuaRocks make tests #integration", function()
159 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file")) 262 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file"))
160 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) 263 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua"))
161 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) 264 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
265 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua"))
266 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file"))
162 end) 267 end)
163 268
164 it("modules with same name from lua/ and lib/ when downgrading with --keep", function() 269 it("modules with same name from lua/ and lib/ when downgrading with --keep", function()
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua
index f43b55c6..cc9eb599 100644
--- a/spec/remove_spec.lua
+++ b/spec/remove_spec.lua
@@ -6,7 +6,7 @@ local testing_paths = test_env.testing_paths
6test_env.unload_luarocks() 6test_env.unload_luarocks()
7 7
8local extra_rocks = { 8local extra_rocks = {
9 "/abelhas-1.1-1.rockspec", 9 "/abelhas-1.1-1.src.rock",
10 "/copas-2.0.1-1.src.rock", 10 "/copas-2.0.1-1.src.rock",
11 "/coxpcall-1.16.0-1.src.rock", 11 "/coxpcall-1.16.0-1.src.rock",
12 "/coxpcall-1.16.0-1.rockspec" 12 "/coxpcall-1.16.0-1.rockspec"