on iko/ghcjs-patch-master help sign in
Add collectChecks functions (#498)
614a675Michael Peyton Jones
docs/reference/library.md+7−1
@@ -281,7 +281,7 @@ Assorted functions for operating on [Haskell.nix][] data. This is
281distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
281distinct from `pkgs.haskell.lib` in the current Nixpkgs Haskell
282Infrastructure.
282Infrastructure.
283
283
284−### collectComponents and collectComponents'
284+### collectComponents, collectComponents'
285
285
286Extracts a selection of components from a Haskell [package set](#package-set).
286Extracts a selection of components from a Haskell [package set](#package-set).
287
287
@@ -316,6 +316,12 @@ tests = collectComponents "tests" (package: package.identifier.name == "mypackag
316Will result in moving derivations from `hsPkgs.mypackage.components.tests.unit-tests`
316Will result in moving derivations from `hsPkgs.mypackage.components.tests.unit-tests`
317to `tests.mypackage.unit-tests`.
317to `tests.mypackage.unit-tests`.
318
318
319+### collectChecks, collectChecks'
320+
321+These are just like `collectComponents` and `collectComponents'`, except that they collect
322+the `checks` attributes of packages (which aren't components, and so can't be collected
323+by the other functions.
324+
319#### check
325#### check
320
326
321This function turns a derivation that builds a test into one to run it.
327This function turns a derivation that builds a test into one to run it.
lib/default.nix+11
@@ -161,6 +161,17 @@ with haskellLib;
161 # myTests = collectComponents' "tests" myHaskellPackages;
161 # myTests = collectComponents' "tests" myHaskellPackages;
162 collectComponents' = group: collectComponents group (_: true);
162 collectComponents' = group: collectComponents group (_: true);
163
163
164+ # Extracts a selection of 'checks' from a Haskell package set.
165+ #
166+ # This can be used to collect all the test runs in your project, so that can be run in CI.
167+ collectChecks = packageSel: haskellPackages:
168+ let packageFilter = name: package: (package.isHaskell or false) && packageSel package;
169+ in recurseIntoAttrs (lib.mapAttrs (_: p: p.checks) (lib.filterAttrs packageFilter haskellPackages));
170+
171+ # Equivalent to collectChecks with (_: true) as selection function.
172+ # Useful for pre-filtered package-set.
173+ collectChecks' = collectChecks (_: true);
174+
164 # Replacement for lib.cleanSourceWith that has a subDir argument.
175 # Replacement for lib.cleanSourceWith that has a subDir argument.
165 inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
176 inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
166
177