Skip to content

Commit fc461b8

Browse files
committed
tests: Fix rustfmt check to allow for RUSTFMT env vars.
1 parent 0de049e commit fc461b8

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

tests/tests.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@ fn rustfmt(source: String) -> (String, String) {
2626
static CHECK_RUSTFMT: Once = Once::new();
2727

2828
CHECK_RUSTFMT.call_once(|| {
29-
let have_working_rustfmt = process::Command::new("rustup")
30-
.args(&["run", "nightly", "rustfmt", "--version"])
29+
if env::var_os("RUSTFMT").is_some() {
30+
return;
31+
}
32+
33+
let mut rustfmt = {
34+
let mut p = process::Command::new("rustup");
35+
p.args(&["run", "nightly", "rustfmt", "--version"]);
36+
p
37+
};
38+
39+
let have_working_rustfmt = rustfmt
3140
.stdout(process::Stdio::null())
3241
.stderr(process::Stdio::null())
3342
.status()
@@ -47,11 +56,17 @@ The latest `rustfmt` is required to run the `bindgen` test suite. Install
4756
}
4857
});
4958

50-
let mut child = process::Command::new("rustup")
59+
let mut child = match env::var_os("RUSTFMT") {
60+
Some(r) => process::Command::new(r),
61+
None => {
62+
let mut p = process::Command::new("rustup");
63+
p.args(&["run", "nightly", "rustfmt"]);
64+
p
65+
}
66+
};
67+
68+
let mut child = child
5169
.args(&[
52-
"run",
53-
"nightly",
54-
"rustfmt",
5570
"--config-path",
5671
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/rustfmt.toml"),
5772
])

0 commit comments

Comments
 (0)