Skip to content

Commit

Permalink
Auto merge of #6739 - ehuss:hg-optional, r=dwijnand
Browse files Browse the repository at this point in the history
Make `hg` optional for tests.

`hg` isn't always available, make it optional.

Failed on rust's CI: rust-lang/rust#59143 (comment)
  • Loading branch information
bors committed Mar 13, 2019
2 parents dd76122 + 6d13bcc commit 0e35bd8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/testsuite/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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")
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 0e35bd8

Please sign in to comment.