add test for evaluation errors

This commit is contained in:
Jörg Thalheim 2023-12-10 16:58:22 +01:00
parent e7c30b306d
commit f970ec3524
2 changed files with 15 additions and 0 deletions

View file

@ -7,5 +7,7 @@
in
{
hydraJobs = import ./ci.nix { inherit pkgs; };
legacyPackages.x86_64-linux.brokenPackage = throw "this is an evaluation error";
};
}

View file

@ -68,3 +68,16 @@ def test_expression() -> None:
with open(TEST_ROOT.joinpath("assets/ci.nix"), "r") as ci_nix:
common_test(["-E", ci_nix.read()])
def test_eval_error() -> None:
with TemporaryDirectory() as tempdir:
cmd = [str(BIN), "--gc-roots-dir", tempdir, "--meta", "--flake", ".#legacyPackages.x86_64-linux"]
res = subprocess.run(
cmd,
cwd=TEST_ROOT.joinpath("assets"),
text=True,
stdout=subprocess.PIPE,
)
attrs = json.loads(res.stdout)
assert attrs["attr"] == "brokenPackage"
assert "this is an evaluation error" in attrs["error"]