Skip to content

Commit 3fc682f

Browse files
Add test to check that renderer utilizes PATH
1 parent 74544f0 commit 3fc682f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/testsuite/renderer.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,48 @@ fn failing_command() {
7575
});
7676
}
7777

78+
// Test that renderer utilizes PATH to find mdbook-FOO executables.
79+
#[test]
80+
fn renderer_utilizes_path() {
81+
let mut test = BookTest::init(|_| {});
82+
test.rust_program(
83+
"custom_directory/mdbook-in_path",
84+
r#"
85+
fn main() {
86+
// Read from stdin to avoid random pipe failures on Linux.
87+
use std::io::Read;
88+
let mut s = String::new();
89+
std::io::stdin().read_to_string(&mut s).unwrap();
90+
println!("Hello World!");
91+
}
92+
"#,
93+
)
94+
.change_file(
95+
"book.toml",
96+
"[output.in_path]\n\
97+
",
98+
);
99+
let custom_directory_path = test
100+
.dir
101+
.join("custom_directory")
102+
.to_str()
103+
.unwrap()
104+
.to_string();
105+
test.run("build", |cmd| {
106+
cmd.env("PATH", format!("$PATH:{}", custom_directory_path));
107+
cmd.expect_stdout(str![[r#"
108+
Hello World!
109+
110+
"#]])
111+
.expect_stderr(str![[r#"
112+
[TIMESTAMP] [INFO] (mdbook::book): Book building has started
113+
[TIMESTAMP] [INFO] (mdbook::book): Running the in_path backend
114+
[TIMESTAMP] [INFO] (mdbook::renderer): Invoking the "in_path" renderer
115+
116+
"#]]);
117+
});
118+
}
119+
78120
// Renderer command is missing.
79121
#[test]
80122
fn missing_renderer() {

0 commit comments

Comments
 (0)