Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,12 @@ impl MDBook {
if let BookItem::Chapter(ref ch) = *item {
if !ch.path.as_os_str().is_empty() {
let path = self.source_dir().join(&ch.path);
let content = utils::fs::file_to_string(&path)?;
info!("Testing file: {:?}", path);

// write preprocessed file to tempdir
let path = temp_dir.path().join(&ch.path);
let mut tmpf = utils::fs::create_file(&path)?;
tmpf.write_all(content.as_bytes())?;
tmpf.write_all(ch.content.as_bytes())?;

let output = Command::new("rustdoc")
.arg(&path)
Expand Down
7 changes: 5 additions & 2 deletions tests/dummy_book/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ impl DummyBook {
})?;

let sub_pattern = if self.passing_test { "true" } else { "false" };
let file_containing_test = temp.path().join("src/first/nested.md");
replace_pattern_in_file(&file_containing_test, "$TEST_STATUS", sub_pattern)?;
let files_containing_tests = ["src/first/nested.md", "src/first/nested-test.rs"];
for file in &files_containing_tests {
let path_containing_tests = temp.path().join(file);
replace_pattern_in_file(&path_containing_tests, "$TEST_STATUS", sub_pattern)?;
}

Ok(temp)
}
Expand Down
1 change: 1 addition & 0 deletions tests/dummy_book/src/first/nested-test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assert!($TEST_STATUS);
4 changes: 4 additions & 0 deletions tests/dummy_book/src/first/nested.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ assert!($TEST_STATUS);
```

## Some Section

```rust
{{#include nested-test.rs}}
```
14 changes: 10 additions & 4 deletions tests/searchindex_fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"title": 2
},
"5": {
"body": 0,
"body": 1,
"breadcrumbs": 3,
"title": 1
},
Expand Down Expand Up @@ -109,7 +109,7 @@
"title": "Nested Chapter"
},
"5": {
"body": "",
"body": "assert!(true);",
"breadcrumbs": "First Chapter » Some Section",
"id": "5",
"title": "Some Section"
Expand Down Expand Up @@ -177,10 +177,13 @@
"df": 0,
"docs": {},
"u": {
"df": 1,
"df": 2,
"docs": {
"4": {
"tf": 1.0
},
"5": {
"tf": 1.0
}
}
}
Expand Down Expand Up @@ -1336,10 +1339,13 @@
"df": 0,
"docs": {},
"u": {
"df": 1,
"df": 2,
"docs": {
"4": {
"tf": 1.0
},
"5": {
"tf": 1.0
}
}
}
Expand Down