Skip to content

BUG: Fail four tests that swallow unexpected exceptions, then convert to GoogleTest - #7051

Merged
hjmjohnson merged 8 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:bug-swallowed-exceptions-misc
Nov 3, 2026
Merged

hjmjohnson merged 8 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:bug-swallowed-exceptions-misc

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Four tests caught an unexpected exception, printed it, and carried on, so a failing filter or setter went unnoticed and the test still passed. For each test, one BUG: commit makes the catch fail the test, and the next commit converts the fixed test to GoogleTest (ASSERT_NO_THROW, or EXPECT_NO_THROW for a final statement).

Test Module Swallowed call
itkMaskImageFilterTest ImageIntensity vectorFilter->Update() with the default outside value
itkMultivariateLegendrePolynomialTest Polynomials SetCoefficients(), behind an empty catch (...)
itkImplicitManifoldNormalVectorFilterTest LevelSets filter->Update(), the test's only real check
itkLaplacianSegmentationLevelSetImageFilterTest LevelSets both Update() calls (first run and reinitialized rerun)
Testing

macOS arm64, conda clang, Release, ITK_BUILD_DEFAULT_MODULES=OFF with Module_ITKImageIntensity, Module_ITKPolynomials, and Module_ITKLevelSets on. Every one of the 8 commits builds the affected drivers with 0 warnings and passes the four tests; each fixed legacy test passes, so none of these calls throws today. pre-commit run --all-files passes.

itkMultivariateLegendrePolynomialTest is the only Polynomials test, so its conversion replaces the module's legacy driver with a GoogleTest driver and adds ITKGoogleTest to TEST_DEPENDS.

How these were found

Same review as #7048 (Statistics) and #7049, extended to the rest of the tree. The staged conversions on gtest-staging-B and gtest-staging-C copied these catch blocks faithfully.

AI assistance (Claude Code) was used to find the defects and draft the changes; they were reviewed and tested locally.

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances 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 area:Filtering Issues affecting the Filtering module area:Segmentation Issues affecting the Segmentation module area:Numerics Issues affecting the Numerics module labels Oct 31, 2026
@hjmjohnson
hjmjohnson marked this pull request as ready for review October 31, 2026 18:22
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

Four legacy tests now fail on unexpected exceptions and run through GoogleTest.

  • The mask filter test fails when a valid vector-image update throws.
  • The polynomial test fails if setting coefficients throws.
  • The normal-vector filter test fails when its update throws.
  • The Laplacian filter test fails if either update throws.

Reviews (2) · Last reviewed commit: "ENH: Convert itkLaplacianSegmentationLev..." · Reviewed by Greptile

@hjmjohnson
hjmjohnson force-pushed the bug-swallowed-exceptions-misc branch from d9de8e1 to 0d62971 Compare October 31, 2026 23:23
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Nov 1, 2026
@hjmjohnson
hjmjohnson requested a review from dzenanz November 1, 2026 16:52
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Nov 1, 2026
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Nov 2, 2026
hjmjohnson added a commit to hjmjohnson/ITK that referenced this pull request Nov 2, 2026

@dzenanz dzenanz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mostly looks good.

The catch block printed the exception and let the test continue, so
a failure went unnoticed and the test still passed.
The catch block printed the exception and let the test continue, so
a failure went unnoticed and the test still passed.
…tion

The catch block printed the exception and let the test continue, so
a failure went unnoticed and the test still passed.
The catch block printed the exception and let the test continue, so
a failure went unnoticed and the test still passed.
@hjmjohnson
hjmjohnson force-pushed the bug-swallowed-exceptions-misc branch from 0d62971 to 11a8b47 Compare November 2, 2026 19:24
@hjmjohnson
hjmjohnson force-pushed the bug-swallowed-exceptions-misc branch from 11a8b47 to d2342d3 Compare November 2, 2026 19:27
@hjmjohnson

Copy link
Copy Markdown
Member Author

@greptileai review this draft before I make it official

@hjmjohnson
hjmjohnson merged commit d308fce into InsightSoftwareConsortium:main Nov 3, 2026
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module area:Numerics Issues affecting the Numerics module area:Segmentation Issues affecting the Segmentation module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances 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