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
114 lines
3.8 KiB
Python
114 lines
3.8 KiB
Python
import re
|
|
|
|
import pytest
|
|
|
|
from testlib.fixtures.file_helper import with_files, CopyFile
|
|
from testlib.fixtures.nix import Nix
|
|
from testlib.utils import get_global_asset
|
|
|
|
_fod_files = {
|
|
"fod-failing.nix": CopyFile("assets/test_build/fod-failing.nix"),
|
|
"config.nix": get_global_asset("config.nix"),
|
|
}
|
|
_build_args = ["build", "-f", "fod-failing.nix", "-L"]
|
|
|
|
|
|
@with_files(_fod_files)
|
|
def test_url_mismatch(nix: Nix):
|
|
res = (
|
|
nix.nix_build(["fod-failing.nix", "-A", "x1"])
|
|
.run()
|
|
.expect(102 if not nix.uses_daemon else 1)
|
|
)
|
|
err = res.stderr_plain
|
|
assert len(re.findall(r"hash mismatch in fixed-output derivation '.*-x1\.drv'", err)) == 1
|
|
assert "likely URL: https://meow.puppy.forge/puppy.tar.gz" in err
|
|
|
|
|
|
@with_files(_fod_files)
|
|
def test_url_keep_going_1(nix: Nix):
|
|
res = nix.nix([*_build_args], flake=True).run().expect(1)
|
|
err = res.stderr_plain
|
|
assert err.count("error:") >= 2
|
|
assert re.findall(r"hash mismatch in fixed-output derivation '.*-x.\.drv'", err)
|
|
assert "likely URL: " in err
|
|
assert re.findall(
|
|
r"error: build of '.*-x[1-8]\.drv\^out'(, '.*-x[1-8]\.drv\^out'){6} failed", err
|
|
)
|
|
|
|
|
|
@with_files(_fod_files)
|
|
def test_url_keep_going_2(nix: Nix):
|
|
res = nix.nix([*_build_args, "x1", "x2", "x3", "--keep-going"], flake=True).run().expect(1)
|
|
err = res.stderr_plain
|
|
assert err.count("error:") == 4
|
|
for f in ["x1", "x2", "x3"]:
|
|
assert re.findall(rf"hash mismatch in fixed-output derivation '.*-{f}\.drv'", err)
|
|
assert "likely URL: https://meow.puppy.forge/puppy.tar.gz" in err
|
|
assert "likely URL: https://kitty.forge/cat.tar.gz" in err
|
|
assert "likely URL: (unknown)" in err
|
|
assert re.findall(
|
|
r"error: build of '.*-x[1-3]\.drv\^out', '.*-x[1-3]\.drv\^out', '.*-x[1-3]\.drv\^out' failed",
|
|
err,
|
|
)
|
|
|
|
|
|
@with_files(_fod_files)
|
|
def test_missing_dependency(nix: Nix):
|
|
res = nix.nix([*_build_args, "x4"], flake=True).run().expect(1)
|
|
err = res.stderr_plain
|
|
assert err.count("error:") >= 2
|
|
assert re.findall(r"error: [12] dependencies of derivation '.*-x4\.drv' failed to build", err)
|
|
assert re.findall(r"hash mismatch in fixed-output derivation '.*-x[23]\.drv'", err)
|
|
|
|
|
|
@with_files(_fod_files)
|
|
def test_missing_dependency_keep_going(nix: Nix):
|
|
res = nix.nix([*_build_args, "x4", "--keep-going"], flake=True).run().expect(1)
|
|
err = res.stderr_plain
|
|
assert err.count("\nerror:") == 3
|
|
assert re.findall(r"error: 2 dependencies of derivation '.*-x4\.drv' failed to build", err)
|
|
for f in ["x2", "x3"]:
|
|
assert re.findall(rf"hash mismatch in fixed-output derivation '.*-{f}\.drv'", err)
|
|
|
|
|
|
@with_files(_fod_files)
|
|
@pytest.mark.parametrize(
|
|
("attr", "url"),
|
|
[
|
|
("x5", "https://avian.example/owls.tar.gz"),
|
|
("x6", "https://avian.example/geese.tar.gz"),
|
|
("x7", "(unknown)"),
|
|
("x8", "https://avian.example/swan1.tar.gz or https://avian.example/swan2.tar.gz"),
|
|
],
|
|
)
|
|
def test_structured_attrs_url(nix: Nix, attr: str, url: str):
|
|
res = nix.nix([*_build_args, attr], flake=True).run().expect(1)
|
|
err = res.stderr_plain
|
|
assert err.count("error: ") == 1
|
|
assert f"likely URL: {url}" in err
|
|
|
|
|
|
@with_files({"config.nix": get_global_asset("config.nix")})
|
|
def test_build_inaccessible_build_dir(nix: Nix):
|
|
env = nix.env
|
|
new_build_dir = env.dirs.home / "build-dir"
|
|
new_build_dir.mkdir()
|
|
new_build_dir.chmod(0o0000)
|
|
try:
|
|
nix.nix(
|
|
[
|
|
"--build-dir",
|
|
str(new_build_dir),
|
|
"build",
|
|
"-E",
|
|
'with import ./config.nix; mkDerivation { name = "test"; buildCommand = "echo rawr > $out"; }',
|
|
"--impure",
|
|
"--no-link",
|
|
],
|
|
flake=True,
|
|
).run().ok()
|
|
finally:
|
|
# clean up perms
|
|
new_build_dir.chmod(0o777)
|