Make hg optional for tests.

This commit is contained in:
Eric Huss 2019-03-12 20:52:38 -07:00
parent dd761226d9
commit 6d13bcce44

View File

@ -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();