diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-07-13 17:12:58 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-07-17 20:30:25 -0300 |
commit | 72d80a35bee56bd8f8002b199db37f89c1441c29 (patch) | |
tree | b3da27263aa3c9a20ca860753791d2ae15496cd6 /spec | |
parent | 526664e6e54da0f129621ea6df355767259a103a (diff) | |
download | luarocks-72d80a35bee56bd8f8002b199db37f89c1441c29.tar.gz luarocks-72d80a35bee56bd8f8002b199db37f89c1441c29.tar.bz2 luarocks-72d80a35bee56bd8f8002b199db37f89c1441c29.zip |
path: keep order of existing entries in PATH
Implements suggestion by @FSMaxB:
> Add an additional flag to util.cleanup_path that specifies if the cleanup
> happens from the right or from the left. If append is true, clean up from the
> left, otherwise clean up from the right.
Fixes #763.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/util_spec.lua | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 930a5aea..b1693cfa 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua | |||
@@ -157,16 +157,34 @@ describe("Luarocks util test #unit", function() | |||
157 | end) | 157 | end) |
158 | 158 | ||
159 | describe("core.util.cleanup_path", function() | 159 | describe("core.util.cleanup_path", function() |
160 | it("does not change order of existing items of prepended path", function() | ||
161 | local sys_path = '/usr/local/bin;/usr/bin' | ||
162 | local lr_path = '/home/user/.luarocks/bin;/usr/bin' | ||
163 | local path = lr_path .. ';' .. sys_path | ||
164 | |||
165 | local result = core_util.cleanup_path(path, ';', '5.3', false) | ||
166 | assert.are.equal('/home/user/.luarocks/bin;/usr/local/bin;/usr/bin', result) | ||
167 | end) | ||
168 | |||
169 | it("does not change order of existing items of appended path", function() | ||
170 | local sys_path = '/usr/local/bin;/usr/bin' | ||
171 | local lr_path = '/home/user/.luarocks/bin;/usr/bin' | ||
172 | local path = sys_path .. ';' .. lr_path | ||
173 | |||
174 | local result = core_util.cleanup_path(path, ';', '5.3', true) | ||
175 | assert.are.equal('/usr/local/bin;/usr/bin;/home/user/.luarocks/bin', result) | ||
176 | end) | ||
177 | |||
160 | it("rewrites versions that do not match the provided version", function() | 178 | it("rewrites versions that do not match the provided version", function() |
161 | local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3/?.lua' | 179 | local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3/?.lua' |
162 | local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3/?.lua', ';', '5.3') | 180 | local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3/?.lua', ';', '5.3') |
163 | assert.are.equal(expected, result) | 181 | assert.are.equal(expected, result) |
164 | end) | 182 | end) |
165 | 183 | ||
166 | it("does not rewrite versions for which the provided version is a substring", function() | 184 | it("does not rewrite versions for which the provided version is a substring", function() |
167 | local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3.4/?.lua' | 185 | local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3.4/?.lua' |
168 | local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3.4/?.lua', ';', '5.3') | 186 | local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3.4/?.lua', ';', '5.3') |
169 | assert.are.equal(expected, result) | 187 | assert.are.equal(expected, result) |
170 | end) | 188 | end) |
171 | end) | 189 | end) |
172 | end) | 190 | end) |