Skip to content

Commit 6a9654b

Browse files
committed
should fix ci tests
1 parent e377608 commit 6a9654b

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

tests/plenary/path2_spec.lua

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,38 @@ local function plat_path(p)
4646
return p:gsub("/", "\\")
4747
end
4848

49+
50+
-- set up mock file with consistent eol regardless of system (git autocrlf settings)
51+
-- simplifies reading tests
52+
local licence_lines = {
53+
"MIT License",
54+
"",
55+
"Copyright (c) 2020 TJ DeVries",
56+
"",
57+
"Permission is hereby granted, free of charge, to any person obtaining a copy",
58+
'of this software and associated documentation files (the "Software"), to deal',
59+
"in the Software without restriction, including without limitation the rights",
60+
"to use, copy, modify, merge, publish, distribute, sublicense, and/or sell",
61+
"copies of the Software, and to permit persons to whom the Software is",
62+
"furnished to do so, subject to the following conditions:",
63+
"",
64+
"The above copyright notice and this permission notice shall be included in all",
65+
"copies or substantial portions of the Software.",
66+
"",
67+
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR',
68+
"IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,",
69+
"FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE",
70+
"AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER",
71+
"LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,",
72+
"OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE",
73+
"SOFTWARE.",
74+
"",
75+
}
76+
77+
local license_str = table.concat(licence_lines, "\n")
78+
local tmp_license = Path:new "TMP_LICENSE"
79+
tmp_license:write(license_str, "w")
80+
4981
describe("Path2", function()
5082
describe("filename", function()
5183
local function get_paths()
@@ -919,7 +951,7 @@ describe("Path2", function()
919951
end)
920952

921953
it_cross_plat("should read head of file", function()
922-
local p = Path:new "LICENSE"
954+
local p = Path:new "TMP_LICENSE"
923955
local data = p:head()
924956
local should = [[MIT License
925957
@@ -936,14 +968,14 @@ furnished to do so, subject to the following conditions:]]
936968
end)
937969

938970
it_cross_plat("should read the first line of file", function()
939-
local p = Path:new "LICENSE"
971+
local p = Path:new "TMP_LICENSE"
940972
local data = p:head(1)
941973
local should = [[MIT License]]
942974
assert.are.same(should, data, diff_str(should, data))
943975
end)
944976

945977
it_cross_plat("should max read whole file", function()
946-
local p = Path:new "LICENSE"
978+
local p = Path:new "TMP_LICENSE"
947979
local data = p:head(1000)
948980
local should = [[MIT License
949981
@@ -1006,7 +1038,7 @@ SOFTWARE.]]
10061038
end)
10071039

10081040
it_cross_plat("should read tail of file", function()
1009-
local p = Path:new "LICENSE"
1041+
local p = Path:new "TMP_LICENSE"
10101042
local data = p:tail()
10111043
local should = [[The above copyright notice and this permission notice shall be included in all
10121044
copies or substantial portions of the Software.
@@ -1022,14 +1054,14 @@ SOFTWARE.]]
10221054
end)
10231055

10241056
it_cross_plat("should read the last line of file", function()
1025-
local p = Path:new "LICENSE"
1057+
local p = Path:new "TMP_LICENSE"
10261058
local data = p:tail(1)
10271059
local should = [[SOFTWARE.]]
10281060
assert.are.same(should, data, diff_str(should, data))
10291061
end)
10301062

10311063
it_cross_plat("should max read whole file", function()
1032-
local p = Path:new "LICENSE"
1064+
local p = Path:new "TMP_LICENSE"
10331065
local data = p:tail(1000)
10341066
local should = [[MIT License
10351067
@@ -1103,14 +1135,14 @@ SOFTWARE.]]
11031135
end)
11041136

11051137
it_cross_plat("should read bytes at given offset", function()
1106-
local p = Path:new "LICENSE"
1138+
local p = Path:new "TMP_LICENSE"
11071139
local data = p:readbyterange(13, 10)
11081140
local should = "Copyright "
11091141
assert.are.same(should, data, diff_str(should, data))
11101142
end)
11111143

11121144
it_cross_plat("supports negative offset", function()
1113-
local p = Path:new "LICENSE"
1145+
local p = Path:new "TMP_LICENSE"
11141146
local data = p:readbyterange(-10, 10)
11151147
local should = "SOFTWARE.\n"
11161148
assert.are.same(should, data, diff_str(should, data))
@@ -1160,7 +1192,7 @@ SOFTWARE.]]
11601192
end)
11611193

11621194
it_cross_plat("no offset", function()
1163-
local p = Path:new "LICENSE"
1195+
local p = Path:new "TMP_LICENSE"
11641196
local data = p:readbyterange(0, 11)
11651197
local should = "MIT License"
11661198
assert.are.same(should, data, diff_str(should, data))
@@ -1240,3 +1272,5 @@ SOFTWARE.]]
12401272
end)
12411273
end)
12421274
end)
1275+
1276+
tmp_license:rm()

0 commit comments

Comments
 (0)