( )⚙ D7579 tests: add test for Rust formatting

This is an archive of the discontinued Mercurial Phabricator instance.

tests: add test for Rust formatting
ClosedPublic

Authored by indygreg on Dec 7 2019, 4:11 PM.

Details

Summary

We enforce formatting for Python and C. It makes sense to do it
for Rust as well.

Since our rustfmt.toml relies on unstable rustfmt features, we
need to use a Nightly rustfmt with --unstable-features in order
for it to work. This is a bit hacky and I would prefer we remove
this requirement. But for now, this commit assumes this is the
way things must be and we go out of our way to detect and use the
rustfmt from the "nightly" toolchain, as installed via rustup.

We had to add some environment variables to the tests to make
the Rust binaries happy. Otherwise when running rustfmt we get
an error about no default toolchain being installed.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Dec 7 2019, 4:11 PM
Alphare added a subscriber: Alphare.Dec 9 2019, 8:15 AM

While I am not a huge fan of the use of a nightly toolchain, I like the fact that we get the latest features and behavior as rustfmt is still pre-1.0 and subject to change. So far, it has been nice to us and has not broken anything I can recall, I vote for keeping it that way until it reaches 1.0.

Alphare accepted this revision.Dec 9 2019, 8:15 AM
pulkit accepted this revision.Dec 10 2019, 9:57 AM
This revision is now accepted and ready to land.Dec 10 2019, 9:57 AM
This revision was automatically updated to reflect the committed changes.

What are we depending on in the rustfmt settings that's nightly behavior?

What are we depending on in the rustfmt settings that's nightly behavior?

wrap_comments = true
error_on_line_overflow = true

Both depend on nightly. I can live without error_on_line_overflow, wrap_comments is pretty neat.