fix: fall back to simple assertions when test gen can't resolve value types#937
Merged
fix: fall back to simple assertions when test gen can't resolve value types#937
Conversation
… types (#818) When the test generator detects a function returns Ok(value) or Some(value) but can't resolve the type for field-level assertions, it was leaving TODO placeholder stubs: let _ = inner; // TODO: assert specific value for "skipped" These compile but test nothing, get flagged as TodoMarker findings, and create a circular loop in the autofix pipeline. Now: if enrich_assertion_with_fields fails to resolve the type, the generator falls back to the simpler discriminant-only assertion (e.g. result_ok instead of result_ok_value): assert!(result.is_ok(), "expected Ok for: ..."); A test that asserts is_ok() is better than a dead TODO stub.
Contributor
Homeboy Results —
|
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.
Summary
Fixes a gap in the test generation pipeline (#818) where unresolvable return types produced dead TODO stubs instead of real tests.
Problem
The test gen pipeline has two tiers of assertion templates:
When a function returns
Ok(value)and the value's type is in the registry,enrich_assertion_with_fieldsreplaces the TODO with realassert_eq!calls. But when the type ISN'T in the registry (common for complex or external types), the TODO stays.These stubs:
TodoMarkeraudit findingsFix
After
enrich_assertion_with_fields, if the assertion still contains// TODO:, fall back to the simpler non-value template:Before:
let _ = inner; // TODO: assert specific value for "skipped"After:
assert!(result.is_ok(), "expected Ok for: ...");A test that asserts the discriminant (
is_ok,is_some,is_err,is_none) is a real behavioral test. The value-level assertion is a nice-to-have that should only appear when it can actually produce meaningful assertions.Impact
This should reduce the
missing_test_methodandtodo_markerissue counts in both homeboy and data-machine by eliminating the stub generation path.