diff options
author | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-01 22:19:38 +0300 |
---|---|---|
committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-11-01 23:00:42 +0300 |
commit | 933386b16d944eac3f93100886b03c3ae745b802 (patch) | |
tree | 43fb0784787dfa2637c3af49752292244518f9cb | |
parent | 5935a1d39658fc0f2dd1ab04f1a3f3dd5413fbb8 (diff) | |
download | luarocks-933386b16d944eac3f93100886b03c3ae745b802.tar.gz luarocks-933386b16d944eac3f93100886b03c3ae745b802.tar.bz2 luarocks-933386b16d944eac3f93100886b03c3ae745b802.zip |
Add a test for conflict resolution with mixed deploy types
-rw-r--r-- | spec/make_spec.lua | 69 | ||||
-rw-r--r-- | test/test_environment.lua | 10 | ||||
-rw-r--r-- | test/testfiles/mixed_deploy_type/mdt.c | 6 | ||||
-rw-r--r-- | test/testfiles/mixed_deploy_type/mdt.lua | 1 | ||||
-rw-r--r-- | test/testfiles/mixed_deploy_type/mdt_file | 1 | ||||
-rw-r--r-- | test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec | 21 | ||||
-rw-r--r-- | test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec | 21 |
7 files changed, 123 insertions, 6 deletions
diff --git a/spec/make_spec.lua b/spec/make_spec.lua index ae79a29c..89036d26 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua | |||
@@ -2,11 +2,11 @@ local test_env = require("test/test_environment") | |||
2 | local lfs = require("lfs") | 2 | 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 | 6 | ||
6 | test_env.unload_luarocks() | 7 | test_env.unload_luarocks() |
7 | 8 | ||
8 | local extra_rocks = { | 9 | local extra_rocks = { |
9 | "lpeg-1.0.0-1.rockspec", | ||
10 | "/luasocket-3.0rc1-2.src.rock", | 10 | "/luasocket-3.0rc1-2.src.rock", |
11 | "/luasocket-3.0rc1-2.rockspec", | 11 | "/luasocket-3.0rc1-2.rockspec", |
12 | "/lxsh-0.8.6-2.src.rock", | 12 | "/lxsh-0.8.6-2.src.rock", |
@@ -98,4 +98,71 @@ describe("LuaRocks make tests #blackbox #b_make", function() | |||
98 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | 98 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) |
99 | end) | 99 | end) |
100 | end) | 100 | end) |
101 | |||
102 | describe("LuaRocks make upgrading rockspecs with mixed deploy types", function() | ||
103 | setup(function() | ||
104 | test_env.copy_dir(testing_paths.testing_dir .. "/testfiles/mixed_deploy_type", "mdt") | ||
105 | end) | ||
106 | |||
107 | teardown(function() | ||
108 | test_env.remove_dir("mdt") | ||
109 | os.remove("mdt."..test_env.lib_extension) | ||
110 | end) | ||
111 | |||
112 | it("modules with same name from lua/ and lib/ when upgrading", function() | ||
113 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec")) | ||
114 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
115 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
116 | |||
117 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec")) | ||
118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
119 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
120 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
121 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
122 | 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")) | ||
123 | 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")) | ||
124 | end) | ||
125 | |||
126 | it("modules with same name from lua/ and lib/ when upgrading with --keep", function() | ||
127 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec")) | ||
128 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
129 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
130 | |||
131 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec --keep")) | ||
132 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
133 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
134 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
135 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
136 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua")) | ||
137 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file")) | ||
138 | end) | ||
139 | |||
140 | it("modules with same name from lua/ and lib/ when downgrading", function() | ||
141 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec")) | ||
142 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
143 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
144 | |||
145 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec")) | ||
146 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
147 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
148 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt."..test_env.lib_extension)) | ||
149 | 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")) | ||
150 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
151 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
152 | end) | ||
153 | |||
154 | it("modules with same name from lua/ and lib/ when downgrading with --keep", function() | ||
155 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec")) | ||
156 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
157 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
158 | |||
159 | assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec --keep")) | ||
160 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension)) | ||
161 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
162 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua")) | ||
163 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file")) | ||
164 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua")) | ||
165 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file")) | ||
166 | end) | ||
167 | end) | ||
101 | end) | 168 | end) |
diff --git a/test/test_environment.lua b/test/test_environment.lua index 196202df..6f6f1cfe 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
@@ -214,7 +214,7 @@ function test_env.set_args() | |||
214 | return true | 214 | return true |
215 | end | 215 | end |
216 | 216 | ||
217 | local function copy_dir(source_path, target_path) | 217 | function test_env.copy_dir(source_path, target_path) |
218 | local testing_paths = test_env.testing_paths | 218 | local testing_paths = test_env.testing_paths |
219 | if test_env.TEST_TARGET_OS == "windows" then | 219 | if test_env.TEST_TARGET_OS == "windows" then |
220 | execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) | 220 | execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) |
@@ -430,8 +430,8 @@ local function build_environment(rocks, env_variables) | |||
430 | end | 430 | end |
431 | end | 431 | end |
432 | 432 | ||
433 | copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) | 433 | test_env.copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) |
434 | copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) | 434 | test_env.copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) |
435 | end | 435 | end |
436 | 436 | ||
437 | --- Reset testing environment | 437 | --- Reset testing environment |
@@ -441,12 +441,12 @@ local function reset_environment(testing_paths, md5sums) | |||
441 | 441 | ||
442 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then | 442 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then |
443 | test_env.remove_dir(testing_paths.testing_tree) | 443 | test_env.remove_dir(testing_paths.testing_tree) |
444 | copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) | 444 | test_env.copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) |
445 | end | 445 | end |
446 | 446 | ||
447 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | 447 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then |
448 | test_env.remove_dir(testing_paths.testing_sys_tree) | 448 | test_env.remove_dir(testing_paths.testing_sys_tree) |
449 | copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) | 449 | test_env.copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) |
450 | end | 450 | end |
451 | print("\n[ENVIRONMENT RESET]") | 451 | print("\n[ENVIRONMENT RESET]") |
452 | end | 452 | end |
diff --git a/test/testfiles/mixed_deploy_type/mdt.c b/test/testfiles/mixed_deploy_type/mdt.c new file mode 100644 index 00000000..a162ce23 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mdt.c | |||
@@ -0,0 +1,6 @@ | |||
1 | #include "lua.h" | ||
2 | |||
3 | int luaopen_mdt(lua_State *L) { | ||
4 | lua_pushstring(L, "mdt.c"); | ||
5 | return 1; | ||
6 | } | ||
diff --git a/test/testfiles/mixed_deploy_type/mdt.lua b/test/testfiles/mixed_deploy_type/mdt.lua new file mode 100644 index 00000000..c9ca9c68 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mdt.lua | |||
@@ -0,0 +1 @@ | |||
return "mdt.lua" | |||
diff --git a/test/testfiles/mixed_deploy_type/mdt_file b/test/testfiles/mixed_deploy_type/mdt_file new file mode 100644 index 00000000..1a15f7d7 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mdt_file | |||
@@ -0,0 +1 @@ | |||
return "mdt_file" | |||
diff --git a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec new file mode 100644 index 00000000..91b725da --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec | |||
@@ -0,0 +1,21 @@ | |||
1 | package = "mixed_deploy_type" | ||
2 | version = "0.1.0-1" | ||
3 | source = { | ||
4 | url = "http://example.com" | ||
5 | } | ||
6 | description = { | ||
7 | homepage = "http://example.com", | ||
8 | license = "*** please specify a license ***" | ||
9 | } | ||
10 | dependencies = {} | ||
11 | build = { | ||
12 | type = "builtin", | ||
13 | modules = { | ||
14 | mdt = "mdt/mdt.lua" | ||
15 | }, | ||
16 | install = { | ||
17 | lua = { | ||
18 | mdt_file = "mdt/mdt_file" | ||
19 | } | ||
20 | } | ||
21 | } | ||
diff --git a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec new file mode 100644 index 00000000..9ca03180 --- /dev/null +++ b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec | |||
@@ -0,0 +1,21 @@ | |||
1 | package = "mixed_deploy_type" | ||
2 | version = "0.2.0-1" | ||
3 | source = { | ||
4 | url = "http://example.com" | ||
5 | } | ||
6 | description = { | ||
7 | homepage = "http://example.com", | ||
8 | license = "*** please specify a license ***" | ||
9 | } | ||
10 | dependencies = {} | ||
11 | build = { | ||
12 | type = "builtin", | ||
13 | modules = { | ||
14 | mdt = "mdt/mdt.c" | ||
15 | }, | ||
16 | install = { | ||
17 | lib = { | ||
18 | mdt_file = "mdt/mdt_file" | ||
19 | } | ||
20 | } | ||
21 | } | ||