As pointed out by @flip1995 in https://github.com/rust-lang/rust-clippy/pull/3824#r261652006, we currently don't have an easy way to run rustfmt on the tests locally like we do on CI.
What we are doing on CI currently:
It would be nice if we could extract that into a separate script so that people can use to format their tests locally, instead of waiting for CI.
Some things to consider when doing this:
rustfmt component if it isn't present locallyrustfmt instead of cargo fmt for the test formatting because of https://github.com/rust-lang/rustfmt/issues/1820master)rustup override set nightly, because that doesn't update the locally installed nightly rust. We should probably pin to a specific nightly instead and update the version from time to time.If we want to provide a cargo format subcommand instead of a shell script, then it might also be worth to look at how rust-analyzer did it: https://github.com/rust-analyzer/rust-analyzer/pull/163.
I'm working on adding a clippy dev subcommand to do this.
I'm don't think the command should install/update toolchains/components by default (especially if we want to run it from a test) but I'll provide an option to do that and error out if the required toolchains/components aren't installed and up to date.
friendly ping @mikerite: did you make some progress on this?
Thanks for the ping.
I didn't get very far and I haven't looked at this in weeks. It's fine by me if someone else wants to do this. Otherwise, I'll try to make some progress this weekend.
I've got something ready but I'll wait until the build is fixed before submitting the PR.
Closing this - thanks to @mikerite we now have util/dev fmt which has been working great :confetti_ball:
Most helpful comment
I'm working on adding a clippy dev subcommand to do this.
I'm don't think the command should install/update toolchains/components by default (especially if we want to run it from a test) but I'll provide an option to do that and error out if the required toolchains/components aren't installed and up to date.