Skip to content

ENH: Reduce CTest verbosity to show output only for failing tests#5971

Open
hjmjohnson wants to merge 2 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:ci-reduce-ctest-verbosity
Open

ENH: Reduce CTest verbosity to show output only for failing tests#5971
hjmjohnson wants to merge 2 commits intoInsightSoftwareConsortium:mainfrom
hjmjohnson:ci-reduce-ctest-verbosity

Conversation

@hjmjohnson
Copy link
Member

Summary

Replace -VV (extra verbose) with -V (verbose) in all CI pipeline ctest -S invocations across 8 YAML files.

Background

Every ITK CI pipeline currently runs CTest in extra-verbose mode (-VV), which prints the full stdout/stderr of every test — regardless of whether it passed or failed. With ITK's 3000+ test suite, this generates enormous CI log output, making it difficult to locate actual failures when a build goes red.

Every pipeline also sets the environment variable CTEST_OUTPUT_ON_FAILURE=1, which is designed to print test output only for failing tests. However, this variable has been effectively dead code — the -VV flag unconditionally prints all output, overriding the output-on-failure behavior.

How CTest verbosity works

Flag Behavior
(none) Minimal output — just summary counts
-V Verbose — prints test names, pass/fail status, and timing
-VV Extra verbose — prints full stdout/stderr of every test
CTEST_OUTPUT_ON_FAILURE=1 Prints full output only for tests that fail (works with -V or no flag, overridden by -VV)

The CTEST_OUTPUT_ON_FAILURE environment variable works in both direct ctest invocations and ctest -S scripted/dashboard mode. The ctest_test() CMake command used internally by itk_common.cmake does not have an OUTPUT_ON_FAILURE keyword argument, but the environment variable is read by the CTest process regardless of invocation mode.

What this changes

  • Before: -VV prints all 3000+ tests' output → large logs, failures buried in noise
  • After: -V + CTEST_OUTPUT_ON_FAILURE=1 prints progress for all tests, full output only for failures → smaller logs, failures immediately visible

Files changed

File Occurrences
.github/workflows/arm.yml 1
AzurePipelinesLinux.yml 3 (one per build config)
AzurePipelinesLinuxPython.yml 1
AzurePipelinesMacOS.yml 1
AzurePipelinesMacOSPython.yml 1
AzurePipelinesWindows.yml 1
AzurePipelinesWindowsPython.yml 1
AzurePipelinesBatch.yml 1

Test plan

  • All pipelines already set CTEST_OUTPUT_ON_FAILURE: 1 in their env blocks
  • CI builds pass on all platforms (Linux, macOS, Windows, ARM)
  • Failing tests still produce full diagnostic output in logs

🤖 Generated with Claude Code

Replace -VV (extra verbose) with -V (verbose) in all CI pipeline
invocations of `ctest -S`. This change applies to all 8 Azure DevOps
pipeline YAML files and the GitHub Actions arm.yml workflow.

Background:

The -VV flag causes CTest to print the full stdout/stderr of every
test, regardless of whether it passed or failed. With ITK's 3000+
tests, this generates hundreds of megabytes of CI log output, making
it difficult to find the actual failure in a failing build.

Every pipeline already sets the environment variable
CTEST_OUTPUT_ON_FAILURE=1, which instructs CTest to print test output
only when a test fails. However, this variable has been effectively
dead code because -VV unconditionally prints all output, overriding
the output-on-failure behavior.

With this change:
- -V (verbose) prints CTest progress: test names, pass/fail status,
  and timing — sufficient for monitoring build progress
- CTEST_OUTPUT_ON_FAILURE=1 now takes effect, printing full test
  output only for tests that fail
- CI logs are dramatically smaller and failures are easier to find

Note: The CTEST_OUTPUT_ON_FAILURE environment variable works in both
direct ctest invocations and ctest -S scripted/dashboard mode. The
ctest_test() CMake command used internally by itk_common.cmake does
not have an OUTPUT_ON_FAILURE keyword argument, but the environment
variable is read by the CTest process regardless of invocation mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct labels Mar 20, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 20, 2026

Greptile Summary

This PR replaces -VV (extra-verbose) with -V (verbose) in all eight CI pipeline ctest -S invocations, allowing the already-configured CTEST_OUTPUT_ON_FAILURE=1 environment variable to take effect. The result is that CI logs will show test names and pass/fail status for every test but only print full stdout/stderr for failing tests — significantly reducing log noise on ITK's 3 000+ test suite while keeping failures immediately visible.

The change is mechanical and complete: all eight YAML files that call ctest -S have been updated, no other CI files run ctest, and every changed step already carries CTEST_OUTPUT_ON_FAILURE: 1 in its env: block.

Notable considerations:

  • Output from passing tests will no longer appear in historical CI logs, which can make it harder to retrospectively debug intermittent failures that previously passed. Teams should be aware of this trade-off.
  • The CTEST_OUTPUT_ON_FAILURE environment variable is confirmed to work in scripted/dashboard mode (ctest -S); it is read by ctest_test() internally regardless of invocation mode.
  • No issues were found with the implementation — all pipelines (Linux, macOS, Windows, ARM) are handled consistently.

