@@ -4,6 +4,7 @@ use crate::prelude::*;
4
4
use mdbook:: errors:: Result ;
5
5
use mdbook:: renderer:: { RenderContext , Renderer } ;
6
6
use snapbox:: IntoData ;
7
+ use std:: env;
7
8
use std:: fs:: File ;
8
9
use std:: sync:: { Arc , Mutex } ;
9
10
@@ -75,6 +76,49 @@ fn failing_command() {
75
76
} ) ;
76
77
}
77
78
79
+ // Test that renderer utilizes PATH to find mdbook-FOO executables.
80
+ #[ test]
81
+ fn renderer_utilizes_path ( ) {
82
+ let mut test = BookTest :: init ( |_| { } ) ;
83
+ test. rust_program (
84
+ "custom_directory/mdbook-in_path" ,
85
+ r#"
86
+ fn main() {
87
+ // Read from stdin to avoid random pipe failures on Linux.
88
+ use std::io::Read;
89
+ let mut s = String::new();
90
+ std::io::stdin().read_to_string(&mut s).unwrap();
91
+ println!("Hello World!");
92
+ }
93
+ "# ,
94
+ )
95
+ . change_file (
96
+ "book.toml" ,
97
+ "[output.in_path]\n \
98
+ ",
99
+ ) ;
100
+ let custom_directory_location = test. dir . join ( "custom_directory" ) ;
101
+
102
+ test. run ( "build" , |cmd| {
103
+ let current_path = env:: var ( "PATH" ) . unwrap_or_default ( ) ;
104
+ let mut paths = env:: split_paths ( & current_path) . collect :: < Vec < _ > > ( ) ;
105
+ paths. insert ( 0 , custom_directory_location. clone ( ) ) ;
106
+ let new_path = env:: join_paths ( paths) . unwrap ( ) ;
107
+ cmd. env ( "PATH" , new_path. into_string ( ) . unwrap ( ) ) ;
108
+
109
+ cmd. expect_stdout ( str![ [ r#"
110
+ Hello World!
111
+
112
+ "# ] ] )
113
+ . expect_stderr ( str![ [ r#"
114
+ [TIMESTAMP] [INFO] (mdbook::book): Book building has started
115
+ [TIMESTAMP] [INFO] (mdbook::book): Running the in_path backend
116
+ [TIMESTAMP] [INFO] (mdbook::renderer): Invoking the "in_path" renderer
117
+
118
+ "# ] ] ) ;
119
+ } ) ;
120
+ }
121
+
78
122
// Renderer command is missing.
79
123
#[ test]
80
124
fn missing_renderer ( ) {
0 commit comments