Testing and continuous integration
ITK validates toolkit behavior, language bindings, source quality, and supported build choices through one test system. CMake registers module tests with CTest, external data supplies stable inputs and expected outputs, and GitHub Actions and Azure Pipelines run focused checks across platforms and build variants. The scope connects to module build and distribution, Python wrapping, and the filtering framework.
Test system
The test system turns module checks into a build-wide validation set. A test can check a return value, compare a generated file with a baseline, or verify that several modules work together.
Test registration and execution
CTest is the test runner used after CMake configures and builds ITK. Module test directories add driver-based tests and GoogleTest suites to the same CTest model. They also attach data, output cleanup, labels, environment choices, and build conditions to each test. The test execution page describes the commands and filters for local runs.
The test set combines broad legacy coverage with focused GoogleTest checks. Recent checks strengthen compile-time contracts for concepts, numeric traits, newer C++ clients, matrices, image iterators, and path iterators. They also cover byte order, memory probes, displacement transforms, velocity fields, B-spline image processing, registration virtual domains, and bias-field edge cases. Core and image-intensity coverage also checks image-region value behavior, pool-based work completion after errors, arithmetic functor edge cases, and weighted image addition. These checks complement existing image and baseline comparisons rather than replacing them. References: CMake/ITKModuleTest.cmake#L16-L97, CMake/ITKModuleTest.cmake#L103-L175, CMake/ITKModuleTest.cmake#L194-L268, Modules/…/CMakeLists.txt• L1533-1681, Modules/Core/Common/test/itkImageIORegionGTest.cxx#L19-L246, Modules/Core/Common/test/itkPoolMultiThreaderGTest.cxx#L19-L239, Modules/Core/Common/test/itkConceptCheckingGTest.cxx#L53-L140, Modules/Core/Common/test/itkNewerStandardClientTest.cxx#L24-L55, Modules/Core/Common/test/itkBridgeMathSVDGTest.cxx#L51-L82, Modules/Core/Common/test/itkImageIteratorsGTest.cxx#L645-L998, Modules/…/CMakeLists.txt• L114-120, Modules/Filtering/Path/test/itkPathIteratorGTest.cxx#L55-L125, Modules/…/CMakeLists.txt• L202-210, Modules/Filtering/DisplacementField/test/itkDisplacementFieldTransformTransformPointGTest.cxx#L150-L207, Modules/Filtering/DisplacementField/test/itkVelocityFieldTransformGTest.cxx#L41-L91, Modules/…/CMakeLists.txt• L740-753, Modules/Filtering/ImageGrid/test/itkBSplineControlPointImageFilterGTest.cxx#L24-L79, Modules/…/CMakeLists.txt• L772-806, Modules/Filtering/ImageIntensity/test/itkArithmeticOpsFunctorsTest.cxx#L19-L105, Modules/Filtering/ImageIntensity/test/itkWeightedAddImageFilterGTest.cxx#L19-L60, Modules/…/CMakeLists.txt• L538-543, Modules/Registration/RegistrationMethodsv4/test/itkImageRegistrationMethodv4VirtualDomainGTest.cxx#L124-L186
External test data
External test data keeps large inputs and baselines out of source history while preserving stable test references. A small content link identifies each object in content-addressed storage, where the object name comes from its content. The manifest maps each repository-relative test path to its content link. The prefetch tool scans every .cid reference and fills the shared object store through the same gateway set used by CMake. The build fetches missing objects into a local store, and tests use those objects through DATA{...} references.
The Testing/Data area separates input data from baseline results. A dedicated cache workflow restores an existing store, fetches every unique content link when needed, checks that all objects are present, and saves the store only after that check passes. Other CI jobs restore the cache and do not write it. This keeps one incomplete platform job from replacing a complete shared cache. References: Testing/…/README.md• L4-17, Testing/Data/content-links.manifest#L1-L13, CMake/ITKExternalData.cmake#L1-L35, .github/…/populate-externaldata-cache.yml• L3-12, .github/…/populate-externaldata-cache.yml• L60-108, Utilities/…/PrefetchCIDContentLinks.py• L46-61, Utilities/…/PrefetchCIDContentLinks.py• L64-128
The main Pixi and ARM workflows restore the platform-independent object store and fetch missing data before the build or test run. Some VTI tests use small deterministic fixtures generated by Modules/…/generate_vti_fixtures.py, then publish those files as content links. The generator also creates guard files for rejected headers. It is not an independent reference writer, so these fixtures do not replace checks against real external files. References: .github/…/pixi.yml• L81-92, .github/…/pixi.yml• L129-169, .github/…/arm.yml• L132-143, .github/…/populate-externaldata-cache.yml• L72-108, Modules/…/CMakeLists.txt• L27-86, Modules/…/generate_vti_fixtures.py• L1-27, Modules/…/generate_vti_fixtures.py• L444-450
Integration and review modules
The ITKIntegratedTest module checks behavior that crosses module boundaries. It exercises shared filters, image and mesh operations, I/O paths, and other combinations that a single module test cannot represent. The ITKReview module validates a separate set of contributed or staged features through focused behavior checks and output comparisons. It is excluded from the default module set and is enabled when that review coverage is needed.
These modules provide two levels of confidence. Integrated tests ask whether established modules work together. Review tests ask whether a feature produces the expected result across representative inputs and settings. References: Modules/Nonunit/IntegratedTest/itk-module.cmake#L1-L87, Modules/…/CMakeLists.txt• L1-18, Modules/Nonunit/Review/itk-module.cmake#L1-L101, Modules/…/CMakeLists.txt• L1-50
Quality tooling
Quality checks supplement behavior tests with checks that catch errors before runtime. They protect module boundaries, source conventions, generated interfaces, and documentation quality.
Module and source checks
Header checks compile generated groups of public headers to expose missing module dependencies. KWStyle checks source layout and naming rules, while optional Cppcheck analysis reviews module source and test code for static problems. These checks support the module quality path rather than replacing behavior tests.
The pre-commit suite provides fast checks before review. It covers file safety, CMake and Python formatting, source formatting, simple Python upgrades, merge-conflict markers, private-key detection, comment spelling, and repository-specific hooks. The pull request workflow also runs focused migration-record tool tests with pinned Python packages before it runs the pre-commit action. The spelling check combines a shared dictionary with the ITK-specific word list in .github/…/itk_dict.txt. The workflow prepares the hook setup and runs this suite with Python 3.12 on Ubuntu 24.04. The test automation page describes how these checks connect to contributor and CI workflows. References: CMake/ITKModuleHeaderTest.cmake#L1-L16, CMake/ITKModuleKWStyleTest.cmake#L1-L23, CMake/ITKModuleCPPCheckTest.cmake#L1-L37, .pre-commit-config.yaml• L10-16, .pre-commit-config.yaml• L86-98, .github/…/itk_dict.txt• L1-1448, .github/…/pre-commit.yml• L1-24
Python wrapping checks
Python wrapping checks protect the user-facing Python view of ITK. They cover wrapped class availability, type and template behavior, lazy loading, pipeline use, metadata conversion, image I/O, array exchange, and safe release of Python's global interpreter lock. Module-specific Python checks can also be registered when wrapping is enabled. Current module checks include dimension-gated Cuberille tests, RLE image type and region-of-interest combinations, Strain filter instantiation, and a RANSAC mesh registration path using external mesh data.
The checks run through CTest with the built wrapper package on PYTHONPATH. They also check NumPy array layout and ownership rules plus platform-specific fixed-width C type aliases. This connects wrapper validation to the same native build and test result used by the rest of ITK. See Python wrapping for the broader binding build and packaging model. References: Wrapping/…/CMakeLists.txt• L1-61, Wrapping/…/CMakeLists.txt• L63-144, Wrapping/…/CMakeLists.txt• L146-229, Wrapping/…/CMakeLists.txt• L231-298, Wrapping/…/extras.py• L409-529, Wrapping/…/test_ctype.py• L25-89, Modules/…/CMakeLists.txt• L1-49, Modules/…/CMakeLists.txt• L1-25, Modules/…/CMakeLists.txt• L1-10, Modules/…/CMakeLists.txt• L1-19, Modules/…/itkRansacMeshTest.py• L19-118, Modules/…/CMakeLists.txt• L1-8, CMake/ITKModuleTest.cmake#L194-L268
Continuous integration
Continuous integration builds and tests supported configurations that are too broad or slow for one local default. Each job prepares tools and caches, configures a chosen build, builds it, runs the selected CTest set, and publishes diagnostics.
Build configuration coverage
The CI matrix checks native builds on Linux, Windows, and macOS. The main Pixi native job uses Ubuntu 22.04, Windows 2022, and macOS 15. The ARM workflow adds native Ubuntu ARM64, x86_64 macOS under Rosetta, and a macOS Python wrapping build. Azure Python dashboard jobs add wrapped-package coverage on Linux, macOS, and Windows. These jobs vary library form and module scope so that both broad and reduced wrapping builds are checked. Other jobs vary debug or release mode, compiler toolsets, C++ standard choices, enabled modules, and memory limits.
The Pixi tasks provide the common local and CI shape for configure, build, test, Python, debug, release, and documentation runs. Azure dashboard jobs add legacy, batch, platform-specific, and Python coverage. The Linux legacy dashboard now runs on Ubuntu 24.04. It uses a C++20 debug build with legacy APIs removed and strict undefined-symbol checks for shared libraries. The Linux Python dashboard runs a release, static-library wrapping build on Ubuntu 22.04 with module tests disabled and a focused Python label set. The macOS Python dashboard runs a release, shared-library wrapping build on macOS 15 with a larger memory allowance. These jobs use the shared external-data store and compiler cache, then publish CTest results and build diagnostics. The module build and distribution page explains how these build choices affect the produced toolkit. References: pyproject.toml• L43-136, pyproject.toml• L188-292, .github/…/pixi.yml• L32-40, .github/…/arm.yml• L35-85, Testing/…/AzurePipelinesLinux.yml• L39-44, Testing/…/AzurePipelinesLinux.yml• L112-152, Testing/…/AzurePipelinesLinuxPython.yml• L39-44, Testing/…/AzurePipelinesLinuxPython.yml• L113-153, Testing/…/AzurePipelinesMacOSPython.yml• L39-45, Testing/…/AzurePipelinesMacOSPython.yml• L116-156, Testing/…/AzurePipelinesWindowsPython.yml• L39-44, Testing/…/AzurePipelinesWindowsPython.yml• L94-118, Testing/…/AzurePipelinesBatch.yml• L21-40
Workflow signals and diagnostics
GitHub Actions runs the main Pixi matrix, ARM and Rosetta coverage, pre-commit checks, documentation warnings, performance comparison, and external-data cache population. Azure Pipelines runs additional dashboard builds and publishes CTest results for review. Pull request path filters avoid spending build time on changes that cannot affect a workflow. The documentation warning check remains active for every pull request.
The CI flow separates correctness, review quality, and performance signals.
flowchart LR
A[Source change] --> B[Prepare tools and caches]
B --> C[Configure build]
C --> D[Build]
D --> E[Run selected CTest checks]
E --> F[Publish results and diagnostics]
A --> G[Quality checks]
A --> H[Performance comparison]
Build caches reduce repeat work without changing the validation target. Pixi and ARM jobs restore compiler and external-data caches, fetch test data before the build, and save compiler results after the run. The population workflow is the only writer of the shared external-data cache. A separate housekeeping job removes superseded compiler cache entries. When a dashboard build fails, the diagnostic helper extracts compiler warnings and errors from CTest's build record so the useful cause appears in the CI log. Performance CI builds benchmark targets at the merge base and pull request head, then compares the two result sets. References: .github/…/pixi.yml• L72-92, .github/…/pixi.yml• L152-218, .github/…/arm.yml• L123-143, .github/…/arm.yml• L194-223, .github/…/pre-commit.yml• L1-24, .github/…/doxygen.yml• L1-67, .github/…/perf-benchmark.yml• L81-177, Testing/…/AzurePipelinesLinux.yml• L89-103, Testing/…/AzurePipelinesLinux.yml• L160-174, Testing/…/AzurePipelinesLinuxPython.yml• L90-104, Testing/…/AzurePipelinesLinuxPython.yml• L159-173, Testing/…/AzurePipelinesMacOSPython.yml• L93-107, Testing/…/AzurePipelinesMacOSPython.yml• L162-176, Testing/…/AzurePipelinesWindowsPython.yml• L124-150, Testing/…/report_build_diagnostics.py• L1-10
Change checklist
When these files or sections are changed, remember to consider these:
- A new or renamed test source must remain in the module's driver list, GoogleTest list, or both as needed. Its CTest registration must provide the required data, output, and cleanup behavior.
- A new
DATA{...}reference needs a reachable content link and a matching entry in the external-data cache scope. - A new test label or test name must remain unique because CTest cleanup fixtures and CI label filters depend on those names.
- A generated VTI fixture must be regenerated with its matching
.cidfiles and staged into the directory expected by the GoogleTest driver. Guard fixtures must remain limited to rejection tests. - A changed baseline must preserve the input and output pairing used by the regression test and must have its content link recorded in
Testing/Data/content-links.manifest. - A changed content-link manifest entry must keep the single-space format, path-without-whitespace rule, and sorted path order used by the upload tool.
- A new wrapped Python type or enabled scalar and dimension must have the matching build conditions and Python test coverage.
- A new supported build choice must be represented in the relevant Pixi or Azure matrix rather than only in a local task.
- A change to the shared external-data cache flow must keep population and consumer jobs separate so a partial object store cannot become the shared cache.
- A change to Python dashboard coverage must keep the platform library form, wrapped module scope, and CTest Python selection aligned with the build it claims to validate.
- A change to FFTW target detection or SIMD defaults must keep architecture, compiler-target, universal-binary, and explicit-option expectations aligned with the configure-time architecture check.
- A change to a shared test helper must preserve the behavior of CPU, GPU, benchmark, and white-image Yvv test entry points after the helper rename.
- A new domain term used in checked comments must be added to the ITK dictionary or the shared spelling sources used by the pre-commit hook.
- A change to migration-record tools or their inputs must keep the focused migration test step and its pinned Python dependencies aligned in the pull request workflow.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An external-data link cannot be fetched | Tests that need the object cannot configure or run | The population workflow verifies every unique object before it saves the shared cache. Consumer jobs restore the store and do not write it. |
| A content-link manifest entry contains whitespace or an invalid path mapping | The external-data map cannot be parsed or the requested test object cannot be found | The manifest uses one space-delimited entry per path, keeps paths free of whitespace, and is maintained by the upload tool. |
| A test source is added to a module but not to its driver or GoogleTest list | The test is absent from the CTest result even though its file exists | Module CMake files keep source lists and driver creation together. |
| A GoogleTest suite is built but not registered with the module test setup | The suite is absent from the CTest result even though its executable builds | The module CMake file creates the GoogleTest driver and registers its test data and output behavior. |
| Two tests use the same CTest name | Cleanup fixtures can race and the main configure can fail | itk_add_test checks names globally and rejects duplicates in the main source tree. |
| A test writes large temporary output without cleanup | A local or CI disk can fill during a broad run | Test registration adds cleanup fixtures by default. Developers can disable cleanup only when they need failure output. |
| A module omits a required test dependency | Its test driver may not link or may not represent the module contract | Module test metadata declares test dependencies and test drivers link the test support module. |
| A wrapper test assumes an unavailable dimension or scalar type | A valid reduced wrapping build reports a false failure | Conditional registration limits those tests to the wrapped types and dimensions. |
| A shared library leaves a symbol undefined in the Linux dashboard build | The build fails early instead of hiding a missing dependency until load time | The Azure Linux job sets -Wl,-z,defs for shared libraries. |
| A documentation build emits a warning | The Doxygen workflow fails its warnings-only check | The workflow uploads the warning log and effective configuration for review. |
| A valid ITK term is absent from the spelling dictionaries | The comment spell check reports a false error and can block review | The pre-commit hook uses the shared dictionary together with .github/…/itk_dict.txt. |
| Migration-record tool behavior or its input contract changes without matching workflow tests | The pull request quality job can miss a broken migration check or fail on an invalid test setup | The workflow installs pinned packages and runs the focused migration-record test suite before the pre-commit action. |
| FFTW architecture detection selects the wrong SIMD default | A build can enable unsupported instructions or miss valid target-specific code | The configure-time check compares ARM, x86, macOS, compiler-target, and explicit-option cases with expected defaults. |
| A Yvv test runs in GPU mode without a usable OpenCL device | The test exits before it can report filter behavior | GPU entry points check GPU availability and report when GPU support is not configured. |
Key files
| File | Why to read it |
|---|---|
CMake/ITKModuleTest.cmake | Defines shared test drivers, CTest registration, Python test setup, GoogleTest discovery, dependency checks, and output cleanup. |
CMake/ITKExternalData.cmake | Defines how test objects are stored and where the build looks for missing data. |
| Testing/…/README.md | Explains the input and baseline data model and the content-link workflow. |
Testing/Data/content-links.manifest | Defines the path-to-content map and its format for external test inputs and baselines. |
| Modules/…/CMakeLists.txt | Shows how legacy drivers, GoogleTest suites, dynamic factory tests, newer-standard client checks, and threader coverage enter one module test set. |
Modules/Core/Common/test/itkImageIORegionGTest.cxx | Shows value and region behavior checks for a core data type. |
Modules/Core/Common/test/itkPoolMultiThreaderGTest.cxx | Shows concurrency checks for work completion, observer errors, and large image regions. |
Modules/Core/Common/test/itkImageIteratorsGTest.cxx | Shows compile-time and run-time checks for image iterator construction, traversal, conversion, const access, and write access. |
Modules/Core/Common/test/itkBridgeMathSVDGTest.cxx | Shows numerical checks for reconstruction, rank, pseudo-inverse, least-squares solve, and legacy-engine agreement. |
| Modules/…/CMakeLists.txt | Shows how legacy image-filter drivers and focused arithmetic GoogleTest suites share one module test set. |
Modules/Filtering/ImageIntensity/test/itkArithmeticOpsFunctorsTest.cxx | Shows edge-case checks for arithmetic functors and division behavior. |
Modules/Filtering/ImageIntensity/test/itkWeightedAddImageFilterGTest.cxx | Shows checks for weighted image input and constant behavior. |
| Modules/…/CMakeLists.txt | Shows how path driver tests and the path iterator GoogleTest suite enter the module test set. |
Modules/Filtering/Path/test/itkPathIteratorGTest.cxx | Shows checks for path iterator state copying, type deduction, and read-only access. |
| Modules/…/CMakeLists.txt | Shows how displacement-field GoogleTest suites join the existing driver tests. |
| Modules/…/CMakeLists.txt | Shows how image-grid GoogleTest suites join data-backed image comparisons. |
Modules/Filtering/SmoothingRecursiveYvvGaussianFilter/test/itkYvvFilterTest.hxx | Defines the shared CPU, GPU, timing, image-output, and white-image test behavior. |
| Modules/…/CMakeLists.txt | Shows long-running registration tests, data comparisons, and focused GoogleTest registration. |
Modules/Nonunit/IntegratedTest/itk-module.cmake | Shows the purpose and broad dependency scope of cross-module validation. |
Modules/Nonunit/Review/itk-module.cmake | Shows the purpose and default-build status of review feature validation. |
| Wrapping/…/CMakeLists.txt | Shows coverage areas and build conditions for Python wrapper tests. |
| Modules/…/CMakeLists.txt | Shows dimension-gated Python wrapping tests with external image inputs. |
| Modules/…/CMakeLists.txt | Shows Python checks for wrapped image and region-of-interest type combinations. |
| Modules/…/CMakeLists.txt | Shows direct Python construction checks for wrapped filter types. |
| Modules/…/CMakeLists.txt | Shows registration of the RANSAC Python workflow and wrapped type check. |
| Modules/…/itkRansacMeshTest.py | Shows the Python mesh-data path used to validate wrapped RANSAC registration. |
| pyproject.toml | Defines shared Pixi environments and local or CI configure, build, test, Python, and documentation tasks. |
| .github/…/pixi.yml | Shows the main cross-platform native CI matrix, data fetch, test, and compiler-cache flow. |
| .github/…/arm.yml | Shows ARM64, Rosetta, and Python configuration coverage. |
| .github/…/populate-externaldata-cache.yml | Shows the single-owner, complete-before-save external-data cache process. |
| Utilities/…/PrefetchCIDContentLinks.py | Shows how all content links are collected and prefetched before the shared cache is saved. |
| .github/…/pre-commit.yml | Shows how migration-record tests and repository quality checks run on pull requests. |
| .github/…/itk_dict.txt | Lists ITK-specific terms accepted by the comment spelling check. |
| .github/…/perf-benchmark.yml | Shows how performance results are compared between the merge base and pull request head. |
| Testing/…/AzurePipelinesLinux.yml | Shows the Linux legacy dashboard configuration, strict shared-library link checks, cache use, and CTest result publishing. |
| Testing/…/AzurePipelinesLinuxPython.yml | Shows Linux Python wrapping coverage, focused Python test selection, external-data and compiler caches, and CTest result publishing. |
| Testing/…/AzurePipelinesMacOSPython.yml | Shows macOS Python wrapping coverage, shared-library configuration, and dashboard diagnostics. |
| Testing/…/AzurePipelinesWindowsPython.yml | Shows Windows Python wrapping coverage and its reduced module build. |
| Testing/…/report_build_diagnostics.py | Shows how compiler diagnostics are made visible in CI logs. |