summaryrefslogtreecommitdiff
path: root/tests/tests.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2020-05-19 04:37:23 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2020-06-15 02:13:39 +0200
commitfc461b8ef72a93997d56e2df44d1b190b6594fad (patch)
tree7fae08b5de9309b463414b0e8c2f1611899adaba /tests/tests.rs
parent0de049e153f2c984ebbddfbe47381c9bc0818b5a (diff)
tests: Fix rustfmt check to allow for RUSTFMT env vars.
Diffstat (limited to 'tests/tests.rs')
-rw-r--r--tests/tests.rs27
1 files changed, 21 insertions, 6 deletions
diff --git a/tests/tests.rs b/tests/tests.rs
index 2b435e45..f4a768c0 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -26,8 +26,17 @@ fn rustfmt(source: String) -> (String, String) {
static CHECK_RUSTFMT: Once = Once::new();
CHECK_RUSTFMT.call_once(|| {
- let have_working_rustfmt = process::Command::new("rustup")
- .args(&["run", "nightly", "rustfmt", "--version"])
+ if env::var_os("RUSTFMT").is_some() {
+ return;
+ }
+
+ let mut rustfmt = {
+ let mut p = process::Command::new("rustup");
+ p.args(&["run", "nightly", "rustfmt", "--version"]);
+ p
+ };
+
+ let have_working_rustfmt = rustfmt
.stdout(process::Stdio::null())
.stderr(process::Stdio::null())
.status()
@@ -47,11 +56,17 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install
}
});
- let mut child = process::Command::new("rustup")
+ let mut child = match env::var_os("RUSTFMT") {
+ Some(r) => process::Command::new(r),
+ None => {
+ let mut p = process::Command::new("rustup");
+ p.args(&["run", "nightly", "rustfmt"]);
+ p
+ }
+ };
+
+ let mut child = child
.args(&[
- "run",
- "nightly",
- "rustfmt",
"--config-path",
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/rustfmt.toml"),
])