From 9f22e12deadfd5c81992c742052d6dd9a011792b Mon Sep 17 00:00:00 2001 From: Teo Camarasu Date: Mon, 10 Feb 2025 18:11:06 +0000 Subject: [PATCH] haskellPackages.mkDerivation: Replace testTarget with testTargets testTarget takes a space separated list of test suites to run. We itnroduce a new testTargets argument that instead takes a list, and add a backwards compatibility shim --- doc/languages-frameworks/haskell.section.md | 4 ++-- doc/release-notes/rl-2505.section.md | 4 ++++ .../haskell-modules/configuration-common.nix | 8 ++++---- pkgs/development/haskell-modules/configuration-nix.nix | 8 ++++---- pkgs/development/haskell-modules/generic-builder.nix | 10 ++++++++-- pkgs/tools/nix/nix-output-monitor/default.nix | 2 +- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/doc/languages-frameworks/haskell.section.md b/doc/languages-frameworks/haskell.section.md index 448cd8e19249..d9bbca300286 100644 --- a/doc/languages-frameworks/haskell.section.md +++ b/doc/languages-frameworks/haskell.section.md @@ -297,8 +297,8 @@ Defaults to `false`. : Whether to build (HTML) documentation using [haddock][haddock]. Defaults to `true` if supported. -`testTarget` -: Name of the test suite to build and run. If unset, all test suites will be executed. +`testTargets` +: Names of the test suites to build and run. If unset, all test suites will be executed. `preCompileBuildDriver` : Shell code to run before compiling `Setup.hs`. diff --git a/doc/release-notes/rl-2505.section.md b/doc/release-notes/rl-2505.section.md index 9c3a264db53e..43d2c100af1b 100644 --- a/doc/release-notes/rl-2505.section.md +++ b/doc/release-notes/rl-2505.section.md @@ -37,3 +37,7 @@ - `functor.wrapped` is now deprecated for some types and using it will give a warning with migration instructions. It is deprecated for these types: - `lib.types.attrsWith` - `lib.types.listOf` + +- The `testTarget` argument of `haskellPackages.mkDerivation` has been deprecated in favour of `testTargets`. + `testTarget` took a space separated string of targets, whereas the new `testTargets` argument takes a list of targets. + For instance, `testTarget = "foo bar baz"` should become `testTargets = [ "foo" "bar" "baz" ]`. diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 126d5fa57a5e..3332d9f57324 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -149,7 +149,7 @@ self: super: { # Too strict bounds on doctest which isn't used, but is part of the configuration jailbreak = true; # vector-doctest seems to be broken when executed via ./Setup test - testTarget = lib.concatStringsSep " " [ + testTargets = [ "vector-tests-O0" "vector-tests-O2" ]; @@ -890,7 +890,7 @@ self: super: { CHXHtml = dontDistribute super.CHXHtml; # https://github.com/NixOS/nixpkgs/issues/6350 - paypal-adaptive-hoops = overrideCabal (drv: { testTarget = "local"; }) super.paypal-adaptive-hoops; + paypal-adaptive-hoops = overrideCabal (drv: { testTargets = [ "local" ]; }) super.paypal-adaptive-hoops; # Avoid "QuickCheck >=2.3 && <2.10" dependency we cannot fulfill in lts-11.x. test-framework = dontCheck super.test-framework; @@ -2507,7 +2507,7 @@ self: super: { rm Setup.hs ''; # doctest suite uses doctest-parallel which still doesn't work in nixpkgs - testTarget = "tests"; + testTargets = [ "tests" ]; }) super.conduit-aeson; hermes-json = overrideCabal (drv: { @@ -2543,7 +2543,7 @@ self: super: { # Disabling doctests. regex-tdfa = overrideCabal { - testTarget = "regex-tdfa-unittest"; + testTargets = [ "regex-tdfa-unittest" ]; } super.regex-tdfa; # Missing test files https://github.com/kephas/xdg-basedir-compliant/issues/1 diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index 95699a5e4c30..ac66efa95a8e 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -75,7 +75,7 @@ self: super: builtins.intersectAttrs super { chmod +x "$out/bin/haskell-language-server" ''; testToolDepends = [ self.cabal-install pkgs.git ]; - testTarget = "func-test"; # wrapper test accesses internet + testTargets = [ "func-test" ]; # wrapper test accesses internet preCheck = '' export PATH=$PATH:$PWD/dist/build/haskell-language-server:$PWD/dist/build/haskell-language-server-wrapper export HOME=$TMPDIR @@ -334,7 +334,7 @@ self: super: builtins.intersectAttrs super { digitalocean-kzs = dontCheck super.digitalocean-kzs; # https://github.com/KazumaSATO/digitalocean-kzs/issues/1 github-types = dontCheck super.github-types; # http://hydra.cryp.to/build/1114046/nixlog/1/raw hadoop-rpc = dontCheck super.hadoop-rpc; # http://hydra.cryp.to/build/527461/nixlog/2/raw - hjsonschema = overrideCabal (drv: { testTarget = "local"; }) super.hjsonschema; + hjsonschema = overrideCabal (drv: { testTargets = [ "local" ]; }) super.hjsonschema; marmalade-upload = dontCheck super.marmalade-upload; # http://hydra.cryp.to/build/501904/nixlog/1/raw mongoDB = dontCheck super.mongoDB; network-transport-tcp = dontCheck super.network-transport-tcp; @@ -701,7 +701,7 @@ self: super: builtins.intersectAttrs super { # Not running the "example" test because it requires a binary from lsps test # suite which is not part of the output of lsp. - lsp-test = overrideCabal (old: { testTarget = "tests func-test"; }) super.lsp-test; + lsp-test = overrideCabal (old: { testTargets = [ "tests" "func-test" ]; }) super.lsp-test; # the test suite attempts to run the binaries built in this package # through $PATH but they aren't in $PATH @@ -1275,7 +1275,7 @@ self: super: builtins.intersectAttrs super { "-p" "!/oeis/" ]; # disco-examples needs network access - testTarget = "disco-tests"; + testTargets = [ "disco-tests" ]; }) super.disco; # Apply a patch which hardcodes the store path of graphviz instead of using diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 8b24fbe3ebd7..90b1b583cd34 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -83,7 +83,9 @@ in , pkg-configDepends ? [], libraryPkgconfigDepends ? [], executablePkgconfigDepends ? [], testPkgconfigDepends ? [], benchmarkPkgconfigDepends ? [] , testDepends ? [], testHaskellDepends ? [], testSystemDepends ? [], testFrameworkDepends ? [] , benchmarkDepends ? [], benchmarkHaskellDepends ? [], benchmarkSystemDepends ? [], benchmarkFrameworkDepends ? [] -, testTarget ? "", testFlags ? [] +, # testTarget is deprecated. Use testTargets instead. + testTarget ? "" +, testTargets ? lib.strings.splitString " " testTarget, testFlags ? [] , broken ? false , preCompileBuildDriver ? null, postCompileBuildDriver ? null , preUnpack ? null, postUnpack ? null @@ -408,6 +410,10 @@ let exec "$@" ''; + testTargetsString = + lib.warnIf (testTarget != "") "haskellPackages.mkDerivation: testTarget is deprecated. Use testTargets instead" + (lib.concatStringsSep " " testTargets); + in lib.fix (drv: stdenv.mkDerivation ({ @@ -616,7 +622,7 @@ stdenv.mkDerivation ({ ${lib.escapeShellArgs (builtins.map (opt: "--test-option=${opt}") testFlags)} ) export NIX_GHC_PACKAGE_PATH_FOR_TEST="''${NIX_GHC_PACKAGE_PATH_FOR_TEST:-$packageConfDir:}" - ${setupCommand} test ${testTarget} $checkFlags ''${checkFlagsArray:+"''${checkFlagsArray[@]}"} + ${setupCommand} test ${testTargetsString} $checkFlags ''${checkFlagsArray:+"''${checkFlagsArray[@]}"} runHook postCheck ''; diff --git a/pkgs/tools/nix/nix-output-monitor/default.nix b/pkgs/tools/nix/nix-output-monitor/default.nix index 03b0e0b78a0c..c50be7ede2a1 100644 --- a/pkgs/tools/nix/nix-output-monitor/default.nix +++ b/pkgs/tools/nix/nix-output-monitor/default.nix @@ -12,7 +12,7 @@ let # nom has unit-tests and golden-tests # golden-tests call nix and thus can’t be run in a nix build. - testTarget = "unit-tests"; + testTargets = [ "unit-tests" ]; buildTools = [ installShellFiles ]; postInstall = ''