diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2021-03-20 23:44:27 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2021-03-22 10:33:10 -0300 |
commit | dcaca50d670b3f5654c109339b6f37c766558eb1 (patch) | |
tree | 638faf5df7570aa874bafdb4179d00f18f410bac /spec/fetch_spec.lua | |
parent | fbd857e1a0b2aae5beb3875427612e41bf67b35e (diff) | |
download | luarocks-dcaca50d670b3f5654c109339b6f37c766558eb1.tar.gz luarocks-dcaca50d670b3f5654c109339b6f37c766558eb1.tar.bz2 luarocks-dcaca50d670b3f5654c109339b6f37c766558eb1.zip |
fix: pack: rockspec with a bare file in the url
Diffstat (limited to 'spec/fetch_spec.lua')
-rw-r--r-- | spec/fetch_spec.lua | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index 8194a298..008a91c8 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua | |||
@@ -52,8 +52,25 @@ describe("luarocks fetch #unit #mock", function() | |||
52 | end) | 52 | end) |
53 | 53 | ||
54 | it("returns the absolute path of the filename argument if the url represents a file", function() | 54 | it("returns the absolute path of the filename argument if the url represents a file", function() |
55 | local file = fetch.fetch_url("file://a_rock.lua") | 55 | test_env.run_in_tmp(function(tmpdir) |
56 | assert.truthy(are_same_files(file, lfs.currentdir() .. "/a_rock.lua")) | 56 | write_file("test.lua", "return {}", finally) |
57 | |||
58 | fs.change_dir(tmpdir) | ||
59 | local file, err = fetch.fetch_url("file://test.lua") | ||
60 | assert.truthy(file, err) | ||
61 | assert.truthy(are_same_files(file, lfs.currentdir() .. "/test.lua")) | ||
62 | fs.pop_dir() | ||
63 | end, finally) | ||
64 | end) | ||
65 | |||
66 | it("fails if local path is invalid and returns a helpful hint for relative paths", function() | ||
67 | test_env.run_in_tmp(function(tmpdir) | ||
68 | write_file("test.lua", "return {}", finally) | ||
69 | |||
70 | local ok, err = fetch.fetch_url("file://boo.lua") | ||
71 | assert.falsy(ok) | ||
72 | assert.match("note that given path in rockspec is not absolute: file://boo.lua", err) | ||
73 | end, finally) | ||
57 | end) | 74 | end) |
58 | 75 | ||
59 | it("returns false and does nothing if the url argument contains a nonexistent file", function() | 76 | it("returns false and does nothing if the url argument contains a nonexistent file", function() |