From 8e39a526b57a2f9cf021f38cd9ffc8f88abd68fd Mon Sep 17 00:00:00 2001 From: Ryan Hartlage Date: Wed, 1 Aug 2018 15:52:02 -0400 Subject: Do not rewrite path in util.cleanup_path if the desired version is a substring of the version (#868) * Do not rewrite path in util.cleanup_path if the desired version is a substring of the version * Improve test coverage for core.util.cleanup_path --- spec/util_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'spec') diff --git a/spec/util_spec.lua b/spec/util_spec.lua index cbdde095..930a5aea 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -155,4 +155,18 @@ describe("Luarocks util test #unit", function() assert.truthy(result:find("[\"e\"] = \"4\"", 1, true)) end) end) + + describe("core.util.cleanup_path", function() + it("rewrites versions that do not match the provided version", function() + local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3/?.lua' + local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3/?.lua', ';', '5.3') + assert.are.equal(expected, result) + end) + + it("does not rewrite versions for which the provided version is a substring", function() + local expected = 'a/b/lua/5.3/?.lua;a/b/c/lua/5.3.4/?.lua' + local result = core_util.cleanup_path('a/b/lua/5.2/?.lua;a/b/c/lua/5.3.4/?.lua', ';', '5.3') + assert.are.equal(expected, result) + end) + end) end) -- cgit v1.2.3-55-g6feb