Make failing_alternate_backend test more platform specific

Use the suggestion from @Michael-F-Bryan to make the passing_ and
failing_alternate_backend test more reliable across platforms.
This commit is contained in:
Bas Bossink 2018-12-05 22:26:53 +01:00
parent 3f002979c4
commit 3598e905aa
1 changed files with 18 additions and 2 deletions

View File

@ -11,14 +11,14 @@ use tempfile::{Builder as TempFileBuilder, TempDir};
#[test]
fn passing_alternate_backend() {
let (md, _temp) = dummy_book_with_backend("passing", "true");
let (md, _temp) = dummy_book_with_backend("passing", success_cmd());
md.build().unwrap();
}
#[test]
fn failing_alternate_backend() {
let (md, _temp) = dummy_book_with_backend("failing", "false");
let (md, _temp) = dummy_book_with_backend("failing", fail_cmd());
md.build().unwrap_err();
}
@ -84,3 +84,19 @@ fn dummy_book_with_backend(name: &str, command: &str) -> (MDBook, TempDir) {
(md, temp)
}
fn fail_cmd() -> &'static str {
if cfg!(windows) {
r#"cmd.exe /c "exit 1""#
} else {
"false"
}
}
fn success_cmd() -> &'static str {
if cfg!(windows) {
r#"cmd.exe /c "exit 0""#
} else {
"true"
}
}