-
Notifications
You must be signed in to change notification settings - Fork 45
chore: generate and compile all .dbc files from test repo #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR integrates test files from the shared-test-files repository as a submodule to enhance test coverage. The changes add multiple DBC (Database Container) file test snapshots from the cantools issue tracker, generating Rust code for various CAN message scenarios including multiplexing, extended IDs, and edge cases.
Changes:
- Added snapshot test files for various cantools issues (issue_63, issue_62, issue_228, issue_207, issue_199, issue_184 variants)
- Generated corresponding Rust code (.snap.rs files) from DBC definitions
- Created snapshot metadata files (.snap) for test verification
Reviewed changes
Copilot reviewed 85 out of 166 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test-snapshots/dbc-cantools/issue_636_negative_scaling.snap | Snapshot metadata for negative scaling test case |
| test-snapshots/dbc-cantools/issue_63.snap.rs | Generated Rust code for AFT1PSI2 message with multiple signal types |
| test-snapshots/dbc-cantools/issue_63.snap | Snapshot metadata for issue 63 |
| test-snapshots/dbc-cantools/issue_62.snap.rs | Generated Rust code for empty messages enum |
| test-snapshots/dbc-cantools/issue_62.snap | Snapshot metadata for issue 62 |
| test-snapshots/dbc-cantools/issue_228.snap.rs | Generated Rust code for signed signal handling (SGMsg, NormalMsg) |
| test-snapshots/dbc-cantools/issue_228.snap | Snapshot metadata for issue 228 |
| test-snapshots/dbc-cantools/issue_207_sig_plus.snap.rs | Generated Rust code for signals with plus notation |
| test-snapshots/dbc-cantools/issue_207_sig_plus.snap | Snapshot metadata for sig_plus variant |
| test-snapshots/dbc-cantools/issue_199_extended.snap.rs | Generated Rust code for extended CAN IDs with vehicle control messages |
| test-snapshots/dbc-cantools/issue_199_extended.snap | Snapshot metadata for extended variant |
| test-snapshots/dbc-cantools/issue_199.snap.rs | Generated Rust code for standard CAN IDs with vehicle control messages |
| test-snapshots/dbc-cantools/issue_199.snap | Snapshot metadata for issue 199 |
| test-snapshots/dbc-cantools/issue_184_extended_mux_multiple_values_dumped.snap.rs | Generated Rust code for extended multiplexing with multiple values (dumped variant) |
| test-snapshots/dbc-cantools/issue_184_extended_mux_multiple_values_dumped.snap | Snapshot metadata for dumped variant |
| test-snapshots/dbc-cantools/issue_184_extended_mux_multiple_values.snap.rs | Generated Rust code for extended multiplexing with multiple values |
| test-snapshots/dbc-cantools/issue_184_extended_mux_multiple_values.snap | Snapshot metadata for multiple values variant |
| test-snapshots/dbc-cantools/issue_184_extended_mux_independent_multiplexors_dumped.snap.rs | Generated Rust code for independent multiplexors (dumped variant) |
| test-snapshots/dbc-cantools/issue_184_extended_mux_independent_multiplexors_dumped.snap | Snapshot metadata for dumped multiplexors |
| test-snapshots/dbc-cantools/issue_184_extended_mux_independent_multiplexors.snap.rs | Generated Rust code for independent multiplexors |
| test-snapshots/dbc-cantools/issue_184_extended_mux_independent_multiplexors.snap | Snapshot metadata for independent multiplexors |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/snapshots.rs
Outdated
| .unwrap_or_default() | ||
| .eq_ignore_ascii_case("dbc") | ||
| { | ||
| return None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the extension is not dbc? test_each_path as its currently used, should ensure we have only dbcs?
| }, | ||
| ]; | ||
|
|
||
| test_each_path! { for ["dbc"] in "./tests/fixtures/opendbc/opendbc/dbc" as dbc => parse_one_file } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could specify test info directly?
Something like:
test_each_path! { for ["dbc"] in "./tests/fixtures/opendbc/opendbc/dbc" as dbc => |path: &Path| {parse_one_file(path, TEST_DIRS[0])} }
... then we dont need reverse lookups from path to test config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets keep this macro call simple -- test_each_path is a bit hacky as is, esp with the weird for syntax - so the simpler it is the better. Besides, I modified the test case lookup - so it is cleaner now
|
@trnila I cleaned up tests a bit more. The code here is actually almost identical to what I added to both can-dbc and can-dbc-pest -- because all 3 repos have identical test cases (as submodules), and they all require similar steps to evaluate. Moreover, in all cases I need to handle the large production .dbc files differently - because they are too large, and I do not want to store giant snapshots in the git repos. Instead, I make sure the large .dbc pass all tests, but they do not get stored. |
This PR adds https://github.com/oxibus/shared-test-files as a submodule and uses them for testing -- similar to can-dbc and can-dbc-pest repos. Note that there is a minor change to the lib.rs to handle missing signal name - rather than crashing. Other than that, the goal of this PR is NOT to fix issues, but to record the status quo. This way any changes to the generation logic will be clearly visible in the test files.
.dbcfiles are converted to .rs binary snapshots (update withjust bless), and are later compiled to ensure the result is usable.stderrfiles. Warnings are treated as errors.opendbcrepo is also used as a test case, but due to the size, the files are only used for generation testing, not compilation. All errors are saved as!error___*.snapfiles.