feat: Add testsuite validation for option types - #1473
robertlipe wants to merge 3 commits into
Conversation
robertlipe
commented
Oct 7, 2025
- feat: Add runtime validation for option types
- Revert "feat: Add runtime validation for option types"
- feat: Add runtime validation for option types
Add a `get_type()` virtual method to the `Option` class hierarchy to enable runtime type identification. Use this new method in `Vecs::validate_args` to validate that the `argtype` specified in `arglist_t` tables matches the actual type of the `Option` object. This will catch configuration errors at startup, such as the one that was present in the kalman filter. This change also includes several fixes to the `Option` class hierarchy to resolve build errors that surfaced during development, including breaking a circular dependency between `defs.h` and `option.h`.
This reverts commit 6b3661c.
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
tsteven4
left a comment
There was a problem hiding this comment.
I can't recreate the original problem as history has been erased by forced pushes. I think the original code should work, but evidently there was a hole?
| virtual void init(const QString& id) {} | ||
| virtual void reset() = 0; | ||
| virtual void set(const QString& s) = 0; | ||
| virtual bool isValid(const QString& s) const = 0; |
There was a problem hiding this comment.
shouldn't isValid be [[nodiscard]]? (everywhere).
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Aren't these cases covered already by the original code below which uses a dynamic cast to deduce the type? I'm missing something or this whole PR seems redundant. I'm trying to find the original failure but with the forced pushes I'm having trouble seeing what the problem was.
There was a problem hiding this comment.
Indeed. When we (Gemini and I) were adding new options in kalman.cc, we triggered a crash from a mismatched type. It was somethin glike the difference in the arguments between strings and floats (sometimes we "atof" and sometimes we ust want a number) and things would get ugly. We fixed the caller, but it occurred to. methat we should be able to catch it (when I started, I was thinking at startup and that probably stuck in my head) but we indeed learned it's in the test - which is cool! This is kind of how I got in trouble because i started two-timing the kalman work and this work at the same time and I think that having two PR-to-bes in one branch confuses it WAY more that it screws me up. I can USUALLY pull it off, but you can tell that I've spent the evening pullin the Kalman work apart into manageable PRs. I DOSes myself. :-/
It's also indeed horse-crap that it chose to delete everything checked in and rewrite git history, nuking a whole lot of history each at least once. SO maddening.
There was a problem hiding this comment.
So this PR can be abandoned and closed, correct?
|
BTW the validation is not at startup, but when you run the validate_formats test. |
|
If I take kalman-2, restore options.h and options.cc from main, take out the new check code in vecs.cc so only the original checks exist, and then introduce type mismatches in kalman.h: and the the test shows: |
034ebfa to
61d9235
Compare
5ea736b to
de5ac3d
Compare
|
I see some activity in the kalman-2 branch that shows the kalman options were originally ARGTYPE_STRING instead of ARGTYPE_FLOAT. If I
|
Add a `get_type()` virtual method to the `Option` class hierarchy to enable runtime type identification. Use this new method in `Vecs::validate_args` to validate that the `argtype` specified in `arglist_t` tables matches the actual type of the `Option` object. This will catch configuration errors at startup. This change also includes several fixes to the `Option` class hierarchy to resolve build errors that surfaced during development, including breaking a circular dependency between `defs.h` and `option.h`.
@robertlipe My conclusion is the original option checking was sufficient to detect the errors you had. I suspect that you assumed the validation ran at startup instead of during the validate_formats test (which also validates the filter arguments). |
|
@robertlipe note that catching any mismatches at test in CI prevents any mismatches from being merged through a PR, but it doesn't prevent them from confusing a developer who hasn't run the test yet. |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |