Skip to content

Commit 0e35bd8

Browse files
committed
Auto merge of #6739 - ehuss:hg-optional, r=dwijnand
Make `hg` optional for tests. `hg` isn't always available, make it optional. Failed on rust's CI: rust-lang/rust#59143 (comment)
2 parents dd76122 + 6d13bcc commit 0e35bd8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/testsuite/init.rs

+16
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::support;
22
use std::env;
33
use std::fs::{self, File};
44
use std::io::prelude::*;
5+
use std::process::Command;
56

67
use crate::support::{paths, Execs};
78

@@ -11,6 +12,18 @@ fn cargo_process(s: &str) -> Execs {
1112
execs
1213
}
1314

15+
fn mercurial_available() -> bool {
16+
let result = Command::new("hg")
17+
.arg("--version")
18+
.output()
19+
.map(|o| o.status.success())
20+
.unwrap_or(false);
21+
if !result {
22+
println!("`hg` not available, skipping test");
23+
}
24+
result
25+
}
26+
1427
#[test]
1528
fn simple_lib() {
1629
cargo_process("init --lib --vcs none --edition 2015")
@@ -467,6 +480,9 @@ fn terminating_newline_in_new_git_ignore() {
467480

468481
#[test]
469482
fn terminating_newline_in_new_mercurial_ignore() {
483+
if !mercurial_available() {
484+
return;
485+
}
470486
cargo_process("init --vcs hg --lib")
471487
.env("USER", "foo")
472488
.run();

0 commit comments

Comments
 (0)