diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-09-07 11:02:22 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-09-07 11:02:22 -0700 |
commit | 46f74c189c95fc6a41daf8ded741e0cf5f5bed92 (patch) | |
tree | a901edf62f97757dca86660ecd4f3f6acb829f79 /tests/tests.rs | |
parent | 04f020bd00cdbaacc0e206fa783f546f6dd57e44 (diff) |
Just check for `rustfmt`; don't install it
Diffstat (limited to 'tests/tests.rs')
-rw-r--r-- | tests/tests.rs | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/tests/tests.rs b/tests/tests.rs index 43347a0c..1e02da2d 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -17,35 +17,26 @@ use options::builder_from_flags; // Run `rustfmt` on the given source string and return a tuple of the formatted // bindings, and rustfmt's stderr. fn rustfmt(source: String) -> (String, String) { - static INSTALL_RUSTFMT: Once = ONCE_INIT; + static CHECK_RUSTFMT: Once = ONCE_INIT; - INSTALL_RUSTFMT.call_once(|| { + CHECK_RUSTFMT.call_once(|| { let have_working_rustfmt = process::Command::new("rustup") .args(&["run", "nightly", "rustfmt", "--version"]) .stdout(process::Stdio::null()) .stderr(process::Stdio::null()) .status() - .expect("should run `rustup run nightly rustfmt --version` OK") - .success(); + .ok() + .map_or(false, |status| status.success()); - if have_working_rustfmt { - return; - } - - // Because `rustfmt` needs to match its exact nightly version, we update - // both at the same time. - - let status = process::Command::new("rustup") - .args(&["update", "nightly"]) - .status() - .expect("should run `rustup update nightly` OK"); - assert!(status.success(), "should run `rustup update nightly` OK"); + if !have_working_rustfmt { + panic!(" +The latest `rustfmt` is required to run the `bindgen` test suite. Install +`rustfmt` with: - let status = process::Command::new("rustup") - .args(&["run", "nightly", "cargo", "install", "-f", "rustfmt-nightly"]) - .status() - .expect("should run `rustup run nightly cargo install rustfmt-nightly` OK"); - assert!(status.success(), "should install rustfmt OK"); + $ rustup update nightly + $ rustup run nightly cargo install -f rustfmt-nightly +"); + } }); let mut child = process::Command::new("rustup") |