1
1
Fork 0
mirror of https://github.com/0x5eal/luau-unzip.git synced 2025-04-11 17:50:54 +01:00

style: apply stylua formatter

This commit is contained in:
Erica Marigold 2025-01-10 07:42:19 +00:00
parent 8051b6eed7
commit 2a742aca59
Signed by: DevComp
GPG key ID: 429EF1C337871656
2 changed files with 87 additions and 87 deletions

View file

@ -121,13 +121,13 @@ return function(test: typeof(frktest.test))
local entry = assert(zip:findEntry(assert(name))) local entry = assert(zip:findEntry(assert(name)))
if entry.versionMadeBy.os == "UNIX" then if entry.versionMadeBy.os == "UNIX" then
check.not_nil(entry:unixMode()) check.not_nil(entry:unixMode())
end end
local ok, zipinfoResult = pcall(process.spawn, "zipinfo", { file, name }) local ok, zipinfoResult = pcall(process.spawn, "zipinfo", { file, name })
if ok then if ok then
-- Errors can only occur when there is a non utf-8 file name, in which case -- Errors can only occur when there is a non utf-8 file name, in which case
-- we skip that file -- we skip that file
assert(zipinfoResult.ok) assert(zipinfoResult.ok)
local versionMadeBySoftware, versionMadeByOS = local versionMadeBySoftware, versionMadeByOS =
@ -148,7 +148,7 @@ return function(test: typeof(frktest.test))
if gotCmpr ~= nil then if gotCmpr ~= nil then
check.equal(cmpr, gotCmpr .. "%") check.equal(cmpr, gotCmpr .. "%")
end end
check.equal(METHOD_NAME_TRANSFORMATIONS[method :: string], entry.method) check.equal(METHOD_NAME_TRANSFORMATIONS[method :: string], entry.method)
check.is_true( check.is_true(
dateFuzzyEq(gotDateTime:formatLocalTime("%Y-%m-%d"), expectedDate :: string, 1) dateFuzzyEq(gotDateTime:formatLocalTime("%Y-%m-%d"), expectedDate :: string, 1)

View file

@ -1,83 +1,83 @@
local frktest = require("../lune_packages/frktest") local frktest = require("../lune_packages/frktest")
local check = frktest.assert.check local check = frktest.assert.check
local path = require("../lib/utils/path") local path = require("../lib/utils/path")
return function(test: typeof(frktest.test)) return function(test: typeof(frktest.test))
test.suite("Path utilities function as expected", function() test.suite("Path utilities function as expected", function()
test.case("Canonicalize should handle basic paths", function() test.case("Canonicalize should handle basic paths", function()
check.equal(path.canonicalize("foo/bar"), "foo/bar") check.equal(path.canonicalize("foo/bar"), "foo/bar")
check.equal(path.canonicalize("foo\\bar"), "foo/bar") check.equal(path.canonicalize("foo\\bar"), "foo/bar")
end) end)
test.case("Canonicalize should remove current directory markers", function() test.case("Canonicalize should remove current directory markers", function()
check.equal(path.canonicalize("foo/./bar"), "foo/bar") check.equal(path.canonicalize("foo/./bar"), "foo/bar")
check.equal(path.canonicalize("./foo/bar"), "foo/bar") check.equal(path.canonicalize("./foo/bar"), "foo/bar")
end) end)
test.case("Canonicalize should handle parent directory traversal", function() test.case("Canonicalize should handle parent directory traversal", function()
check.equal(path.canonicalize("foo/bar/../baz"), "foo/baz") check.equal(path.canonicalize("foo/bar/../baz"), "foo/baz")
check.equal(path.canonicalize("foo/bar/../../baz"), "baz") check.equal(path.canonicalize("foo/bar/../../baz"), "baz")
end) end)
test.case("isAbsolute should identify Unix-style absolute paths", function() test.case("isAbsolute should identify Unix-style absolute paths", function()
check.is_true(path.isAbsolute("/foo/bar")) check.is_true(path.isAbsolute("/foo/bar"))
check.is_true(path.isAbsolute("//foo/bar")) check.is_true(path.isAbsolute("//foo/bar"))
end) end)
test.case("isAbsolute should identify Windows-style absolute paths", function() test.case("isAbsolute should identify Windows-style absolute paths", function()
check.is_true(path.isAbsolute("C:\\foo\\bar")) check.is_true(path.isAbsolute("C:\\foo\\bar"))
check.is_true(path.isAbsolute("\\\\server\\share")) check.is_true(path.isAbsolute("\\\\server\\share"))
end) end)
test.case("isAbsolute should identify relative paths", function() test.case("isAbsolute should identify relative paths", function()
check.is_false(path.isAbsolute("foo/bar")) check.is_false(path.isAbsolute("foo/bar"))
check.is_false(path.isAbsolute("./foo/bar")) check.is_false(path.isAbsolute("./foo/bar"))
end) end)
test.case("isRelative should be inverse of isAbsolute", function() test.case("isRelative should be inverse of isAbsolute", function()
check.is_false(path.isRelative("/foo/bar")) check.is_false(path.isRelative("/foo/bar"))
check.is_false(path.isRelative("C:\\foo\\bar")) check.is_false(path.isRelative("C:\\foo\\bar"))
check.is_true(path.isRelative("foo/bar")) check.is_true(path.isRelative("foo/bar"))
check.is_true(path.isRelative("./foo/bar")) check.is_true(path.isRelative("./foo/bar"))
end) end)
test.case("isSafe should reject paths with null bytes", function() test.case("isSafe should reject paths with null bytes", function()
check.is_false(path.isSafe("foo\0bar")) check.is_false(path.isSafe("foo\0bar"))
end) end)
test.case("isSafe should reject absolute paths", function() test.case("isSafe should reject absolute paths", function()
check.is_false(path.isSafe("/foo/bar")) check.is_false(path.isSafe("/foo/bar"))
check.is_false(path.isSafe("C:\\foo\\bar")) check.is_false(path.isSafe("C:\\foo\\bar"))
end) end)
test.case("isSafe should reject paths that escape current directory", function() test.case("isSafe should reject paths that escape current directory", function()
check.is_false(path.isSafe("../foo")) check.is_false(path.isSafe("../foo"))
check.is_false(path.isSafe("foo/../../bar")) check.is_false(path.isSafe("foo/../../bar"))
end) end)
test.case("isSafe should accept safe relative paths", function() test.case("isSafe should accept safe relative paths", function()
check.is_true(path.isSafe("foo/bar")) check.is_true(path.isSafe("foo/bar"))
check.is_true(path.isSafe("foo/bar/baz")) check.is_true(path.isSafe("foo/bar/baz"))
end) end)
test.case("Sanitize should remove special components", function() test.case("Sanitize should remove special components", function()
check.equal(path.sanitize("../foo/bar"), "foo/bar") check.equal(path.sanitize("../foo/bar"), "foo/bar")
check.equal(path.sanitize("./foo/bar"), "foo/bar") check.equal(path.sanitize("./foo/bar"), "foo/bar")
check.equal(path.sanitize("C:\\foo\\bar"), "foo/bar") check.equal(path.sanitize("C:\\foo\\bar"), "foo/bar")
check.equal(path.sanitize("\\\\server\\share\\foo"), "share/foo") check.equal(path.sanitize("\\\\server\\share\\foo"), "share/foo")
end) end)
test.case("Sanitize should truncate at null bytes", function() test.case("Sanitize should truncate at null bytes", function()
check.equal(path.sanitize("foo\0bar/baz"), "foo") check.equal(path.sanitize("foo\0bar/baz"), "foo")
end) end)
test.case("Sanitize should convert backslashes to forward slashes", function() test.case("Sanitize should convert backslashes to forward slashes", function()
check.equal(path.sanitize("foo\\bar\\baz"), "foo/bar/baz") check.equal(path.sanitize("foo\\bar\\baz"), "foo/bar/baz")
end) end)
test.case("Sanitize should handle empty components", function() test.case("Sanitize should handle empty components", function()
check.equal(path.sanitize("/foo//bar"), "foo/bar") check.equal(path.sanitize("/foo//bar"), "foo/bar")
end) end)
end) end)
end end