Mercurial > public > mercurial-scm > hg-stable
diff tests/run-tests.py @ 43837: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 | 3fe91bcd5199 |
children | bd3fa45c0662 |
line wrap: on
line diff
--- a/tests/run-tests.py Sat Dec 07 13:06:25 2019 -0800 +++ b/tests/run-tests.py Sat Dec 07 13:07:25 2019 -0800 @@ -1363,6 +1363,20 @@ if PYTHON3 and os.name == 'nt': env['PYTHONLEGACYWINDOWSSTDIO'] = '1' + # Modified HOME in test environment can confuse Rust tools. So set + # CARGO_HOME and RUSTUP_HOME automatically if a Rust toolchain is + # present and these variables aren't already defined. + cargo_home_path = os.path.expanduser('~/.cargo') + rustup_home_path = os.path.expanduser('~/.rustup') + + if os.path.exists(cargo_home_path) and b'CARGO_HOME' not in osenvironb: + env['CARGO_HOME'] = cargo_home_path + if ( + os.path.exists(rustup_home_path) + and b'RUSTUP_HOME' not in osenvironb + ): + env['RUSTUP_HOME'] = rustup_home_path + # Reset some environment variables to well-known values so that # the tests produce repeatable output. env['LANG'] = env['LC_ALL'] = env['LANGUAGE'] = 'C'