comparison tests/run-tests.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 3fe91bcd5199
children bd3fa45c0662
comparison
equal deleted inserted replaced
43818:ce088b38f92b 43819:e8a3bbffdc7d
1360 # This has the same effect as Py_LegacyWindowsStdioFlag in exewrapper.c, 1360 # This has the same effect as Py_LegacyWindowsStdioFlag in exewrapper.c,
1361 # but this is needed for testing python instances like dummyssh, 1361 # but this is needed for testing python instances like dummyssh,
1362 # dummysmtpd.py, and dumbhttp.py. 1362 # dummysmtpd.py, and dumbhttp.py.
1363 if PYTHON3 and os.name == 'nt': 1363 if PYTHON3 and os.name == 'nt':
1364 env['PYTHONLEGACYWINDOWSSTDIO'] = '1' 1364 env['PYTHONLEGACYWINDOWSSTDIO'] = '1'
1365
1366 # Modified HOME in test environment can confuse Rust tools. So set
1367 # CARGO_HOME and RUSTUP_HOME automatically if a Rust toolchain is
1368 # present and these variables aren't already defined.
1369 cargo_home_path = os.path.expanduser('~/.cargo')
1370 rustup_home_path = os.path.expanduser('~/.rustup')
1371
1372 if os.path.exists(cargo_home_path) and b'CARGO_HOME' not in osenvironb:
1373 env['CARGO_HOME'] = cargo_home_path
1374 if (
1375 os.path.exists(rustup_home_path)
1376 and b'RUSTUP_HOME' not in osenvironb
1377 ):
1378 env['RUSTUP_HOME'] = rustup_home_path
1365 1379
1366 # Reset some environment variables to well-known values so that 1380 # Reset some environment variables to well-known values so that
1367 # the tests produce repeatable output. 1381 # the tests produce repeatable output.
1368 env['LANG'] = env['LC_ALL'] = env['LANGUAGE'] = 'C' 1382 env['LANG'] = env['LC_ALL'] = env['LANGUAGE'] = 'C'
1369 env['TZ'] = 'GMT' 1383 env['TZ'] = 'GMT'