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