From d641a829bbbcf3304d202596574e8fd5741fad0e Mon Sep 17 00:00:00 2001 From: rootile Date: Fri, 23 Jan 2026 16:15:53 +0100 Subject: [PATCH] tests/functional2: migrate brotli.sh and zstd.sh Change-Id: I5f1252e8f29a9551f3d6b2ed8f0598f524906aed --- tests/functional/brotli.sh | 21 ------------- tests/functional/meson.build | 2 -- tests/functional/zstd.sh | 28 ----------------- .../store/cache/test_cache_compressions.py | 30 +++++++++++++++++++ 4 files changed, 30 insertions(+), 51 deletions(-) delete mode 100644 tests/functional/brotli.sh delete mode 100644 tests/functional/zstd.sh create mode 100644 tests/functional2/store/cache/test_cache_compressions.py diff --git a/tests/functional/brotli.sh b/tests/functional/brotli.sh deleted file mode 100644 index dc9bbdb66..000000000 --- a/tests/functional/brotli.sh +++ /dev/null @@ -1,21 +0,0 @@ -source common.sh - -clearStore -clearCache - -cacheURI="file://$cacheDir?compression=br" - -outPath=$(nix-build dependencies.nix --no-out-link) - -nix copy --to $cacheURI $outPath - -HASH=$(nix hash path $outPath) - -clearStore -clearCacheCache - -nix copy --from $cacheURI $outPath --no-check-sigs - -HASH2=$(nix hash path $outPath) - -[[ $HASH = $HASH2 ]] diff --git a/tests/functional/meson.build b/tests/functional/meson.build index cc87cb21b..f50e3b86e 100644 --- a/tests/functional/meson.build +++ b/tests/functional/meson.build @@ -97,8 +97,6 @@ functional_tests_scripts = [ 'build-dry.sh', 'structured-attrs.sh', 'shell.sh', - 'brotli.sh', - 'zstd.sh', 'nix-copy-ssh.sh', 'nix-copy-ssh-ng.sh', 'pre-hook.sh', diff --git a/tests/functional/zstd.sh b/tests/functional/zstd.sh deleted file mode 100644 index ba7c20501..000000000 --- a/tests/functional/zstd.sh +++ /dev/null @@ -1,28 +0,0 @@ -source common.sh - -clearStore -clearCache - -cacheURI="file://$cacheDir?compression=zstd" - -outPath=$(nix-build dependencies.nix --no-out-link) - -nix copy --to $cacheURI $outPath - -HASH=$(nix hash path $outPath) - -clearStore -clearCacheCache - -nix copy --from $cacheURI $outPath --no-check-sigs - -if ls $cacheDir/nar/*.zst &> /dev/null; then - echo "files do exist" -else - echo "nars do not exist" - exit 1 -fi - -HASH2=$(nix hash path $outPath) - -[[ $HASH = $HASH2 ]] diff --git a/tests/functional2/store/cache/test_cache_compressions.py b/tests/functional2/store/cache/test_cache_compressions.py new file mode 100644 index 000000000..ba1d2edee --- /dev/null +++ b/tests/functional2/store/cache/test_cache_compressions.py @@ -0,0 +1,30 @@ +import pytest + +from testlib.fixtures.file_helper import with_files +from testlib.fixtures.nix import Nix +from testlib.utils import get_global_asset_pack + + +@with_files(get_global_asset_pack("dependencies")) +@pytest.mark.parametrize("algorithm", ["br", "zstd", "xz"]) +def test_cache_compressions(nix: Nix, algorithm: str): + nix.settings.add_xp_feature("nix-command") + cache_uri = f"file://{nix.env.dirs.cache_dir}?compression={algorithm}" + res = nix.nix_build(["dependencies.nix", "--no-out-link"]).run().ok() + out_path = res.stdout_plain + + res = nix.nix(["copy", "--to", cache_uri, out_path]).run().ok() + assert "copying 4 paths..." in res.stderr_plain + hash1 = nix.hash_path(out_path) + + # clear the "cache cache" + for f in (nix.env.dirs.home / ".cache" / "nix").glob("test-binary-cache*"): + f.unlink() + nix.clear_store() + + res = nix.nix(["copy", "--from", cache_uri, out_path, "--no-check-sigs"]).run().ok() + assert "copying 4 paths..." in res.stderr_plain + + hash2 = nix.hash_path(out_path) + + assert hash1 == hash2