aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.nix2
-rw-r--r--nixos/tests/all-tests.nix24
-rw-r--r--nixos/tests/dsl.nix31
3 files changed, 39 insertions, 18 deletions
diff --git a/flake.nix b/flake.nix
index bef6329..10314f9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -67,7 +67,7 @@
legacyPackages = forAllSystems (
{ pkgs, ... }:
{
- nixosTests = import ./nixos/tests/all-tests.nix pkgs;
+ nixosTests = pkgs.callPackage ./nixos/tests/all-tests.nix { };
}
);
checks = forAllSystems (
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 68342d6..158c025 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -1,4 +1,4 @@
-pkgs:
+{ testers }:
let
dsl = ./dsl.nix;
@@ -54,7 +54,7 @@ in
builtins.mapAttrs
(
name: value:
- pkgs.testers.runNixOSTest (
+ testers.runNixOSTest (
{
inherit name;
testScript = ''
@@ -105,12 +105,20 @@ builtins.mapAttrs
sunset-unbuilt-0 = {
imports = [
{
- # all builds
- dag.needBuilds = 9;
- # all builds allowed
- dag.allowBuilds = 5;
- # chosen builds requested
- dag.choseBuilds = 3;
+ dag = {
+ # all builds
+ needBuilds = 9;
+ # all builds allowed
+ allowBuilds = 5;
+ # chosen builds requested
+ choseBuilds = 3;
+
+ nodes = {
+ a.assertChosen = true;
+ b.assertChosen = true;
+ c.assertChosen = true;
+ };
+ };
}
sunset
];
diff --git a/nixos/tests/dsl.nix b/nixos/tests/dsl.nix
index b22c521..63fcfae 100644
--- a/nixos/tests/dsl.nix
+++ b/nixos/tests/dsl.nix
@@ -105,11 +105,11 @@ in
'';
requestExpressions = pkgs.writeText "guest-request-scope.nix" ''
let
- pkgs = import /nix/store/r365xbb4lp3h3vzahr97aysrzd4dysis-yqy82fn77fy3rv7lpwa9m11w3a2nnqg5-source { };
- config = builtins.fromJSON (builtins.readFile /nix/store/4jai0ds3f1kswspwdib1ggxwyikv1jhr-nix-dag.json);
+ pkgs = import ${pkgs.path} { };
+ config = builtins.fromJSON (builtins.readFile ${configJson});
testPkgs = import ${expressions};
in
- pkgs.lib.attrsets.filterAttrs (name: node: !(config.nodes ? ''${name}) || config.nodes.''${name}.request ) testPkgs
+ pkgs.lib.attrsets.filterAttrs (name: node: !(config.nodes ? ''${name}) || (config.nodes.''${name} ? request && config.nodes.''${name}.request)) testPkgs
'';
tester = pkgs.writers.writePython3Bin "dag-test" { } ''
@@ -222,12 +222,27 @@ in
assert len(need_builds) == expected_need_builds, f"{len(need_builds)} != {expected_need_builds}; building {need_builds}"
print("Verified `needBuilds`", file=sys.stderr)
- if config.get("allowBuilds", None) is not None and config.get("choseBuilds", None) is not None:
- p = subprocess.run(["evanix", "${requestExpressions}", "--dry-run", "--solver=highs", "--max-build", str(config["allowBuilds"])], check=True, stdout=subprocess.PIPE)
- output = p.stdout.decode("utf-8")
- evanix_builds = parse_evanix_dry_run(output)
+ evanix_args = ["evanix", "${requestExpressions}", "--dry-run", "--close-unused-fd", "false"]
+ if config.get("allowBuilds", None) is not None:
+ evanix_args.extend(["--solver=highs", "--max-build", str(config["allowBuilds"])])
+
+ evanix = subprocess.run(evanix_args, check=True, stdout=subprocess.PIPE)
+ evanix_output = evanix.stdout.decode("utf-8")
+ evanix_builds = parse_evanix_dry_run(evanix_output)
+
+ if config.get("choseBuilds", None) is not None:
assert len(evanix_builds) == config["choseBuilds"], f"len({evanix_builds}) != choseBuilds"
print("Verified `choseBuilds`", file=sys.stderr)
+
+ hadAssertChosen = False
+ for name, node in nodes.items():
+ if "assertChosen" not in node or not node["assertChosen"]:
+ continue
+ else:
+ hadAssertChosen = True
+ assert name in evanix_builds, f"{name}.assertChosen failed"
+ if hadAssertChosen:
+ print("Verified `assertChosen`", file=sys.stderr)
'';
in
{
@@ -238,8 +253,6 @@ in
(builtins.map ({ name, ... }: scope.${name}))
]
++ [
- expressions
- requestExpressions
pkgs.path
# Cache runCommand's dependencies such as runtimeShell