mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 23:52:33 +00:00
haskell-generic-builder: allow passing flags to the test suite(s)
Every flag the generic builder receives via `testFlags` is passed via `--test-option` [1] to `Setup.hs` which in turn passes them to the underlying test suite binary. These wrapped options are added to `checkFlagsArray` in `checkPhase`. This needs to be done in bash since without structuredAttrs in nixpkgs so far, Nix arrays aren't properly translated into bash arrays, so we'd have all sorts of quoting issues when spaces are involved. Re-using `checkFlags` and `checkFlagsArray` from standard stdenv setup.sh also results in an additional feature: Using `overrideAttrs` `checkFlags` and `checkFlagsArray` can additionally be overridden, which allows passing extra flags to `Setup.hs` whithout being wrapped with `--test-option`. [1]: See also https://cabal.readthedocs.io/en/3.4/setup-commands.html?highlight=test-option#cmdoption-runhaskell-Setup.hs-test-test-option According to the cabal-install man page this also allows passing special variables which are substituted for other values depending on context.
This commit is contained in:
parent
8ba5828c24
commit
57ec1813ff
|
@ -1928,9 +1928,7 @@ EOT
|
||||||
# Disable flaky tests
|
# Disable flaky tests
|
||||||
# https://github.com/DavidEichmann/alpaca-netcode/issues/2
|
# https://github.com/DavidEichmann/alpaca-netcode/issues/2
|
||||||
alpaca-netcode = overrideCabal super.alpaca-netcode {
|
alpaca-netcode = overrideCabal super.alpaca-netcode {
|
||||||
# use testTarget to also pass some flags to the test suite.
|
testFlags = [ "--pattern" "!/[NOCI]/" ];
|
||||||
# TODO: We should add proper support for this to the builder.
|
|
||||||
testTarget = "test --test-options='-p \"!/[NOCI]/\"'";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Tests require to run a binary which isn't built
|
# Tests require to run a binary which isn't built
|
||||||
|
@ -1941,8 +1939,7 @@ EOT
|
||||||
# this, run tests with only a single job.
|
# this, run tests with only a single job.
|
||||||
# https://github.com/vmchale/libarchive/issues/20
|
# https://github.com/vmchale/libarchive/issues/20
|
||||||
libarchive = overrideCabal super.libarchive {
|
libarchive = overrideCabal super.libarchive {
|
||||||
# TODO: We should add proper support for this to the builder.
|
testFlags = [ "-j1" ];
|
||||||
testTarget = "libarchive-test --test-options='-j1'";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# unrestrict bounds for hashable and semigroups
|
# unrestrict bounds for hashable and semigroups
|
||||||
|
|
|
@ -58,7 +58,7 @@ in
|
||||||
, pkg-configDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? [], benchmarkPkgconfigDepends ? []
|
, pkg-configDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? [], benchmarkPkgconfigDepends ? []
|
||||||
, testDepends ? [], testHaskellDepends ? [], testSystemDepends ? [], testFrameworkDepends ? []
|
, testDepends ? [], testHaskellDepends ? [], testSystemDepends ? [], testFrameworkDepends ? []
|
||||||
, benchmarkDepends ? [], benchmarkHaskellDepends ? [], benchmarkSystemDepends ? [], benchmarkFrameworkDepends ? []
|
, benchmarkDepends ? [], benchmarkHaskellDepends ? [], benchmarkSystemDepends ? [], benchmarkFrameworkDepends ? []
|
||||||
, testTarget ? ""
|
, testTarget ? "", testFlags ? []
|
||||||
, broken ? false
|
, broken ? false
|
||||||
, preCompileBuildDriver ? null, postCompileBuildDriver ? null
|
, preCompileBuildDriver ? null, postCompileBuildDriver ? null
|
||||||
, preUnpack ? null, postUnpack ? null
|
, preUnpack ? null, postUnpack ? null
|
||||||
|
@ -454,9 +454,13 @@ stdenv.mkDerivation ({
|
||||||
|
|
||||||
inherit doCheck;
|
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 = ''
|
checkPhase = ''
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
${setupCommand} test ${testTarget}
|
checkFlagsArray+=(${lib.escapeShellArgs (builtins.map (opt: "--test-option=${opt}") testFlags)})
|
||||||
|
${setupCommand} test ${testTarget} $checkFlags ''${checkFlagsArray:+"''${checkFlagsArray[@]}"}
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue