haskellPackages: avoid re-enabling previously disabled tests

The intent of all doCheck = <condition>, where condition is possibly true, is to disable
the tests in a specific case. However, as currently written, this also has the effect of
re-enabling the tests, even if they have been disabled by an override before, e.g. to
mkDerivation.

This also affects the default value given in mkDerivation, which is !isCross. Before this
change, aeson for example, would have been built with tests when cross-compiling, which
was not intended.

The proper way is to set the doCheck = false attribute only conditionally, and otherwise
rely on a previous override or the default value given in mkDerivation.
This commit is contained in:
Wolfgang Walther 2024-02-10 15:15:56 +01:00
parent 85ebf8847e
commit df284fa43c
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
2 changed files with 27 additions and 25 deletions

View File

@ -145,11 +145,11 @@ self: super: {
czipwith = doJailbreak super.czipwith;
# Deal with infinite and NaN values generated by QuickCheck-2.14.3
aeson = overrideCabal {
aeson = overrideCabal (lib.optionalAttrs pkgs.stdenv.hostPlatform.is32bit {
# aeson's test suite includes some tests with big numbers that fail on 32bit
# https://github.com/haskell/aeson/issues/1060
doCheck = !pkgs.stdenv.hostPlatform.is32bit;
} (appendPatches [
doCheck = false;
}) (appendPatches [
(pkgs.fetchpatch {
name = "aeson-quickcheck-2.14.3-double-workaround.patch";
url = "https://github.com/haskell/aeson/commit/58766a1916b4980792763bab74f0c86e2a7ebf20.patch";
@ -1320,9 +1320,10 @@ self: super: {
# Requires pg_ctl command during tests
beam-postgres = overrideCabal (drv: {
# https://github.com/NixOS/nixpkgs/issues/198495
doCheck = pkgs.postgresql.doCheck;
testToolDepends = (drv.testToolDepends or []) ++ [pkgs.postgresql];
} // lib.optionalAttrs (!pkgs.postgresql.doCheck) {
# https://github.com/NixOS/nixpkgs/issues/198495
doCheck = false;
}) super.beam-postgres;
# PortMidi needs an environment variable to have ALSA find its plugins:
@ -1364,8 +1365,6 @@ self: super: {
sed -i test/PostgreSQL/Test.hs \
-e s^host=localhost^^
'';
# https://github.com/NixOS/nixpkgs/issues/198495
doCheck = pkgs.postgresql.doCheck;
# Match the test suite defaults (or hardcoded values?)
preCheck = drv.preCheck or "" + ''
PGUSER=esqutest
@ -1379,6 +1378,9 @@ self: super: {
pkgs.postgresql
pkgs.postgresqlTestHook
];
} // lib.optionalAttrs (!pkgs.postgresql.doCheck) {
# https://github.com/NixOS/nixpkgs/issues/198495
doCheck = false;
})
super.esqueleto;
@ -1482,14 +1484,11 @@ self: super: {
sed -i test/PgInit.hs \
-e s^'host=" <> host <> "'^^
'';
doCheck =
# https://github.com/commercialhaskell/stackage/issues/6884
# persistent-postgresql-2.13.5.1 needs persistent-test >= 2.13.1.3 which
# is incompatible with the stackage version of persistent, so the tests
# are disabled temporarily.
false
# https://github.com/NixOS/nixpkgs/issues/198495
&& pkgs.postgresql.doCheck;
# https://github.com/commercialhaskell/stackage/issues/6884
# persistent-postgresql-2.13.5.1 needs persistent-test >= 2.13.1.3 which
# is incompatible with the stackage version of persistent, so the tests
# are disabled temporarily.
doCheck = false;
preCheck = drv.preCheck or "" + ''
PGDATABASE=test
PGUSER=test
@ -1498,6 +1497,9 @@ self: super: {
pkgs.postgresql
pkgs.postgresqlTestHook
];
} // lib.optionalAttrs (!pkgs.postgresql.doCheck) {
# https://github.com/NixOS/nixpkgs/issues/198495
doCheck = false;
})
super.persistent-postgresql;
@ -1665,12 +1667,13 @@ self: super: {
testToolDepends = drv.testToolDepends or [] ++ [
pkgs.postgresql pkgs.postgresqlTestHook
];
# https://github.com/NixOS/nixpkgs/issues/198495
doCheck = pkgs.postgresql.doCheck;
preCheck = drv.preCheck or "" + ''
# empty string means use default connection
export DATABASE_URL=""
'';
} // lib.optionalAttrs (!pkgs.postgresql.doCheck) {
# https://github.com/NixOS/nixpkgs/issues/198495
doCheck = false;
}) (super.pg-client.override {
resource-pool = self.hasura-resource-pool;
ekg-core = self.hasura-ekg-core;
@ -2133,9 +2136,9 @@ self: super: {
# Tests need to lookup target triple x86_64-unknown-linux
# https://github.com/llvm-hs/llvm-hs/issues/334
llvm-hs = overrideCabal {
doCheck = pkgs.stdenv.targetPlatform.system == "x86_64-linux";
} super.llvm-hs;
llvm-hs = overrideCabal (lib.optionalAttrs (pkgs.stdenv.targetPlatform.system != "x86_64-linux") {
doCheck = false;
}) super.llvm-hs;
# Fix build with bytestring >= 0.11 (GHC 9.2)
# https://github.com/llvm-hs/llvm-hs/pull/389

View File

@ -1103,7 +1103,7 @@ self: super: builtins.intersectAttrs super {
rel8 = pkgs.lib.pipe super.rel8 [
(addTestToolDepend pkgs.postgresql)
# https://github.com/NixOS/nixpkgs/issues/198495
(overrideCabal { doCheck = pkgs.postgresql.doCheck; })
(overrideCabal (lib.optionalAttrs (!pkgs.postgresql.doCheck) { doCheck = false; }))
];
# Wants running postgresql database accessible over ip, so postgresqlTestHook
@ -1178,10 +1178,9 @@ self: super: builtins.intersectAttrs super {
# Some hash implementations are x86 only, but part of the test suite.
# So executing and building it on non-x86 platforms will always fail.
hashes = overrideCabal {
doCheck = with pkgs.stdenv; hostPlatform == buildPlatform
&& buildPlatform.isx86;
} super.hashes;
hashes = overrideCabal (lib.optionalAttrs (!pkgs.stdenv.hostPlatform.isx86) {
doCheck = false;
}) super.hashes;
# Tries to access network
aws-sns-verify = dontCheck super.aws-sns-verify;