Mercurial > hg
comparison tests/hghave.py @ 43819:e8a3bbffdc7d
tests: add test for Rust formatting
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.
Differential Revision: https://phab.mercurial-scm.org/D7579
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 07 Dec 2019 13:07:25 -0800 |
parents | 21e05aabef8c |
children | 5b38c2ab6ad3 |
comparison
equal
deleted
inserted
replaced
43818:ce088b38f92b | 43819:e8a3bbffdc7d |
---|---|
1013 def has_pytype(): | 1013 def has_pytype(): |
1014 pytypecmd = 'pytype --version' | 1014 pytypecmd = 'pytype --version' |
1015 version = matchoutput(pytypecmd, b'[0-9a-b.]+') | 1015 version = matchoutput(pytypecmd, b'[0-9a-b.]+') |
1016 sv = distutils.version.StrictVersion | 1016 sv = distutils.version.StrictVersion |
1017 return version and sv(_strpath(version.group(0))) >= sv('2019.10.17') | 1017 return version and sv(_strpath(version.group(0))) >= sv('2019.10.17') |
1018 | |
1019 | |
1020 @check("rustfmt", "rustfmt tool") | |
1021 def has_rustfmt(): | |
1022 # We use Nightly's rustfmt due to current unstable config options. | |
1023 return matchoutput( | |
1024 '`rustup which --toolchain nightly rustfmt` --version', b'rustfmt' | |
1025 ) |