diff options
author | aszlig <aszlig@redmoonstudios.org> | 2016-02-29 20:02:26 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2016-03-01 01:04:35 +0100 |
commit | b3337edd0b77f04d0abe4a29642a5e4fdb4ad692 (patch) | |
tree | 71be28f7c1c8892c61f1c984a5e3b45dfd0d9b09 /nixos/release.nix | |
parent | 5bab623fb93567e9f3217e90c7e2679388ec86a3 (diff) | |
download | nixpkgs-b3337edd0b77f04d0abe4a29642a5e4fdb4ad692.tar nixpkgs-b3337edd0b77f04d0abe4a29642a5e4fdb4ad692.tar.gz nixpkgs-b3337edd0b77f04d0abe4a29642a5e4fdb4ad692.tar.bz2 nixpkgs-b3337edd0b77f04d0abe4a29642a5e4fdb4ad692.tar.lz nixpkgs-b3337edd0b77f04d0abe4a29642a5e4fdb4ad692.tar.xz nixpkgs-b3337edd0b77f04d0abe4a29642a5e4fdb4ad692.tar.zst nixpkgs-b3337edd0b77f04d0abe4a29642a5e4fdb4ad692.zip |
nixos/release.nix: Add a callSubTests function
This should de-clutter the various redundant lines of callTest's on subtests so that every main test file should have only one line with a callSubTests instead. Overrides work the same way as callTest, except that if the system attribute is explicitly specified we do not generate attributes for all available systems. Signed-off-by: aszlig <aszlig@redmoonstudios.org> Cc: @edolstra
Diffstat (limited to 'nixos/release.nix')
-rw-r--r-- | nixos/release.nix | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/nixos/release.nix b/nixos/release.nix index 497056c2274..76d0ce90458 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -13,7 +13,25 @@ let forAllSystems = genAttrs supportedSystems; - callTest = fn: args: forAllSystems (system: hydraJob (import fn ({ inherit system; } // args))); + importTest = fn: args: system: import fn ({ + inherit system; + } // args); + + callTest = fn: args: forAllSystems (system: hydraJob (importTest fn args system)); + + callSubTests = fn: args: let + discover = attrs: let + subTests = filterAttrs (const (hasAttr "test")) attrs; + in mapAttrs (const (t: hydraJob t.test)) subTests; + + discoverForSystem = system: mapAttrs (_: test: { + ${system} = test; + }) (discover (importTest fn args system)); + + # If the test is only for a particular system, use only the specified + # system instead of generating attributes for all available systems. + in if args ? system then discover (import fn args) + else foldAttrs (a: b: a // b) {} (map discoverForSystem supportedSystems); pkgs = import nixpkgs { system = "x86_64-linux"; }; |