Confidence Score: 5/5

  • This PR is safe to merge — it is a mechanical, low-risk verbosity reduction that makes a previously inert env var effective.
  • The change is a single-character flag swap (-VV-V) repeated identically across 8 files. Every affected step already carries CTEST_OUTPUT_ON_FAILURE: 1, so the intended semantics (full output only on failure) are already in place and will simply activate. No test logic, build configuration, or application code is modified. All CI platforms (Linux, macOS, Windows, ARM) are covered and none were missed.
  • No files require special attention.

Important Files Changed

Filename Overview
.github/workflows/arm.yml Single -VV-V replacement at line 177; CTEST_OUTPUT_ON_FAILURE: 1 already present in the same step's env: block.
Testing/ContinuousIntegration/AzurePipelinesLinux.yml Three -VV-V replacements (lines 114, 205, 294) covering the Linux, LinuxLegacyRemoved, and LinuxCxx20 jobs; each step already sets CTEST_OUTPUT_ON_FAILURE: 1.
Testing/ContinuousIntegration/AzurePipelinesLinuxPython.yml Single -VV-V replacement; CTEST_OUTPUT_ON_FAILURE: 1 already set. The lengthy -E exclusion filter is preserved correctly.
Testing/ContinuousIntegration/AzurePipelinesMacOS.yml Single -VV-V replacement; CTEST_OUTPUT_ON_FAILURE: 1 already set.
Testing/ContinuousIntegration/AzurePipelinesMacOSPython.yml Single -VV-V replacement; CTEST_OUTPUT_ON_FAILURE: 1 already set.
Testing/ContinuousIntegration/AzurePipelinesWindows.yml Single -VV-V replacement on a Windows script: step; Azure Pipelines env: block sets CTEST_OUTPUT_ON_FAILURE: 1 for cmd-based steps as well.
Testing/ContinuousIntegration/AzurePipelinesWindowsPython.yml Single -VV-V replacement; CTEST_OUTPUT_ON_FAILURE: 1 already set, -L Python label filter preserved.
Testing/ContinuousIntegration/AzurePipelinesBatch.yml Single -VV-V replacement in the Windows batch pipeline; CTEST_OUTPUT_ON_FAILURE: 1 already set.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["CI pipeline triggers\n(push / PR)"] --> B["ctest -S dashboard.cmake -V -j N"]
    B --> C{Test result?}
    C -- Pass --> D["Print: test name + status + timing\n(no stdout/stderr captured)"]
    C -- Fail --> E["CTEST_OUTPUT_ON_FAILURE=1\nPrint: test name + status + full stdout/stderr"]
    D --> F["CTest summary"]
    E --> F
    F --> G["ci_addons: format JUnit XML\n(Azure Pipelines only)"]
    G --> H["PublishTestResults\n(Azure Pipelines only)"]

    style E fill:#f96,color:#000
    style D fill:#9c9,color:#000
Loading

Last reviewed commit: "ENH: Reduce CTest ve..."

hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Mar 20, 2026
DO NOT MERGE — this commit intentionally introduces:

1. An unused variable in itkObject.cxx to generate a compiler warning
   (-Wunused-variable) that should appear in CDash warning counts.

2. A deliberate EXIT_FAILURE in itkPointGeometryTest to verify that
   CTEST_OUTPUT_ON_FAILURE=1 produces visible test output in CI logs
   when using -V instead of -VV.

This is a test artifact for PR InsightSoftwareConsortium#5971 (reduce CTest verbosity).
If the CI logs show the "DELIBERATE FAILURE" message in the test
output section, the new verbosity scheme is working correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ctest_build() captures compiler diagnostics in Build.xml for CDash
submission but does not print them to the CI log.  With -V (instead
of -VV), build output scrolls past quickly and warnings are easy to
miss entirely.

Add report_build_diagnostics.py which parses the <Warning> and
<Error> elements from Build.xml and prints them in a clearly
delimited section.  Add a "Report build warnings and errors" step
to every Azure DevOps and GitHub Actions pipeline, running after
the build/test step with succeededOrFailed()/always() so diagnostics
are reported even when the build fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the area:Python wrapping Python bindings for a class label Mar 20, 2026
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Mar 20, 2026
DO NOT MERGE — this commit intentionally introduces:

1. An unused variable in itkObject.cxx to generate a compiler warning
   (-Wunused-variable) that should appear in CDash warning counts.

2. A deliberate EXIT_FAILURE in itkPointGeometryTest to verify that
   CTEST_OUTPUT_ON_FAILURE=1 produces visible test output in CI logs
   when using -V instead of -VV.

This is a test artifact for PR InsightSoftwareConsortium#5971 (reduce CTest verbosity).
If the CI logs show the "DELIBERATE FAILURE" message in the test
output section, the new verbosity scheme is working correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Mar 20, 2026
Point all CI pipelines at hjmjohnson/ITK dash-board-github-ci-instrument-groupings
branch instead of upstream dashboard to test collapsible CI log sections
and build diagnostics reporting from PR InsightSoftwareConsortium#5973.

This commit must NOT be merged — revert the dashboard clone URL
before merging PR InsightSoftwareConsortium#5971.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks, Hans!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Python wrapping Python bindings for a class type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants