tests/functional2: migrate brotli.sh and zstd.sh

Change-Id: I5f1252e8f29a9551f3d6b2ed8f0598f524906aed
This commit is contained in:
rootile
2026-02-23 20:44:46 +01:00
parent 864c5e7507
commit d641a829bb
4 changed files with 30 additions and 51 deletions
-21
View File
@@ -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 ]]
-2
View File
@@ -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',
-28
View File
@@ -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 ]]
@@ -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