1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-24 14:41:17 +00:00

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
This commit is contained in:
aszlig 2016-02-29 20:02:26 +01:00
parent 5bab623fb9
commit b3337edd0b
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961

View file

@ -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"; };