Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 19 additions & 22 deletions lib/check.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{ stdenv, lib, haskellLib, srcOnly }:
{ stdenv, lib, haskellLib }:
drv:

let
component = drv.config;

subdir =
if drv?source
then
drv.srcSubDir or ""
else
# srcOnly returns just the subdir, so we're already in it.
"";

# This derivation can be used to execute test component.
# The $out of the derivation is a file containing the resulting
# stdout output.
in stdenv.mkDerivation ({
in stdenv.mkDerivation ((
if drv ? source
then {
src = drv.source;
patchPhase =
# This `cd` is normally done in the `prePatch` of the drv
lib.optionalString (drv.srcSubDir != "") ''
cd ${lib.removePrefix "/" drv.srcSubDir}
'';
}
else
# This makes the derivation work a bit like `srcOnly`,
# using the original derivation, but replacing the `buildPhase`.
(drv.drvAttrs or drv) // {
outputs = [ "out" ];
separateDebugInfo = false;
}) // {
name = (drv.name + "-check");

# Using `srcOnly` (rather than getting the `src` via a `drv.passthru`)
# should correctly apply the patches from `drv` (if any).
src = drv.source or (srcOnly drv);

passthru = {
inherit (drv) identifier config configFiles executableToolDepends cleanSrc env exeName;
};
Expand All @@ -30,19 +34,12 @@ in stdenv.mkDerivation ({

inherit (component) doCheck doCrossCheck;

phases = ["unpackPhase" "buildPhase"];
phases = ["unpackPhase" "patchPhase" "buildPhase"];

# If doCheck or doCrossCheck are false we may still build this
# component and we want it to quietly succeed.
buildPhase = ''
mkdir $out
${
# Change to the source sub directory if there is one.
lib.optionalString (subdir != "") ''
cd ${lib.removePrefix "/" subdir}
''
}

runHook preCheck

${toString component.testWrapper} ${drv}/bin/${drv.exeName} ${lib.concatStringsSep " " component.testFlags} | tee $out/test-stdout
Expand Down
2 changes: 1 addition & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ in {

# Check a test component
check = import ./check.nix {
inherit stdenv lib haskellLib srcOnly;
inherit stdenv lib haskellLib;
};

# Do coverage of a package
Expand Down