lowRISC / opentitan

OpenTitan: Open source silicon root of trust
https://www.opentitan.org
Apache License 2.0
2.6k stars 783 forks source link

[tock] rustfmt_fix fails with a missing tests module #22737

Open kupiakos opened 7 months ago

kupiakos commented 7 months ago

Description

$ bazel run //quality:rustfmt_fix
INFO: Analyzed target //quality:rustfmt_fix (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
INFO: Elapsed time: 0.881s, Critical Path: 0.38s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/quality/rustfmt_fix.bash
Error writing files: failed to resolve mod `tests`: <opentitan dir>/sw/device/silicon_owner/tock/kernel/src/tests.rs does not exist

The described file indeed does not exist. If it's supposed to be autogenerated by something A) it's discouraged to put generated files next to non-generated files for reasons like this and B) it should be a (transitive) dependency of the rustfmt_fix rule.

jrvanwhy commented 7 months ago

That file is not supposed to exist; that code was copied out of another repository (Tock) but the tests were not copied over as they are not compatible with our test infrastructure. We don't expect it to compile with --cfg test.

It looks like there is significant divergence between rustfmt_check and rustfmt_fix. In addition to the above error, rustfmt_fix currently makes changes to files even when rustfmt_check passes (tested on both master and earlgrey_es_sival).

pamaury commented 7 months ago

This is a known issue, I have pending PRs that fix the rustfmt_check and also can take care of this issue with the module but this is low priority: https://github.com/lowRISC/rules_rust/pull/5 and https://github.com/lowRISC/opentitan/pull/21631

vbendeb commented 7 months ago

That file is not supposed to exist; that code was copied out of another repository (Tock) but the tests were not copied over as they are not compatible with our test infrastructure. We don't expect it to compile with --cfg test.

It looks like there is significant divergence between rustfmt_check and rustfmt_fix. In addition to the above error, rustfmt_fix currently makes changes to files even when rustfmt_check passes (tested on both master and earlgrey_es_sival).

with this in mind I'm going to upload a PR removing the test reference from main.rs