Skip to content

Conversation

@nyurik
Copy link
Member

@nyurik nyurik commented Jan 7, 2026

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.

  • .dbc files are converted to .rs binary snapshots (update with just bless), and are later compiled to ensure the result is usable
  • In some cases, test files produce compilation errors - stored as snapshot files too, but without the corresponding .rs file
  • All compilation failures are store in the .stderr files. Warnings are treated as errors.
  • an entire opendbc repo 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___*.snap files.

@nyurik nyurik marked this pull request as ready for review January 10, 2026 23:18
@nyurik nyurik requested review from Copilot and trnila January 10, 2026 23:18
Copy link

Copilot AI left a 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.

@nyurik nyurik changed the title generate and compile all .dbc files from test repo chore: generate and compile all .dbc files from test repo Jan 10, 2026
@nyurik nyurik mentioned this pull request Jan 11, 2026
@nyurik nyurik requested a review from trnila January 11, 2026 19:47
@nyurik nyurik enabled auto-merge (squash) January 11, 2026 19:49
.unwrap_or_default()
.eq_ignore_ascii_case("dbc")
{
return None;
Copy link
Member

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 }
Copy link
Member

@trnila trnila Jan 11, 2026

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?

Copy link
Member Author

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

@nyurik
Copy link
Member Author

nyurik commented Jan 12, 2026

@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.

@nyurik nyurik requested a review from trnila January 12, 2026 06:36
@nyurik nyurik merged commit 33735dd into oxibus:main Jan 12, 2026
4 checks passed
@nyurik nyurik deleted the compile-tests branch January 12, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants