diff options
Diffstat (limited to 'spec/util_spec.lua')
-rw-r--r-- | spec/util_spec.lua | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 0c2d620e..abc0da57 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
@@ -2,6 +2,7 @@ local test_env = require("spec.util.test_env") | |||
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 P = test_env.P | ||
5 | 6 | ||
6 | describe("Basic tests #integration", function() | 7 | describe("Basic tests #integration", function() |
7 | 8 | ||
@@ -182,34 +183,34 @@ describe("luarocks.util #unit", function() | |||
182 | end) | 183 | end) |
183 | 184 | ||
184 | describe("core.util.cleanup_path", function() | 185 | describe("core.util.cleanup_path", function() |
185 | it("does not change order of existing items of prepended path", function() | 186 | it("does not change order of existing items of prepended path", function() |
186 | local sys_path = '/usr/local/bin;/usr/bin' | 187 | local sys_path = P'/usr/local/bin;/usr/bin' |
187 | local lr_path = '/home/user/.luarocks/bin;/usr/bin' | 188 | local lr_path = P'/home/user/.luarocks/bin;/usr/bin' |
188 | local path = lr_path .. ';' .. sys_path | 189 | local path = lr_path .. ';' .. sys_path |
189 | 190 | ||
190 | local result = core_util.cleanup_path(path, ';', '5.3', false) | 191 | local result = core_util.cleanup_path(path, ';', '5.3', false) |
191 | assert.are.equal('/home/user/.luarocks/bin;/usr/local/bin;/usr/bin', result) | 192 | assert.are.equal(P'/home/user/.luarocks/bin;/usr/local/bin;/usr/bin', result) |
192 | end) | 193 | end) |
193 | 194 | ||
194 | it("does not change order of existing items of appended path", function() | 195 | it("does not change order of existing items of appended path", function() |
195 | local sys_path = '/usr/local/bin;/usr/bin' | 196 | local sys_path = P'/usr/local/bin;/usr/bin' |
196 | local lr_path = '/home/user/.luarocks/bin;/usr/bin' | 197 | local lr_path = P'/home/user/.luarocks/bin;/usr/bin' |
197 | local path = sys_path .. ';' .. lr_path | 198 | local path = sys_path .. ';' .. lr_path |
198 | 199 | ||
199 | local result = core_util.cleanup_path(path, ';', '5.3', true) | 200 | local result = core_util.cleanup_path(path, ';', '5.3', true) |
200 | assert.are.equal('/usr/local/bin;/usr/bin;/home/user/.luarocks/bin', result) | 201 | assert.are.equal(P'/usr/local/bin;/usr/bin;/home/user/.luarocks/bin', result) |
201 | end) | 202 | end) |
202 | 203 | ||
203 | it("rewrites versions that do not match the provided version", function() | 204 | it("rewrites versions that do not match the provided version", function() |
204 | local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3/?.lua' | 205 | local expected = P'a/b/lua/5.3/?.lua;a/b/c/lua/5.3/?.lua' |
205 | local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3/?.lua', ';', '5.3') | 206 | local result = core_util.cleanup_path(P'a/b/lua/5.2/?.lua;a/b/c/lua/5.3/?.lua', ';', '5.3') |
206 | assert.are.equal(expected, result) | 207 | assert.are.equal(expected, result) |
207 | end) | 208 | end) |
208 | 209 | ||
209 | it("does not rewrite versions for which the provided version is a substring", function() | 210 | it("does not rewrite versions for which the provided version is a substring", function() |
210 | local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3.4/?.lua' | 211 | local expected = P'a/b/lua/5.3/?.lua;a/b/c/lua/5.3.4/?.lua' |
211 | local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3.4/?.lua', ';', '5.3') | 212 | local result = core_util.cleanup_path(P'a/b/lua/5.2/?.lua;a/b/c/lua/5.3.4/?.lua', ';', '5.3') |
212 | assert.are.equal(expected, result) | 213 | assert.are.equal(expected, result) |
213 | end) | 214 | end) |
214 | end) | 215 | end) |
215 | end) | 216 | end) |