test: data-driven filter test engine with RTK_UPDATE_TEST_DATA#901
Open
osipxd wants to merge 2 commits intortk-ai:developfrom
Open
test: data-driven filter test engine with RTK_UPDATE_TEST_DATA#901osipxd wants to merge 2 commits intortk-ai:developfrom
osipxd wants to merge 2 commits intortk-ai:developfrom
Conversation
d337976 to
86f9ffb
Compare
Add `src/datatest::run_tests` (compiled only under `#[cfg(test)]`) for file-based filter tests. Pairs `<name>.<ext>` inputs with `<name>.after.<params>.<ext>` expected outputs; collects all failures before reporting. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add file-based test cases for the filter engine:
- tests/data/filter/rust.{rs,after.minimal.rs,after.aggressive.rs}
- tests/data/filter/python.{py,after.minimal.py,after.aggressive.py}
Wire up test_filter using datatest::run_tests("filter/*").
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
86f9ffb to
39afde0
Compare
Author
|
The failure report currently dumps full expected/actual blocks. A line-by-line diff would be much easier to read, but that requires adding a diff crate (e.g. |
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
src/datatest.rs: a lightweight data-driven test engine that discovers input/expected file pairs undertests/data/and runs them through a caller-supplied closure returning the actual outputtests/data/filter/covering the fullMinimalFilterandAggressiveFiltercodepaths, and wiresfilter::tests::test_filterto use itUpdate mode: set
RTK_UPDATE_TEST_DATA=1to overwrite expected files with the actual filter output instead of failing — useful when filter behaviour intentionally changes.Known filter quirks documented by the test data (noted for follow-up):
pub(crate)items are silently dropped by aggressive (pub\s+regex doesn't matchpub(crate)), but Python__internal_methodis kept — asymmetry between the two languages}is dropped from struct/mod bodies (brace depth tracking exits before emitting it)#[cfg(test)] mod testswrapper is dropped but its contents (use super::*, function signatures) are still emitted at the outer indentation levelunittest.TestCasesubclass are not dropped in Python either// ... implementationplaceholder is used for Python files (C-style comment)Test plan
cargo fmt --all && cargo clippy --all-targets && cargo testRTK_UPDATE_TEST_DATA=1 cargo test filter::tests::test_filter— verified update mode writes correct expected files, re-run confirms green