Skip to content

Commit a5ccc64

Browse files
Added a windows-specific tee equivalent
1 parent 80f4267 commit a5ccc64

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/alternate_backends.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ extern crate mdbook;
44
extern crate tempdir;
55

66
use std::fs::File;
7+
use std::path::Path;
78
use tempdir::TempDir;
89
use mdbook::config::Config;
910
use mdbook::MDBook;
@@ -30,11 +31,22 @@ fn alternate_backend_with_arguments() {
3031
md.build().unwrap();
3132
}
3233

34+
/// Get a command which will pipe `stdin` to the provided file.
35+
fn tee_command<P: AsRef<Path>>(out_file: P) -> String {
36+
let out_file = out_file.as_ref();
37+
38+
if cfg!(windows) {
39+
format!("cmd.exe /c type ^> \"{}\"", out_file.display())
40+
} else {
41+
format!("tee {}", out_file.display())
42+
}
43+
}
44+
3345
#[test]
3446
fn backends_receive_render_context_via_stdin() {
3547
let temp = TempDir::new("output").unwrap();
3648
let out_file = temp.path().join("out.txt");
37-
let cmd = format!("tee {}", out_file.display());
49+
let cmd = tee_command(&out_file);
3850

3951
let (md, _temp) = dummy_book_with_backend("cat-to-file", &cmd);
4052

0 commit comments

Comments
 (0)