Repository navigation
BUG: Fail Statistics tests when Update() throws, then convert to GoogleTest - #7048
Open
hjmjohnson wants to merge 20 commits into
Open
hjmjohnson wants to merge 20 commits into
hjmjohnson wants to merge 20 commits into
Conversation
This was referenced Oct 31, 2026
hjmjohnson
marked this pull request as ready for review
October 31, 2026 18:19
Contributor
[Low impact] The changes affect how a bounded set of Statistics tests report results. The exception fixes look sound, but the numbered conversions must use distinct GoogleTest suites before merging. Findings
|
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
hjmjohnson
force-pushed
the
bug-statistics-swallowed-exceptions
branch
from
October 31, 2026 23:23
ded447c to
6680dd6
Compare
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced. Its message also wrongly called the exception expected.
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced. Its message also wrongly called the exception expected.
…) throws The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
The catch block printed the exception and let the test continue, so a failing Update() went unnoticed and the checks that follow ran on output that was never produced.
hjmjohnson
force-pushed
the
bug-statistics-swallowed-exceptions
branch
from
November 1, 2026 00:53
6680dd6 to
483d119
Compare
hjmjohnson
added a commit
to hjmjohnson/ITK
that referenced
this pull request
Nov 1, 2026
# Conflicts: # Modules/Numerics/Statistics/test/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ten Statistics tests caught an exception from
Update(), printed it, and carried on, so a failing filter went unnoticed and the checks that followed read output that was never produced. For each test, oneBUG:commit makes the catch fail the test, and the next commit converts the fixed test to GoogleTest (ASSERT_NO_THROW).itkCovarianceSampleFilterTestitkCovarianceSampleFilterTest2itkMeanSampleFilterTestitkMeanSampleFilterTest2itkMeanSampleFilterTest3itkWeightedMeanSampleFilterTestitkWeightedCovarianceSampleFilterTestitkWeightedCovarianceSampleFilterTest2itkStandardDeviationPerComponentSampleFilterTestitkSubsampleTest3Testing
macOS arm64, conda clang, Release,
ITK_BUILD_DEFAULT_MODULES=OFF,Module_ITKStatistics=ON. Every one of the 20 commits builds both Statistics drivers with 0 warnings and passes the affected legacy and GoogleTest tests. Each fixed legacy test passes, which confirms that none of theseUpdate()calls throws today.pre-commit run --all-filespasses.Every Statistics GoogleTest, the existing ones and these ten, was also scanned for try/catch blocks and error branches that cannot fail the test; none remain.
The conversions use
ASSERT_NO_THROWrather thanEXPECT_NO_THROWbecause eachUpdate()is followed by checks on the filter's output.How these were found
A review of the staged no-argument GoogleTest conversions (
gtest-staging-C) found that the conversions copied these swallowing catch blocks faithfully. As with #7046, the fix goes to each legacy test first and the conversion follows.itkCovarianceSampleFilterTest3has the same defect; it is fixed separately in #7049 because #7046 converts it.AI assistance (Claude Code) was used to find the defects and draft the changes; they were reviewed and tested locally.