From f970ec352483ad411b1ea090dc46a92ca0faebab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 10 Dec 2023 16:58:22 +0100 Subject: [PATCH] add test for evaluation errors --- tests/assets/flake.nix | 2 ++ tests/test_eval.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/assets/flake.nix b/tests/assets/flake.nix index 90cb732..fd0a07f 100644 --- a/tests/assets/flake.nix +++ b/tests/assets/flake.nix @@ -7,5 +7,7 @@ in { hydraJobs = import ./ci.nix { inherit pkgs; }; + + legacyPackages.x86_64-linux.brokenPackage = throw "this is an evaluation error"; }; } diff --git a/tests/test_eval.py b/tests/test_eval.py index c64c8b1..eb7e786 100644 --- a/tests/test_eval.py +++ b/tests/test_eval.py @@ -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"]