this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test(interop): add lzma, brotli, tar, zip, and tar.* pipeline interop tests

Expands bin/test.sh so `just test full` now exercises every supported format
against its canonical CLI: lzma (xz-utils), brotli, tar, zip, and the four
tar.<codec> compound pipelines (tar.gz/xz/bz2/zst). This catches any drift in
archive-format compatibility the Rust unit tests cannot see — in particular,
that cmprss-produced pipeline archives are readable by the stock tar CLI and
vice versa. Adds brotli/zip/unzip to the devShell so all tools are available.

+136 -1
+133 -1
bin/test.sh
··· 224 224 echo "No errors detected" 225 225 } 226 226 227 + # Test lzma (legacy LZMA1) at the given level against the lzma CLI from xz-utils 228 + test_lzma_level() { 229 + tmpdir 230 + echo "Testing lzma level $1 in $PWD" 231 + echo "Creating random data" 232 + random_file 1000000 file 233 + echo "Compressing with lzma and cmprss" 234 + lzma --stdout -"$1" file >lzma_file.lzma 235 + cmprss lzma --level "$1" file cmprss_file.lzma --progress=off 236 + compare_size lzma_file.lzma cmprss_file.lzma 237 + echo "Decompressing" 238 + lzma --stdout --decompress lzma_file.lzma >lzma_lzma 239 + lzma --stdout --decompress cmprss_file.lzma >cmprss_lzma 240 + cmprss lzma --extract cmprss_file.lzma cmprss_cmprss --progress=off 241 + cmprss lzma --extract lzma_file.lzma lzma_cmprss --progress=off 242 + echo "Comparing the decompressed files" 243 + compare file lzma_lzma 244 + compare file cmprss_lzma 245 + compare file cmprss_cmprss 246 + compare file lzma_cmprss 247 + echo "No errors detected" 248 + } 249 + 250 + test_lzma() { 251 + test_lzma_level 1 252 + test_lzma_level 6 # Default 253 + test_lzma_level 9 254 + } 255 + 256 + # Test brotli at the given quality against the brotli CLI 257 + test_brotli_level() { 258 + tmpdir 259 + echo "Testing brotli quality $1 in $PWD" 260 + echo "Creating random data" 261 + random_file 1000000 file 262 + echo "Compressing with brotli and cmprss" 263 + brotli --quality="$1" --stdout file >brotli_file.br 264 + cmprss brotli --level "$1" file cmprss_file.br --progress=off 265 + compare_size brotli_file.br cmprss_file.br 266 + echo "Decompressing" 267 + brotli --decompress --stdout brotli_file.br >brotli_brotli 268 + brotli --decompress --stdout cmprss_file.br >cmprss_brotli 269 + cmprss brotli --extract cmprss_file.br cmprss_cmprss --progress=off 270 + cmprss brotli --extract brotli_file.br brotli_cmprss --progress=off 271 + echo "Comparing the decompressed files" 272 + compare file brotli_brotli 273 + compare file cmprss_brotli 274 + compare file cmprss_cmprss 275 + compare file brotli_cmprss 276 + echo "No errors detected" 277 + } 278 + 279 + test_brotli() { 280 + test_brotli_level 1 281 + test_brotli_level 6 # Default 282 + test_brotli_level 11 283 + } 284 + 285 + # Test tar archive interop with the tar CLI. Tar has no progress bar, so no 286 + # --progress flag is passed. 287 + test_tar() { 288 + tmpdir 289 + echo "Testing tar in $PWD" 290 + echo "Creating random data" 291 + random_dir 10 indir 292 + echo "Creating tar archives with each tool" 293 + tar -cf tar_archive.tar indir 294 + cmprss tar indir cmprss_archive.tar 295 + echo "Extracting each archive with the opposite tool" 296 + mkdir -p tar_from_cmprss 297 + tar -xf cmprss_archive.tar -C tar_from_cmprss 298 + mkdir -p cmprss_from_tar 299 + cmprss tar --extract tar_archive.tar cmprss_from_tar 300 + echo "Comparing the extracted contents" 301 + compare indir tar_from_cmprss/indir 302 + compare indir cmprss_from_tar/indir 303 + echo "No errors detected" 304 + } 305 + 306 + # Test zip archive interop with the zip/unzip CLIs. Zip has no progress bar, 307 + # so no --progress flag is passed. 308 + test_zip() { 309 + tmpdir 310 + echo "Testing zip in $PWD" 311 + echo "Creating random data" 312 + random_dir 10 indir 313 + echo "Creating zip archives with each tool" 314 + (cd "$(dirname indir)" && zip -qr zip_archive.zip "$(basename indir)") 315 + cmprss zip indir cmprss_archive.zip 316 + echo "Extracting each archive with the opposite tool" 317 + mkdir -p zip_from_cmprss 318 + (cd zip_from_cmprss && unzip -q ../cmprss_archive.zip) 319 + mkdir -p cmprss_from_zip 320 + cmprss zip --extract zip_archive.zip cmprss_from_zip 321 + echo "Comparing the extracted contents" 322 + compare indir zip_from_cmprss/indir 323 + compare indir cmprss_from_zip/indir 324 + echo "No errors detected" 325 + } 326 + 327 + # Shared helper for tar.<codec> pipeline interop. Takes the compound extension 328 + # (tar.gz/tar.xz/tar.zst/tar.bz2) and the corresponding tar short flag 329 + # (-z/-J/--zstd/-j). Verifies that cmprss produces archives the tar CLI can 330 + # read, and vice versa. Pipelines are invoked without a subcommand so 331 + # --progress isn't accepted; the archive is written to a file, not stdout, 332 + # which is fine for tests. 333 + test_tar_pipeline() { 334 + local ext="$1" 335 + local tar_flag="$2" 336 + tmpdir 337 + echo "Testing $ext pipeline in $PWD" 338 + echo "Creating random data" 339 + random_dir 10 indir 340 + echo "Creating $ext archives with each tool" 341 + tar "$tar_flag" -cf tar_archive."$ext" indir 342 + cmprss indir cmprss_archive."$ext" 343 + echo "Extracting each archive with the opposite tool" 344 + mkdir -p tar_from_cmprss 345 + tar "$tar_flag" -xf cmprss_archive."$ext" -C tar_from_cmprss 346 + mkdir -p cmprss_from_tar 347 + cmprss --extract tar_archive."$ext" cmprss_from_tar 348 + echo "Comparing the extracted contents" 349 + compare indir tar_from_cmprss/indir 350 + compare indir cmprss_from_tar/indir 351 + echo "No errors detected" 352 + } 353 + 354 + test_tar_gz() { test_tar_pipeline tar.gz -z; } 355 + test_tar_xz() { test_tar_pipeline tar.xz -J; } 356 + test_tar_bz2() { test_tar_pipeline tar.bz2 -j; } 357 + test_tar_zst() { test_tar_pipeline tar.zst --zstd; } 358 + 227 359 # Run all the tests if no arguments are given 228 360 if [ $# -eq 0 ]; then 229 - set -- gzip xz bzip2 zstd lz4 361 + set -- gzip xz bzip2 zstd lz4 lzma brotli tar zip tar_gz tar_xz tar_bz2 tar_zst 230 362 fi 231 363 232 364 # Run the tests given on the command line
+3
flake.nix
··· 283 283 diffutils 284 284 285 285 # Official tools 286 + brotli 286 287 bzip2 287 288 gnutar 288 289 gzip 289 290 lz4 291 + unzip 290 292 xz 293 + zip 291 294 zstd 292 295 ]; 293 296