mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
ctestCheckHook: init, {pdal,gifticlib,zynaddsubfx}: migrate to ctestCheckHook (#379426)
This commit is contained in:
commit
99dd92d76f
7 changed files with 106 additions and 33 deletions
|
@ -33,3 +33,21 @@ The default value is `build`.
|
||||||
#### `dontUseCmakeConfigure` {#dont-use-cmake-configure}
|
#### `dontUseCmakeConfigure` {#dont-use-cmake-configure}
|
||||||
|
|
||||||
When set to true, don't use the predefined `cmakeConfigurePhase`.
|
When set to true, don't use the predefined `cmakeConfigurePhase`.
|
||||||
|
|
||||||
|
## Controlling CTest invocation {#cmake-ctest}
|
||||||
|
|
||||||
|
By default tests are run by make in [`checkPhase`](#ssec-check-phase) or by [ninja](#ninja) if `ninja` is
|
||||||
|
available in `nativeBuildInputs`. Makefile and Ninja generators produce the `test` target, which invokes `ctest` under the hood.
|
||||||
|
This makes passing additional arguments to `ctest` difficult, so it's possible to invoke it directly in `checkPhase`
|
||||||
|
by adding `ctestCheckHook` to `nativeCheckInputs`.
|
||||||
|
|
||||||
|
### CTest Variables {#cmake-ctest-variables}
|
||||||
|
|
||||||
|
#### `disabledTests` {#cmake-ctest-disabled-tests}
|
||||||
|
|
||||||
|
Allows to disable running a list of tests. Note that regular expressions are not supported by `disabledTests`, but
|
||||||
|
it can be combined with `--exclude-regex` option.
|
||||||
|
|
||||||
|
#### `ctestFlags` {#cmake-ctest-flags}
|
||||||
|
|
||||||
|
Additional options passed to `ctest` together with `checkFlags`.
|
||||||
|
|
|
@ -5,6 +5,18 @@
|
||||||
"chap-release-notes": [
|
"chap-release-notes": [
|
||||||
"release-notes.html#chap-release-notes"
|
"release-notes.html#chap-release-notes"
|
||||||
],
|
],
|
||||||
|
"cmake-ctest": [
|
||||||
|
"index.html#cmake-ctest"
|
||||||
|
],
|
||||||
|
"cmake-ctest-disabled-tests": [
|
||||||
|
"index.html#cmake-ctest-disabled-tests"
|
||||||
|
],
|
||||||
|
"cmake-ctest-flags": [
|
||||||
|
"index.html#cmake-ctest-flags"
|
||||||
|
],
|
||||||
|
"cmake-ctest-variables": [
|
||||||
|
"index.html#cmake-ctest-variables"
|
||||||
|
],
|
||||||
"ex-build-helpers-extendMkDerivation": [
|
"ex-build-helpers-extendMkDerivation": [
|
||||||
"index.html#ex-build-helpers-extendMkDerivation"
|
"index.html#ex-build-helpers-extendMkDerivation"
|
||||||
],
|
],
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
# Test dependencies
|
# Test dependencies
|
||||||
cxxtest,
|
cxxtest,
|
||||||
ruby,
|
ruby,
|
||||||
|
ctestCheckHook,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert builtins.any (g: guiModule == g) [
|
assert builtins.any (g: guiModule == g) [
|
||||||
|
@ -151,28 +152,19 @@ stdenv.mkDerivation rec {
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [
|
||||||
cxxtest
|
cxxtest
|
||||||
ruby
|
ruby
|
||||||
|
ctestCheckHook
|
||||||
];
|
];
|
||||||
|
|
||||||
# TODO: Update cmake hook to make it simpler to selectively disable cmake tests: #113829
|
|
||||||
checkPhase =
|
|
||||||
let
|
|
||||||
disabledTests =
|
disabledTests =
|
||||||
# PortChecker is non-deterministic. It's fixed in the master
|
# PortChecker is non-deterministic. It's fixed in the master
|
||||||
# branch, but backporting would require an update to rtosc, so
|
# branch, but backporting would require an update to rtosc, so
|
||||||
# we'll just disable it until the next release.
|
# we'll just disable it until the next release.
|
||||||
[ "PortChecker" ]
|
[ "PortChecker" ]
|
||||||
|
|
||||||
# Tests fail on aarch64
|
# Tests fail on aarch64
|
||||||
++ lib.optionals stdenv.hostPlatform.isAarch64 [
|
++ lib.optionals stdenv.hostPlatform.isAarch64 [
|
||||||
"MessageTest"
|
"MessageTest"
|
||||||
"UnisonTest"
|
"UnisonTest"
|
||||||
];
|
];
|
||||||
in
|
|
||||||
''
|
|
||||||
runHook preCheck
|
|
||||||
ctest --output-on-failure -E '^${lib.concatStringsSep "|" disabledTests}$'
|
|
||||||
runHook postCheck
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Use Zyn-Fusion logo for zest build
|
# Use Zyn-Fusion logo for zest build
|
||||||
# An SVG version of the logo isn't hosted anywhere we can fetch, I
|
# An SVG version of the logo isn't hosted anywhere we can fetch, I
|
||||||
|
|
44
pkgs/by-name/ct/ctestCheckHook/ctest-check-hook.sh
Normal file
44
pkgs/by-name/ct/ctestCheckHook/ctest-check-hook.sh
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# shellcheck shell=bash disable=SC2154
|
||||||
|
|
||||||
|
ctestCheckHook() {
|
||||||
|
echo "Executing ctestCheckHook"
|
||||||
|
|
||||||
|
runHook preCheck
|
||||||
|
|
||||||
|
local buildCores=1
|
||||||
|
|
||||||
|
if [ "${enableParallelChecking-1}" ]; then
|
||||||
|
buildCores="$NIX_BUILD_CORES"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local flagsArray=(
|
||||||
|
"-j$buildCores"
|
||||||
|
# This is enabled by the cmakeConfigurePhase by exporting
|
||||||
|
# CTEST_OUTPUT_ON_FAILURE, but it makes sense it enable it globally here
|
||||||
|
# as well.
|
||||||
|
"--output-on-failure"
|
||||||
|
)
|
||||||
|
|
||||||
|
local disabledTestsArray=()
|
||||||
|
concatTo disabledTestsArray disabledTests
|
||||||
|
|
||||||
|
if [ ${#disabledTestsArray[@]} -ne 0 ]; then
|
||||||
|
local ctestExcludedTestsFile=$NIX_BUILD_TOP/.ctest-excluded-tests
|
||||||
|
disabledTestsString="$(concatStringsSep "\n" disabledTestsArray)"
|
||||||
|
echo -e "$disabledTestsString" >"$ctestExcludedTestsFile"
|
||||||
|
flagsArray+=("--exclude-from-file" "$ctestExcludedTestsFile")
|
||||||
|
fi
|
||||||
|
|
||||||
|
concatTo flagsArray ctestFlags checkFlags checkFlagsArray
|
||||||
|
|
||||||
|
echoCmd 'ctest flags' "${flagsArray[@]}"
|
||||||
|
ctest "${flagsArray[@]}"
|
||||||
|
|
||||||
|
echo "Finished ctestCheckHook"
|
||||||
|
|
||||||
|
runHook postCheck
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -z "${dontUseCTestCheck-}" ] && [ -z "${checkPhase-}" ]; then
|
||||||
|
checkPhase=ctestCheckHook
|
||||||
|
fi
|
9
pkgs/by-name/ct/ctestCheckHook/package.nix
Normal file
9
pkgs/by-name/ct/ctestCheckHook/package.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
makeSetupHook,
|
||||||
|
cmake,
|
||||||
|
}:
|
||||||
|
|
||||||
|
makeSetupHook {
|
||||||
|
name = "ctestCheckHook";
|
||||||
|
propagatedBuildInputs = [ cmake ];
|
||||||
|
} ./ctest-check-hook.sh
|
|
@ -6,6 +6,7 @@
|
||||||
expat,
|
expat,
|
||||||
nifticlib,
|
nifticlib,
|
||||||
zlib,
|
zlib,
|
||||||
|
ctestCheckHook,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
@ -33,11 +34,11 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
# without the test data, this is only a few basic tests
|
# without the test data, this is only a few basic tests
|
||||||
doCheck = !stdenv.hostPlatform.isDarwin;
|
doCheck = !stdenv.hostPlatform.isDarwin;
|
||||||
checkPhase = ''
|
nativeCheckInputs = [ ctestCheckHook ];
|
||||||
runHook preCheck
|
checkFlags = [
|
||||||
ctest -LE 'NEEDS_DATA'
|
"-LE"
|
||||||
runHook postCheck
|
"NEEDS_DATA"
|
||||||
'';
|
];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "https://www.nitrc.org/projects/gifti";
|
homepage = "https://www.nitrc.org/projects/gifti";
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
callPackage,
|
callPackage,
|
||||||
|
ctestCheckHook,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
testers,
|
testers,
|
||||||
|
|
||||||
|
@ -92,6 +93,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
];
|
];
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
# tests are flaky and they seem to fail less often when they don't run in
|
||||||
|
# parallel
|
||||||
|
enableParallelChecking = false;
|
||||||
|
|
||||||
disabledTests = [
|
disabledTests = [
|
||||||
# Tests failing due to TileDB library implementation, disabled also
|
# Tests failing due to TileDB library implementation, disabled also
|
||||||
|
@ -116,16 +120,9 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
nativeCheckInputs = [
|
nativeCheckInputs = [
|
||||||
gdal # gdalinfo
|
gdal # gdalinfo
|
||||||
|
ctestCheckHook
|
||||||
];
|
];
|
||||||
|
|
||||||
checkPhase = ''
|
|
||||||
runHook preCheck
|
|
||||||
# tests are flaky and they seem to fail less often when they don't run in
|
|
||||||
# parallel
|
|
||||||
ctest -j 1 --output-on-failure -E '^${lib.concatStringsSep "|" finalAttrs.disabledTests}$'
|
|
||||||
runHook postCheck
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
patchShebangs --update --build $out/bin/pdal-config
|
patchShebangs --update --build $out/bin/pdal-config
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue