File tree Expand file tree Collapse file tree 5 files changed +21
-8
lines changed
Expand file tree Collapse file tree 5 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -242,13 +242,12 @@ impl MDBook {
242242 if let BookItem :: Chapter ( ref ch) = * item {
243243 if !ch. path . as_os_str ( ) . is_empty ( ) {
244244 let path = self . source_dir ( ) . join ( & ch. path ) ;
245- let content = utils:: fs:: file_to_string ( & path) ?;
246245 info ! ( "Testing file: {:?}" , path) ;
247246
248247 // write preprocessed file to tempdir
249248 let path = temp_dir. path ( ) . join ( & ch. path ) ;
250249 let mut tmpf = utils:: fs:: create_file ( & path) ?;
251- tmpf. write_all ( content. as_bytes ( ) ) ?;
250+ tmpf. write_all ( ch . content . as_bytes ( ) ) ?;
252251
253252 let output = Command :: new ( "rustdoc" )
254253 . arg ( & path)
Original file line number Diff line number Diff line change @@ -58,8 +58,11 @@ impl DummyBook {
5858 } ) ?;
5959
6060 let sub_pattern = if self . passing_test { "true" } else { "false" } ;
61- let file_containing_test = temp. path ( ) . join ( "src/first/nested.md" ) ;
62- replace_pattern_in_file ( & file_containing_test, "$TEST_STATUS" , sub_pattern) ?;
61+ let files_containing_tests = [ "src/first/nested.md" , "src/first/nested-test.rs" ] ;
62+ for file in & files_containing_tests {
63+ let path_containing_tests = temp. path ( ) . join ( file) ;
64+ replace_pattern_in_file ( & path_containing_tests, "$TEST_STATUS" , sub_pattern) ?;
65+ }
6366
6467 Ok ( temp)
6568 }
Original file line number Diff line number Diff line change 1+ assert ! ( $TEST_STATUS ) ;
Original file line number Diff line number Diff line change @@ -7,3 +7,7 @@ assert!($TEST_STATUS);
77```
88
99## Some Section
10+
11+ ``` rust
12+ {{#include nested - test . rs}}
13+ ```
Original file line number Diff line number Diff line change 4646 "title" : 2
4747 },
4848 "5" : {
49- "body" : 0 ,
49+ "body" : 1 ,
5050 "breadcrumbs" : 3 ,
5151 "title" : 1
5252 },
109109 "title" : " Nested Chapter"
110110 },
111111 "5" : {
112- "body" : " " ,
112+ "body" : " assert!(true); " ,
113113 "breadcrumbs" : " First Chapter » Some Section" ,
114114 "id" : " 5" ,
115115 "title" : " Some Section"
177177 "df" : 0 ,
178178 "docs" : {},
179179 "u" : {
180- "df" : 1 ,
180+ "df" : 2 ,
181181 "docs" : {
182182 "4" : {
183183 "tf" : 1.0
184+ },
185+ "5" : {
186+ "tf" : 1.0
184187 }
185188 }
186189 }
13361339 "df" : 0 ,
13371340 "docs" : {},
13381341 "u" : {
1339- "df" : 1 ,
1342+ "df" : 2 ,
13401343 "docs" : {
13411344 "4" : {
13421345 "tf" : 1.0
1346+ },
1347+ "5" : {
1348+ "tf" : 1.0
13431349 }
13441350 }
13451351 }
You can’t perform that action at this time.
0 commit comments