Merge pull request #891 from integer32llc/include-before-test
Write preprocessed content to file before testing with rustdoc
This commit is contained in:
commit
07830f7f11
|
@ -268,13 +268,12 @@ impl MDBook {
|
||||||
if let BookItem::Chapter(ref ch) = *item {
|
if let BookItem::Chapter(ref ch) = *item {
|
||||||
if !ch.path.as_os_str().is_empty() {
|
if !ch.path.as_os_str().is_empty() {
|
||||||
let path = self.source_dir().join(&ch.path);
|
let path = self.source_dir().join(&ch.path);
|
||||||
let content = utils::fs::file_to_string(&path)?;
|
|
||||||
info!("Testing file: {:?}", path);
|
info!("Testing file: {:?}", path);
|
||||||
|
|
||||||
// write preprocessed file to tempdir
|
// write preprocessed file to tempdir
|
||||||
let path = temp_dir.path().join(&ch.path);
|
let path = temp_dir.path().join(&ch.path);
|
||||||
let mut tmpf = utils::fs::create_file(&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")
|
let output = Command::new("rustdoc")
|
||||||
.arg(&path)
|
.arg(&path)
|
||||||
|
|
|
@ -53,8 +53,11 @@ impl DummyBook {
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let sub_pattern = if self.passing_test { "true" } else { "false" };
|
let sub_pattern = if self.passing_test { "true" } else { "false" };
|
||||||
let file_containing_test = temp.path().join("src/first/nested.md");
|
let files_containing_tests = ["src/first/nested.md", "src/first/nested-test.rs"];
|
||||||
replace_pattern_in_file(&file_containing_test, "$TEST_STATUS", sub_pattern)?;
|
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)
|
Ok(temp)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
assert!($TEST_STATUS);
|
|
@ -7,3 +7,7 @@ assert!($TEST_STATUS);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Some Section
|
## Some Section
|
||||||
|
|
||||||
|
```rust
|
||||||
|
{{#include nested-test.rs}}
|
||||||
|
```
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
"title": 2
|
"title": 2
|
||||||
},
|
},
|
||||||
"5": {
|
"5": {
|
||||||
"body": 0,
|
"body": 1,
|
||||||
"breadcrumbs": 3,
|
"breadcrumbs": 3,
|
||||||
"title": 1
|
"title": 1
|
||||||
},
|
},
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
"title": "Nested Chapter"
|
"title": "Nested Chapter"
|
||||||
},
|
},
|
||||||
"5": {
|
"5": {
|
||||||
"body": "",
|
"body": "assert!(true);",
|
||||||
"breadcrumbs": "First Chapter » Some Section",
|
"breadcrumbs": "First Chapter » Some Section",
|
||||||
"id": "5",
|
"id": "5",
|
||||||
"title": "Some Section"
|
"title": "Some Section"
|
||||||
|
@ -269,10 +269,13 @@
|
||||||
"df": 0,
|
"df": 0,
|
||||||
"docs": {},
|
"docs": {},
|
||||||
"u": {
|
"u": {
|
||||||
"df": 1,
|
"df": 2,
|
||||||
"docs": {
|
"docs": {
|
||||||
"4": {
|
"4": {
|
||||||
"tf": 1.0
|
"tf": 1.0
|
||||||
|
},
|
||||||
|
"5": {
|
||||||
|
"tf": 1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1872,10 +1875,13 @@
|
||||||
"df": 0,
|
"df": 0,
|
||||||
"docs": {},
|
"docs": {},
|
||||||
"u": {
|
"u": {
|
||||||
"df": 1,
|
"df": 2,
|
||||||
"docs": {
|
"docs": {
|
||||||
"4": {
|
"4": {
|
||||||
"tf": 1.0
|
"tf": 1.0
|
||||||
|
},
|
||||||
|
"5": {
|
||||||
|
"tf": 1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue