diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index 1e1e3c85495..2495eff8011 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -2,6 +2,7 @@ use crate::support; use std::env; use std::fs::{self, File}; use std::io::prelude::*; +use std::process::Command; use crate::support::{paths, Execs}; @@ -11,6 +12,18 @@ fn cargo_process(s: &str) -> Execs { execs } +fn mercurial_available() -> bool { + let result = Command::new("hg") + .arg("--version") + .output() + .map(|o| o.status.success()) + .unwrap_or(false); + if !result { + println!("`hg` not available, skipping test"); + } + result +} + #[test] fn simple_lib() { cargo_process("init --lib --vcs none --edition 2015") @@ -467,6 +480,9 @@ fn terminating_newline_in_new_git_ignore() { #[test] fn terminating_newline_in_new_mercurial_ignore() { + if !mercurial_available() { + return; + } cargo_process("init --vcs hg --lib") .env("USER", "foo") .run();