about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/haskell-modules/generic-builder.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/haskell-modules/generic-builder.nix')
-rw-r--r--nixpkgs/pkgs/development/haskell-modules/generic-builder.nix10
1 files changed, 7 insertions, 3 deletions
diff --git a/nixpkgs/pkgs/development/haskell-modules/generic-builder.nix b/nixpkgs/pkgs/development/haskell-modules/generic-builder.nix
index a9c8f11223f7..2b2f23e20eaf 100644
--- a/nixpkgs/pkgs/development/haskell-modules/generic-builder.nix
+++ b/nixpkgs/pkgs/development/haskell-modules/generic-builder.nix
@@ -58,7 +58,7 @@ in
 , pkg-configDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? [], benchmarkPkgconfigDepends ? []
 , testDepends ? [], testHaskellDepends ? [], testSystemDepends ? [], testFrameworkDepends ? []
 , benchmarkDepends ? [], benchmarkHaskellDepends ? [], benchmarkSystemDepends ? [], benchmarkFrameworkDepends ? []
-, testTarget ? ""
+, testTarget ? "", testFlags ? []
 , broken ? false
 , preCompileBuildDriver ? null, postCompileBuildDriver ? null
 , preUnpack ? null, postUnpack ? null
@@ -454,9 +454,13 @@ stdenv.mkDerivation ({
 
   inherit doCheck;
 
+  # Run test suite(s) and pass `checkFlags` as well as `checkFlagsArray`.
+  # `testFlags` are added to `checkFlagsArray` each prefixed with
+  # `--test-option`, so Cabal passes it to the underlying test suite binary.
   checkPhase = ''
     runHook preCheck
-    ${setupCommand} test ${testTarget}
+    checkFlagsArray+=(${lib.escapeShellArgs (builtins.map (opt: "--test-option=${opt}") testFlags)})
+    ${setupCommand} test ${testTarget} $checkFlags ''${checkFlagsArray:+"''${checkFlagsArray[@]}"}
     runHook postCheck
   '';
 
@@ -481,7 +485,7 @@ stdenv.mkDerivation ({
       # ^^ if the project is not a library, and we have a build target, then use "copy" to install
       # just the target specified; "install" will error here, since not all targets have been built.
     else ''
-      ${setupCommand} copy
+      ${setupCommand} copy ${buildTarget}
       local packageConfDir="$out/lib/${ghc.name}/package.conf.d"
       local packageConfFile="$packageConfDir/${pname}-${version}.conf"
       mkdir -p "$packageConfDir"