on e94de40 help sign in
haskell.nix/lib/check.nix
45 lines 1.4 kB history raw
1{ stdenv, lib, haskellLib, srcOnly }:
2drv:
4let
5 component = drv.config;
7# This derivation can be used to execute test component.
8# The $out of the derivation is a file containing the resulting
9# stdout output.
10in stdenv.mkDerivation ({
11 name = (drv.name + "-check");
13 # Useing `srcOnly` (rather than getting the `src` via a `drv.passthru`)
14 # should correctly apply the patches from `drv` (if any).
15 src = drv.source or (srcOnly drv);
17 passthru = {
18 inherit (drv) identifier config configFiles executableToolDepends cleanSrc env exeName;
19 };
21 inherit (drv) meta LANG LC_ALL buildInputs nativeBuildInputs;
23 inherit (component) doCheck doCrossCheck;
25 phases = ["unpackPhase" "buildPhase"];
27 # If doCheck or doCrossCheck are false we may still build this
28 # component and we want it to quietly succeed.
29 buildPhase = ''
30 mkdir $out
32 runHook preCheck
34 ${toString component.testWrapper} ${drv}/bin/${drv.exeName} ${lib.concatStringsSep " " component.testFlags} | tee $out/test-stdout
36 # Copy over tix files, if they exist
37 find . -iname '${drv.exeName}.tix' -exec mkdir -p $out/share/hpc/vanilla/tix/${drv.exeName} \; -exec cp {} $out/share/hpc/vanilla/tix/${drv.exeName}/ \;
39 runHook postCheck
40 '';
41} // haskellLib.optionalHooks {
42 inherit (component) preCheck postCheck;
44// lib.optionalAttrs (drv ? LOCALE_ARCHIVE) { inherit (drv) LOCALE_ARCHIVE; }