git.iko.soy/typeable/nixpkgs
on master help sign in
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

commitb3337edd0b77f04d0abe4a29642a5e4fdb4ad692 authoraszlig <aszlig@redmoonstudios.org> dateMon 29 Feb 2016, 20:02 (11 years ago) parent5bab623
1 file changed+19−1
nixos/release.nix+19−1
nixos/release.nix+19−1
@@ -13,7 +13,25 @@ let
1313
1414 forAllSystems = genAttrs supportedSystems;
1515
16− callTest = fn: args: forAllSystems (system: hydraJob (import fn ({ inherit system; } // args)));
16+ importTest = fn: args: system: import fn ({
17+ inherit system;
18+ } // args);
19+
20+ callTest = fn: args: forAllSystems (system: hydraJob (importTest fn args system));
21+
22+ callSubTests = fn: args: let
23+ discover = attrs: let
24+ subTests = filterAttrs (const (hasAttr "test")) attrs;
25+ in mapAttrs (const (t: hydraJob t.test)) subTests;
26+
27+ discoverForSystem = system: mapAttrs (_: test: {
28+ ${system} = test;
29+ }) (discover (importTest fn args system));
30+
31+ # If the test is only for a particular system, use only the specified
32+ # system instead of generating attributes for all available systems.
33+ in if args ? system then discover (import fn args)
34+ else foldAttrs (a: b: a // b) {} (map discoverForSystem supportedSystems);
1735
1836 pkgs = import nixpkgs { system = "x86_64-linux"; };
1937