ctestCheckHook: init, {pdal,gifticlib,zynaddsubfx}: migrate to ctestCheckHook (#379426)

authored by

Sandro and committed by
GitHub
99dd92d7 97562fc7

+106 -33
+18
doc/hooks/cmake.section.md
··· 33 33 #### `dontUseCmakeConfigure` {#dont-use-cmake-configure} 34 34 35 35 When set to true, don't use the predefined `cmakeConfigurePhase`. 36 + 37 + ## Controlling CTest invocation {#cmake-ctest} 38 + 39 + By default tests are run by make in [`checkPhase`](#ssec-check-phase) or by [ninja](#ninja) if `ninja` is 40 + available in `nativeBuildInputs`. Makefile and Ninja generators produce the `test` target, which invokes `ctest` under the hood. 41 + This makes passing additional arguments to `ctest` difficult, so it's possible to invoke it directly in `checkPhase` 42 + by adding `ctestCheckHook` to `nativeCheckInputs`. 43 + 44 + ### CTest Variables {#cmake-ctest-variables} 45 + 46 + #### `disabledTests` {#cmake-ctest-disabled-tests} 47 + 48 + Allows to disable running a list of tests. Note that regular expressions are not supported by `disabledTests`, but 49 + it can be combined with `--exclude-regex` option. 50 + 51 + #### `ctestFlags` {#cmake-ctest-flags} 52 + 53 + Additional options passed to `ctest` together with `checkFlags`.
+12
doc/redirects.json
··· 5 5 "chap-release-notes": [ 6 6 "release-notes.html#chap-release-notes" 7 7 ], 8 + "cmake-ctest": [ 9 + "index.html#cmake-ctest" 10 + ], 11 + "cmake-ctest-disabled-tests": [ 12 + "index.html#cmake-ctest-disabled-tests" 13 + ], 14 + "cmake-ctest-flags": [ 15 + "index.html#cmake-ctest-flags" 16 + ], 17 + "cmake-ctest-variables": [ 18 + "index.html#cmake-ctest-variables" 19 + ], 8 20 "ex-build-helpers-extendMkDerivation": [ 9 21 "index.html#ex-build-helpers-extendMkDerivation" 10 22 ],
+12 -20
pkgs/applications/audio/zynaddsubfx/default.nix
··· 45 45 # Test dependencies 46 46 cxxtest, 47 47 ruby, 48 + ctestCheckHook, 48 49 }: 49 50 50 51 assert builtins.any (g: guiModule == g) [ ··· 151 152 nativeCheckInputs = [ 152 153 cxxtest 153 154 ruby 155 + ctestCheckHook 154 156 ]; 155 157 156 - # TODO: Update cmake hook to make it simpler to selectively disable cmake tests: #113829 157 - checkPhase = 158 - let 159 - disabledTests = 160 - # PortChecker is non-deterministic. It's fixed in the master 161 - # branch, but backporting would require an update to rtosc, so 162 - # we'll just disable it until the next release. 163 - [ "PortChecker" ] 164 - 165 - # Tests fail on aarch64 166 - ++ lib.optionals stdenv.hostPlatform.isAarch64 [ 167 - "MessageTest" 168 - "UnisonTest" 169 - ]; 170 - in 171 - '' 172 - runHook preCheck 173 - ctest --output-on-failure -E '^${lib.concatStringsSep "|" disabledTests}$' 174 - runHook postCheck 175 - ''; 158 + disabledTests = 159 + # PortChecker is non-deterministic. It's fixed in the master 160 + # branch, but backporting would require an update to rtosc, so 161 + # we'll just disable it until the next release. 162 + [ "PortChecker" ] 163 + # Tests fail on aarch64 164 + ++ lib.optionals stdenv.hostPlatform.isAarch64 [ 165 + "MessageTest" 166 + "UnisonTest" 167 + ]; 176 168 177 169 # Use Zyn-Fusion logo for zest build 178 170 # An SVG version of the logo isn't hosted anywhere we can fetch, I
+44
pkgs/by-name/ct/ctestCheckHook/ctest-check-hook.sh
··· 1 + # shellcheck shell=bash disable=SC2154 2 + 3 + ctestCheckHook() { 4 + echo "Executing ctestCheckHook" 5 + 6 + runHook preCheck 7 + 8 + local buildCores=1 9 + 10 + if [ "${enableParallelChecking-1}" ]; then 11 + buildCores="$NIX_BUILD_CORES" 12 + fi 13 + 14 + local flagsArray=( 15 + "-j$buildCores" 16 + # This is enabled by the cmakeConfigurePhase by exporting 17 + # CTEST_OUTPUT_ON_FAILURE, but it makes sense it enable it globally here 18 + # as well. 19 + "--output-on-failure" 20 + ) 21 + 22 + local disabledTestsArray=() 23 + concatTo disabledTestsArray disabledTests 24 + 25 + if [ ${#disabledTestsArray[@]} -ne 0 ]; then 26 + local ctestExcludedTestsFile=$NIX_BUILD_TOP/.ctest-excluded-tests 27 + disabledTestsString="$(concatStringsSep "\n" disabledTestsArray)" 28 + echo -e "$disabledTestsString" >"$ctestExcludedTestsFile" 29 + flagsArray+=("--exclude-from-file" "$ctestExcludedTestsFile") 30 + fi 31 + 32 + concatTo flagsArray ctestFlags checkFlags checkFlagsArray 33 + 34 + echoCmd 'ctest flags' "${flagsArray[@]}" 35 + ctest "${flagsArray[@]}" 36 + 37 + echo "Finished ctestCheckHook" 38 + 39 + runHook postCheck 40 + } 41 + 42 + if [ -z "${dontUseCTestCheck-}" ] && [ -z "${checkPhase-}" ]; then 43 + checkPhase=ctestCheckHook 44 + fi
+9
pkgs/by-name/ct/ctestCheckHook/package.nix
··· 1 + { 2 + makeSetupHook, 3 + cmake, 4 + }: 5 + 6 + makeSetupHook { 7 + name = "ctestCheckHook"; 8 + propagatedBuildInputs = [ cmake ]; 9 + } ./ctest-check-hook.sh
+6 -5
pkgs/by-name/gi/gifticlib/package.nix
··· 6 6 expat, 7 7 nifticlib, 8 8 zlib, 9 + ctestCheckHook, 9 10 }: 10 11 11 12 stdenv.mkDerivation { ··· 33 34 34 35 # without the test data, this is only a few basic tests 35 36 doCheck = !stdenv.hostPlatform.isDarwin; 36 - checkPhase = '' 37 - runHook preCheck 38 - ctest -LE 'NEEDS_DATA' 39 - runHook postCheck 40 - ''; 37 + nativeCheckInputs = [ ctestCheckHook ]; 38 + checkFlags = [ 39 + "-LE" 40 + "NEEDS_DATA" 41 + ]; 41 42 42 43 meta = with lib; { 43 44 homepage = "https://www.nitrc.org/projects/gifti";
+5 -8
pkgs/by-name/pd/pdal/package.nix
··· 2 2 lib, 3 3 stdenv, 4 4 callPackage, 5 + ctestCheckHook, 5 6 fetchFromGitHub, 6 7 testers, 7 8 ··· 92 93 ]; 93 94 94 95 doCheck = true; 96 + # tests are flaky and they seem to fail less often when they don't run in 97 + # parallel 98 + enableParallelChecking = false; 95 99 96 100 disabledTests = [ 97 101 # Tests failing due to TileDB library implementation, disabled also ··· 116 120 117 121 nativeCheckInputs = [ 118 122 gdal # gdalinfo 123 + ctestCheckHook 119 124 ]; 120 - 121 - checkPhase = '' 122 - runHook preCheck 123 - # tests are flaky and they seem to fail less often when they don't run in 124 - # parallel 125 - ctest -j 1 --output-on-failure -E '^${lib.concatStringsSep "|" finalAttrs.disabledTests}$' 126 - runHook postCheck 127 - ''; 128 125 129 126 postInstall = '' 130 127 patchShebangs --update --build $out/bin/pdal-config