Disable exact compression tests and write about why

This commit is contained in:
Filip Tibell 2025-04-24 21:43:41 +02:00
parent c163c6f157
commit 43f11cd9f5
No known key found for this signature in database
2 changed files with 34 additions and 5 deletions

View file

@ -1,5 +1,5 @@
local outer = require("./module")
local inner = require("@self/module") local inner = require("@self/module")
local outer = require("./module")
assert(type(outer) == "table", "Outer module is not a table") assert(type(outer) == "table", "Outer module is not a table")
assert(type(inner) == "table", "Inner module is not a table") assert(type(inner) == "table", "Inner module is not a table")

View file

@ -1,3 +1,22 @@
--[[
The "compress" tests are currently disabled, and may not ever be enabled again.
Unit testing that our compression implementation produces the exact result saved
in test files is very fragile and prone to breakage whenever one of the crates
we depend on for compression algorithms updates, be it to improve compression
ratio, speed, memory usage, or any other metric.
Instead, we should focus on the correctness of the implementation, ensuring that
any files we know are good from other sources can be decompressed without issues.
In the future, it is probably a good idea to rewrite these compression tests so
that they do not rely on any exact output, but instead call some external program
to verify that others can decompress without issues. This is a challenge in and of
itself since finding CLI programs for testing compression is near-impossible, but alas.
]]
local TEST_COMPRESS = false
local TEST_DECOMPRESS = true
local fs = require("@lune/fs") local fs = require("@lune/fs")
local process = require("@lune/process") local process = require("@lune/process")
local serde = require("@lune/serde") local serde = require("@lune/serde")
@ -81,12 +100,22 @@ for _, test in TESTS do
local target = fs.readFile(test.Target) local target = fs.readFile(test.Target)
-- Compression -- Compression
testOperation("Compress", serde.compress, test.Format, source, target) if TEST_COMPRESS then
testOperation("Compress", serde.compress, test.Format, buffer.fromstring(source), target) testOperation("Compress", serde.compress, test.Format, source, target)
testOperation("Compress", serde.compress, test.Format, buffer.fromstring(source), target)
end
-- Decompression -- Decompression
testOperation("Decompress", serde.decompress, test.Format, target, source) if TEST_DECOMPRESS then
testOperation("Decompress", serde.decompress, test.Format, buffer.fromstring(target), source) testOperation("Decompress", serde.decompress, test.Format, target, source)
testOperation(
"Decompress",
serde.decompress,
test.Format,
buffer.fromstring(target),
source
)
end
end end
if failed then if failed then