diff --git a/pkgs/applications/audio/cozy-audiobooks/default.nix b/pkgs/applications/audio/cozy-audiobooks/default.nix index f0a7280b038..1b996f9f0c5 100644 --- a/pkgs/applications/audio/cozy-audiobooks/default.nix +++ b/pkgs/applications/audio/cozy-audiobooks/default.nix @@ -66,10 +66,6 @@ python3Packages.buildPythonApplication rec { substituteInPlace cozy/magic/magic.py --replace "ctypes.util.find_library('magic')" "'${file}/lib/libmagic${stdenv.hostPlatform.extensions.sharedLibrary}'" ''; - checkPhase = '' - ninja test - ''; - postInstall = '' ln -s $out/bin/com.github.geigi.cozy $out/bin/cozy ''; diff --git a/pkgs/applications/audio/radiotray-ng/default.nix b/pkgs/applications/audio/radiotray-ng/default.nix index 6f7ce9048c4..900c2bf7a41 100644 --- a/pkgs/applications/audio/radiotray-ng/default.nix +++ b/pkgs/applications/audio/radiotray-ng/default.nix @@ -80,7 +80,6 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; checkInputs = [ gtest ]; - checkPhase = "ctest"; # doCheck = stdenv.hostPlatform == stdenv.buildPlatform; doCheck = false; # fails to pick up supplied gtest, tries to download it instead diff --git a/pkgs/applications/networking/instant-messengers/utox/default.nix b/pkgs/applications/networking/instant-messengers/utox/default.nix index 531ca5cbadc..3c5e65ffe77 100644 --- a/pkgs/applications/networking/instant-messengers/utox/default.nix +++ b/pkgs/applications/networking/instant-messengers/utox/default.nix @@ -32,11 +32,6 @@ stdenv.mkDerivation rec { doCheck = stdenv.hostPlatform == stdenv.buildPlatform; checkInputs = [ check ]; - checkPhase = '' - runHook preCheck - ctest -VV - runHook postCheck - ''; meta = with stdenv.lib; { description = "Lightweight Tox client"; diff --git a/pkgs/applications/office/kmymoney/default.nix b/pkgs/applications/office/kmymoney/default.nix index 7899bf607e5..7061a632394 100644 --- a/pkgs/applications/office/kmymoney/default.nix +++ b/pkgs/applications/office/kmymoney/default.nix @@ -64,7 +64,7 @@ stdenv.mkDerivation rec { installCheckPhase = let pluginPath = "${qtbase.bin}/${qtbase.qtPluginPrefix}"; in lib.optionalString doInstallCheck '' - QT_PLUGIN_PATH=${lib.escapeShellArg pluginPath} CTEST_OUTPUT_ON_FAILURE=1 \ + QT_PLUGIN_PATH=${lib.escapeShellArg pluginPath} \ ${xvfb_run}/bin/xvfb-run -s '-screen 0 1024x768x24' make test \ ARGS="-E '(reports-chart-test)'" # Test fails, so exclude it for now. ''; diff --git a/pkgs/applications/science/biology/EZminc/default.nix b/pkgs/applications/science/biology/EZminc/default.nix index 20d88eb3aaf..dbcfead6b1e 100644 --- a/pkgs/applications/science/biology/EZminc/default.nix +++ b/pkgs/applications/science/biology/EZminc/default.nix @@ -18,8 +18,6 @@ stdenv.mkDerivation rec { pname = "EZminc"; "-DEZMINC_BUILD_MRFSEG=TRUE" "-DEZMINC_BUILD_DD=TRUE" ]; - checkPhase = "ctest --output-on-failure ../tests/"; # but ctest doesn't find the tests ... - enableParallelBuilding = true; meta = with stdenv.lib; { diff --git a/pkgs/applications/science/biology/N3/default.nix b/pkgs/applications/science/biology/N3/default.nix index c14846beec2..3502ac3e51b 100644 --- a/pkgs/applications/science/biology/N3/default.nix +++ b/pkgs/applications/science/biology/N3/default.nix @@ -19,9 +19,6 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" "-DEBTKS_DIR=${EBTKS}/lib/" ]; - checkPhase = "ctest --output-on-failure"; - # don't run the tests as they fail at least due to missing program wrappers in this phase ... - postFixup = '' for p in $out/bin/*; do wrapProgram $p --prefix PERL5LIB : $PERL5LIB diff --git a/pkgs/applications/science/biology/ants/default.nix b/pkgs/applications/science/biology/ants/default.nix index 0b8ddd0d4fb..f54bd9af028 100644 --- a/pkgs/applications/science/biology/ants/default.nix +++ b/pkgs/applications/science/biology/ants/default.nix @@ -21,8 +21,6 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - checkPhase = "ctest"; - postInstall = '' for file in $out/bin/*; do wrapProgram $file --set ANTSPATH "$out/bin" diff --git a/pkgs/applications/science/biology/inormalize/default.nix b/pkgs/applications/science/biology/inormalize/default.nix index f17143ad06b..7ba054a592e 100644 --- a/pkgs/applications/science/biology/inormalize/default.nix +++ b/pkgs/applications/science/biology/inormalize/default.nix @@ -21,8 +21,6 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" "-DEBTKS_DIR=${EBTKS}/lib/" ]; - checkPhase = "ctest --output-on-failure"; # but no tests - postFixup = '' for p in $out/bin/*; do wrapProgram $p --prefix PERL5LIB : $PERL5LIB diff --git a/pkgs/applications/science/biology/minc-tools/default.nix b/pkgs/applications/science/biology/minc-tools/default.nix index 8e1f74686d1..c680eda95d2 100644 --- a/pkgs/applications/science/biology/minc-tools/default.nix +++ b/pkgs/applications/science/biology/minc-tools/default.nix @@ -17,8 +17,6 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" ]; - checkPhase = "ctest --output-on-failure"; # still some weird test failures though - postFixup = '' for prog in minccomplete minchistory mincpik; do wrapProgram $out/bin/$prog --prefix PERL5LIB : $PERL5LIB diff --git a/pkgs/desktops/gnome-3/apps/evolution/default.nix b/pkgs/desktops/gnome-3/apps/evolution/default.nix index 8fb8c230784..89a16b02893 100644 --- a/pkgs/desktops/gnome-3/apps/evolution/default.nix +++ b/pkgs/desktops/gnome-3/apps/evolution/default.nix @@ -38,8 +38,6 @@ in stdenv.mkDerivation rec { doCheck = true; - checkPhase = "ctest"; - passthru = { updateScript = gnome3.updateScript { packageName = "evolution"; diff --git a/pkgs/development/libraries/arguments/default.nix b/pkgs/development/libraries/arguments/default.nix index 60fafd60ad0..ebef604e1be 100644 --- a/pkgs/development/libraries/arguments/default.nix +++ b/pkgs/development/libraries/arguments/default.nix @@ -18,7 +18,6 @@ stdenv.mkDerivation rec { #cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib" "-DBICPL_DIR=${bicpl}/lib" "-DBUILD_TESTING=FALSE" ]; - checkPhase = "ctest --output-on-failure"; doCheck = false; # internal_volume_io.h: No such file or directory diff --git a/pkgs/development/libraries/cmark/default.nix b/pkgs/development/libraries/cmark/default.nix index fce02dac950..a7b604bc0d2 100644 --- a/pkgs/development/libraries/cmark/default.nix +++ b/pkgs/development/libraries/cmark/default.nix @@ -13,9 +13,8 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; doCheck = !stdenv.isDarwin; - checkPhase = '' + preCheck = '' export LD_LIBRARY_PATH=$(readlink -f ./src) - CTEST_OUTPUT_ON_FAILURE=1 make test ''; meta = with stdenv.lib; { diff --git a/pkgs/development/libraries/libcouchbase/default.nix b/pkgs/development/libraries/libcouchbase/default.nix index 516702e2afe..2db78f82292 100644 --- a/pkgs/development/libraries/libcouchbase/default.nix +++ b/pkgs/development/libraries/libcouchbase/default.nix @@ -17,7 +17,6 @@ stdenv.mkDerivation rec { buildInputs = [ libevent openssl ]; doCheck = !stdenv.isDarwin; - checkPhase = "ctest"; meta = with stdenv.lib; { description = "C client library for Couchbase"; diff --git a/pkgs/development/libraries/libtoxcore/default.nix b/pkgs/development/libraries/libtoxcore/default.nix index 4a8dfc40d4a..026674e44fc 100644 --- a/pkgs/development/libraries/libtoxcore/default.nix +++ b/pkgs/development/libraries/libtoxcore/default.nix @@ -31,7 +31,6 @@ let doCheck = false; # hangs, tries to access the net? checkInputs = [ check ]; - checkPhase = "ctest"; meta = with stdenv.lib; { description = "P2P FOSS instant messaging application aimed to replace Skype"; diff --git a/pkgs/development/libraries/pagmo2/default.nix b/pkgs/development/libraries/pagmo2/default.nix index 367cef46dc4..c680efa95f8 100644 --- a/pkgs/development/libraries/pagmo2/default.nix +++ b/pkgs/development/libraries/pagmo2/default.nix @@ -31,10 +31,6 @@ stdenv.mkDerivation rec { "-DNLOPT_LIBRARY=${nlopt}/lib/libnlopt_cxx.so" "-DPAGMO_WITH_IPOPT=yes" "-DCMAKE_CXX_FLAGS='-fuse-ld=gold'" ]; - checkPhase = '' - ctest - ''; - # All but one test pass skip for now (tests also take about 30 min to compile) doCheck = false; diff --git a/pkgs/development/libraries/science/biology/EBTKS/default.nix b/pkgs/development/libraries/science/biology/EBTKS/default.nix index 67f868a91a7..f4353f51d66 100644 --- a/pkgs/development/libraries/science/biology/EBTKS/default.nix +++ b/pkgs/development/libraries/science/biology/EBTKS/default.nix @@ -16,8 +16,6 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/" ]; - checkPhase = "ctest --output-on-failure"; # but cmake doesn't run the tests ... - meta = with stdenv.lib; { homepage = "https://github.com/BIC-MNI/${pname}"; description = "Library for working with MINC files"; diff --git a/pkgs/development/libraries/science/biology/bicpl/default.nix b/pkgs/development/libraries/science/biology/bicpl/default.nix index d00a74f61e2..f763e8a4fcc 100644 --- a/pkgs/development/libraries/science/biology/bicpl/default.nix +++ b/pkgs/development/libraries/science/biology/bicpl/default.nix @@ -19,7 +19,6 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib" "-DBUILD_TESTING=FALSE" ]; - checkPhase = "ctest --output-on-failure"; doCheck = false; # internal_volume_io.h: No such file or directory diff --git a/pkgs/development/libraries/science/biology/elastix/default.nix b/pkgs/development/libraries/science/biology/elastix/default.nix index 7b9e6b24d41..5f4cbbaa567 100644 --- a/pkgs/development/libraries/science/biology/elastix/default.nix +++ b/pkgs/development/libraries/science/biology/elastix/default.nix @@ -13,8 +13,6 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake python ]; buildInputs = [ itk ]; - checkPhase = "ctest"; - meta = with stdenv.lib; { homepage = http://elastix.isi.uu.nl/; description = "Image registration toolkit based on ITK"; diff --git a/pkgs/development/libraries/science/biology/nifticlib/default.nix b/pkgs/development/libraries/science/biology/nifticlib/default.nix index 19e5644b993..51eed36312d 100644 --- a/pkgs/development/libraries/science/biology/nifticlib/default.nix +++ b/pkgs/development/libraries/science/biology/nifticlib/default.nix @@ -13,7 +13,6 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; buildInputs = [ zlib ]; - checkPhase = "ctest"; doCheck = false; # fails 7 out of 293 tests meta = with stdenv.lib; { diff --git a/pkgs/development/libraries/science/math/liblapack/default.nix b/pkgs/development/libraries/science/math/liblapack/default.nix index 38260f63d91..c26e9c575ab 100644 --- a/pkgs/development/libraries/science/math/liblapack/default.nix +++ b/pkgs/development/libraries/science/math/liblapack/default.nix @@ -30,10 +30,6 @@ stdenv.mkDerivation rec { doCheck = ! shared; - checkPhase = " - ctest - "; - enableParallelBuilding = true; meta = with stdenv.lib; { diff --git a/pkgs/development/libraries/science/math/scalapack/default.nix b/pkgs/development/libraries/science/math/scalapack/default.nix index c5930fdb684..3f37bf49de3 100644 --- a/pkgs/development/libraries/science/math/scalapack/default.nix +++ b/pkgs/development/libraries/science/math/scalapack/default.nix @@ -27,7 +27,7 @@ stdenv.mkDerivation rec { ) ''; - checkPhase = '' + preCheck = '' # make sure the test starts even if we have less than 4 cores export OMPI_MCA_rmaps_base_oversubscribe=1 @@ -35,9 +35,6 @@ stdenv.mkDerivation rec { export OMP_NUM_THREADS=1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib - export CTEST_OUTPUT_ON_FAILURE=1 - - make test ''; meta = with stdenv.lib; { diff --git a/pkgs/development/libraries/simpleitk/default.nix b/pkgs/development/libraries/simpleitk/default.nix index c807325b155..1c17124a2bb 100644 --- a/pkgs/development/libraries/simpleitk/default.nix +++ b/pkgs/development/libraries/simpleitk/default.nix @@ -15,8 +15,6 @@ stdenv.mkDerivation rec { cmakeFlags = [ "-DBUILD_SHARED_LIBS=ON" "-DCMAKE_CXX_FLAGS='-Wno-attributes'" ]; - checkPhase = "ctest"; - enableParallelBuilding = true; meta = with stdenv.lib; { diff --git a/pkgs/development/python-modules/pythonix/default.nix b/pkgs/development/python-modules/pythonix/default.nix index fd8012a24d3..f7cecae8497 100644 --- a/pkgs/development/python-modules/pythonix/default.nix +++ b/pkgs/development/python-modules/pythonix/default.nix @@ -18,10 +18,6 @@ buildPythonPackage rec { buildInputs = [ nix boost ]; - checkPhase = '' - ninja test - ''; - meta = with stdenv.lib; { description = '' Eval nix code from python. diff --git a/pkgs/development/tools/build-managers/cmake/setup-hook.sh b/pkgs/development/tools/build-managers/cmake/setup-hook.sh index d37e25943b5..f095103ee04 100755 --- a/pkgs/development/tools/build-managers/cmake/setup-hook.sh +++ b/pkgs/development/tools/build-managers/cmake/setup-hook.sh @@ -15,6 +15,11 @@ fixCmakeFiles() { cmakeConfigurePhase() { runHook preConfigure + export CTEST_OUTPUT_ON_FAILURE=1 + if [ -n "${enableParallelChecking-1}" ]; then + export CTEST_PARALLEL_LEVEL=$NIX_BUILD_CORES + fi + if [ -z "$dontFixCmake" ]; then fixCmakeFiles . fi diff --git a/pkgs/development/tools/build-managers/meson/setup-hook.sh b/pkgs/development/tools/build-managers/meson/setup-hook.sh index b98225c1305..06375c1528e 100644 --- a/pkgs/development/tools/build-managers/meson/setup-hook.sh +++ b/pkgs/development/tools/build-managers/meson/setup-hook.sh @@ -39,15 +39,3 @@ if [ -z "$dontUseMesonConfigure" -a -z "$configurePhase" ]; then setOutputFlags= configurePhase=mesonConfigurePhase fi - -mesonCheckPhase() { - runHook preCheck - - meson test --print-errorlogs - - runHook postCheck -} - -if [ -z "$dontUseMesonCheck" -a -z "$checkPhase" ]; then - checkPhase=mesonCheckPhase -fi diff --git a/pkgs/development/tools/build-managers/ninja/setup-hook.sh b/pkgs/development/tools/build-managers/ninja/setup-hook.sh index d9ad7460931..e3c67bd139d 100644 --- a/pkgs/development/tools/build-managers/ninja/setup-hook.sh +++ b/pkgs/development/tools/build-managers/ninja/setup-hook.sh @@ -1,27 +1,21 @@ ninjaBuildPhase() { runHook preBuild - if [[ -z "$ninjaFlags" && ! ( -e build.ninja ) ]]; then - echo "no build.ninja, doing nothing" - else - local buildCores=1 + local buildCores=1 - # Parallel building is enabled by default. - if [ "${enableParallelBuilding-1}" ]; then - buildCores="$NIX_BUILD_CORES" - fi - - # shellcheck disable=SC2086 - local flagsArray=( \ - -j"$buildCores" -l"$NIX_BUILD_CORES" \ - $ninjaFlags "${ninjaFlagsArray[@]}" \ - $buildFlags "${buildFlagsArray[@]}") - - echoCmd 'build flags' "${flagsArray[@]}" - ninja "${flagsArray[@]}" - unset flagsArray + # Parallel building is enabled by default. + if [ "${enableParallelBuilding-1}" ]; then + buildCores="$NIX_BUILD_CORES" fi + local flagsArray=( + -j$buildCores -l$NIX_BUILD_CORES + $ninjaFlags "${ninjaFlagsArray[@]}" + ) + + echoCmd 'build flags' "${flagsArray[@]}" + ninja "${flagsArray[@]}" + runHook postBuild } @@ -32,15 +26,14 @@ fi ninjaInstallPhase() { runHook preInstall - installTargets="${installTargets:-install}" - # shellcheck disable=SC2086 - local flagsArray=( $installTargets \ - $ninjaFlags "${ninjaFlagsArray[@]}") + local flagsArray=( + $ninjaFlags "${ninjaFlagsArray[@]}" + ${installTargets:-install} + ) echoCmd 'install flags' "${flagsArray[@]}" ninja "${flagsArray[@]}" - unset flagsArray runHook postInstall } @@ -48,3 +41,38 @@ ninjaInstallPhase() { if [ -z "$dontUseNinjaInstall" -a -z "$installPhase" ]; then installPhase=ninjaInstallPhase fi + +ninjaCheckPhase() { + runHook preCheck + + if [ -z "${checkTarget:-}" ]; then + if ninja -t query test >/dev/null 2>&1; then + checkTarget=test + fi + fi + + if [ -z "${checkTarget:-}" ]; then + echo "no test target found in ninja, doing nothing" + else + local buildCores=1 + + if [ "${enableParallelChecking-1}" ]; then + buildCores="$NIX_BUILD_CORES" + fi + + local flagsArray=( + -j$buildCores -l$NIX_BUILD_CORES + $ninjaFlags "${ninjaFlagsArray[@]}" + $checkTarget + ) + + echoCmd 'check flags' "${flagsArray[@]}" + ninja "${flagsArray[@]}" + fi + + runHook postCheck +} + +if [ -z "$dontUseNinjaCheck" -a -z "$checkPhase" ]; then + checkPhase=ninjaCheckPhase +fi