From e70b3b80557b41c5a309b67af72db51c1fd2fc17 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Sun, 23 Feb 2025 19:19:19 +0000 Subject: [PATCH] chore(tests): add edge case test for `max_comment_size.zip` --- tests/edge_cases.luau | 12 ++++++++++++ tests/metadata.luau | 1 + 2 files changed, 13 insertions(+) diff --git a/tests/edge_cases.luau b/tests/edge_cases.luau index 33e8132..a974bad 100644 --- a/tests/edge_cases.luau +++ b/tests/edge_cases.luau @@ -66,5 +66,17 @@ return function(test: typeof(frktest.test)) return zip:extractDirectory("/", { type = "text" }) end) end) + + test.case("Efficiently handles ZIP with max length comment", function() + local data = fs.readFile("tests/data/max_comment_size.zip") + local zip = ZipReader.load(buffer.fromstring(data)) + + local unzipResult = process.spawn("unzip", { "-z", "tests/data/max_comment_size.zip" }) + assert(unzipResult.ok) + + print(#unzipResult.stdout, #zip.comment) + -- Check that the comment is the same as the one in the ZIP file (only compare hashes) + check.equal(serde.hash("blake3", unzipResult.stdout), serde.hash("blake3", zip.comment)) + end) end) end diff --git a/tests/metadata.luau b/tests/metadata.luau index a6c9bfd..7b3bb3d 100644 --- a/tests/metadata.luau +++ b/tests/metadata.luau @@ -17,6 +17,7 @@ local FALLIBLES = { "misaligned_comment.zip", "comment_garbage.zip", "chinese.zip", -- FIXME: Support encoding other than UTF-8 and ASCII using OS APIs after FFI + "max_comment_size.zip", -- NOTE: We test for this in the edge cases suite } local METHOD_NAME_TRANSFORMATIONS: { [string]: unzip.CompressionMethod } = {