Skip to content

Commit d48810f

Browse files
authored
Merge pull request #2307 from ehuss/backends_receive_render_context_via_stdin
Clean up test backends_receive_render_context_via_stdin
2 parents 7825bd6 + 3387cf3 commit d48810f

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

tests/alternative_backends.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,27 @@ fn alternate_backend_with_arguments() {
3939
md.build().unwrap();
4040
}
4141

42-
/// Get a command which will pipe `stdin` to the provided file.
43-
#[cfg(not(windows))]
44-
fn tee_command<P: AsRef<Path>>(out_file: P) -> String {
45-
let out_file = out_file.as_ref();
46-
47-
if cfg!(windows) {
48-
format!("cmd.exe /c \"type > {}\"", out_file.display())
49-
} else {
50-
format!("tee {}", out_file.display())
51-
}
52-
}
53-
5442
#[test]
55-
#[cfg(not(windows))]
5643
fn backends_receive_render_context_via_stdin() {
5744
use mdbook::renderer::RenderContext;
5845
use std::fs::File;
5946

60-
let temp = TempFileBuilder::new().prefix("output").tempdir().unwrap();
61-
let out_file = temp.path().join("out.txt");
62-
let cmd = tee_command(&out_file);
47+
let (md, temp) = dummy_book_with_backend("cat-to-file", "renderers/myrenderer", false);
48+
49+
let renderers = temp.path().join("renderers");
50+
fs::create_dir(&renderers).unwrap();
51+
rust_exe(
52+
&renderers,
53+
"myrenderer",
54+
r#"fn main() {
55+
use std::io::Read;
56+
let mut s = String::new();
57+
std::io::stdin().read_to_string(&mut s).unwrap();
58+
std::fs::write("out.txt", s).unwrap();
59+
}"#,
60+
);
6361

64-
let (md, _temp) = dummy_book_with_backend("cat-to-file", &cmd, false);
62+
let out_file = temp.path().join("book/out.txt");
6563

6664
assert!(!out_file.exists());
6765
md.build().unwrap();

0 commit comments

Comments
 (0)