on 19052d8 help sign in
haskell.nix/lib/check.nix
51 lines 1.6 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 # Using `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
31 ${
32 # Change to the source sub directory if there is one.
33 lib.optionalString (drv.srcSubDir or "" != "") ''
34 cd ${lib.removePrefix "/" drv.srcSubDir}
35 ''
36 }
38 runHook preCheck
40 ${toString component.testWrapper} ${drv}/bin/${drv.exeName} ${lib.concatStringsSep " " component.testFlags} | tee $out/test-stdout
42 # Copy over tix files, if they exist
43 find . -iname '${drv.exeName}.tix' -exec mkdir -p $out/share/hpc/vanilla/tix/${drv.exeName} \; -exec cp {} $out/share/hpc/vanilla/tix/${drv.exeName}/ \;
45 runHook postCheck
46 '';
47} // haskellLib.optionalHooks {
48 inherit (component) preCheck postCheck;
50// lib.optionalAttrs (drv ? LOCALE_ARCHIVE) { inherit (drv) LOCALE_ARCHIVE; }