This commit enables the parametrization for "legacy-combined" protocol. All failing tests with that have been either fixed or disabled. Notably: - A couple of tests (e.g. involving builders) could be made to work with a non-local store, but this would require some refactoring to testlib in order to make certain configuration settings generic over local and remote operations. We've disabled those for now, in order to make progress - The store tests all run locally only because of their nature - The flakes tests also all run locally only because my energy for fixing them is limited (and it's a *lot* of test failures, with probably little overall benefit in terms of test coverage) Change-Id: I56fa249a64f7c17c952f688ec89e9687f2a13f12
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
from textwrap import dedent
|
|
|
|
from testlib.fixtures.nix import Nix
|
|
import pytest
|
|
|
|
|
|
# FIXME: clear_store breaks daemons
|
|
@pytest.mark.no_daemon
|
|
def test_substitute_truncated_nar(nix: Nix):
|
|
drv = dedent("""
|
|
derivation {
|
|
name = "text";
|
|
system = builtins.currentSystem;
|
|
builder = "/bin/sh";
|
|
args = [ "-c" "echo some text to make the nar less empty > $out" ];
|
|
}
|
|
""")
|
|
cache_dir = nix.env.dirs.cache_dir
|
|
cache_uri = f"file://{cache_dir}?compression=none"
|
|
nar = cache_dir / "nar" / "0513ia03lmqyq8bipmvv0awjji48li22rbmm9p5iwzm08y8m810z.nar"
|
|
nix.settings.add_xp_feature("nix-command")
|
|
|
|
res = nix.nix_build(["--no-out-link", "--expr", drv]).run().ok()
|
|
out_path = res.stdout_plain
|
|
|
|
res = nix.nix(["copy", "--to", cache_uri, out_path]).run().ok()
|
|
assert "copying 1 path" in res.stderr_plain
|
|
|
|
assert nar.exists()
|
|
|
|
res = nix.nix([], "nix-collect-garbage").run().ok()
|
|
# .drv file + built path
|
|
assert "2 store paths deleted" in res.stderr_plain
|
|
|
|
args = [
|
|
"--no-out-link",
|
|
"--debug",
|
|
"--option",
|
|
"substituters",
|
|
cache_uri,
|
|
"--option",
|
|
"require-sigs",
|
|
"false",
|
|
"-j0",
|
|
"--expr",
|
|
drv,
|
|
]
|
|
|
|
# Ensure we can substitute with a non-corrupted nar
|
|
res = nix.nix_build(args).run().ok()
|
|
|
|
nar.write_bytes(nar.read_bytes()[:-10])
|
|
nix.clear_store()
|
|
|
|
res = nix.nix_build(args).run().expect(1)
|
|
assert "error: some substitutes for the outputs of derivation" in res.stderr_plain
|
|
assert "error: bad archive: unexpected end of nar encountered" in res.stderr_plain
|