summaryrefslogtreecommitdiffstats
path: root/vendor/mdbook/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/mdbook/tests')
-rw-r--r--vendor/mdbook/tests/cli/test.rs20
-rw-r--r--vendor/mdbook/tests/init.rs2
-rw-r--r--vendor/mdbook/tests/testing.rs21
3 files changed, 32 insertions, 11 deletions
diff --git a/vendor/mdbook/tests/cli/test.rs b/vendor/mdbook/tests/cli/test.rs
index bc525d9a9..63114d3a1 100644
--- a/vendor/mdbook/tests/cli/test.rs
+++ b/vendor/mdbook/tests/cli/test.rs
@@ -10,11 +10,11 @@ fn mdbook_cli_can_correctly_test_a_passing_book() {
let mut cmd = mdbook_cmd();
cmd.arg("test").current_dir(temp.path());
cmd.assert().success()
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]intro.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]first[\\/]index.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]first[\\/]nested.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"rustdoc returned an error:\n\n"##).unwrap().not())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "README.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "intro.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "first[\\/]index.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "first[\\/]nested.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"returned an error:\n\n"##).unwrap().not())
.stderr(predicates::str::is_match(r##"Nested_Chapter::Rustdoc_include_works_with_anchors_too \(line \d+\) ... FAILED"##).unwrap().not());
}
@@ -25,10 +25,10 @@ fn mdbook_cli_detects_book_with_failing_tests() {
let mut cmd = mdbook_cmd();
cmd.arg("test").current_dir(temp.path());
cmd.assert().failure()
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]intro.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]first[\\/]index.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]first[\\/]nested.md""##).unwrap())
- .stderr(predicates::str::is_match(r##"rustdoc returned an error:\n\n"##).unwrap())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "README.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "intro.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "first[\\/]index.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"Testing chapter [^:]*: "first[\\/]nested.md""##).unwrap())
+ .stderr(predicates::str::is_match(r##"returned an error:\n\n"##).unwrap())
.stderr(predicates::str::is_match(r##"Nested_Chapter::Rustdoc_include_works_with_anchors_too \(line \d+\) ... FAILED"##).unwrap());
}
diff --git a/vendor/mdbook/tests/init.rs b/vendor/mdbook/tests/init.rs
index 4deb84019..1c3b962b5 100644
--- a/vendor/mdbook/tests/init.rs
+++ b/vendor/mdbook/tests/init.rs
@@ -95,7 +95,7 @@ fn run_mdbook_init_with_custom_book_and_src_locations() {
let contents = fs::read_to_string(temp.path().join("book.toml")).unwrap();
assert_eq!(
contents,
- "[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nuse-default-preprocessors = true\n"
+ "[book]\nauthors = []\nlanguage = \"en\"\nmultilingual = false\nsrc = \"in\"\n\n[build]\nbuild-dir = \"out\"\ncreate-missing = true\nextra-watch-dirs = []\nuse-default-preprocessors = true\n"
);
}
diff --git a/vendor/mdbook/tests/testing.rs b/vendor/mdbook/tests/testing.rs
index 2b2c0fd0d..3030c5cb6 100644
--- a/vendor/mdbook/tests/testing.rs
+++ b/vendor/mdbook/tests/testing.rs
@@ -24,3 +24,24 @@ fn mdbook_detects_book_with_failing_tests() {
assert!(md.test(vec![]).is_err());
}
+
+#[test]
+fn mdbook_test_chapter() {
+ let temp = DummyBook::new().with_passing_test(true).build().unwrap();
+ let mut md = MDBook::load(temp.path()).unwrap();
+
+ let result = md.test_chapter(vec![], Some("Introduction"));
+ assert!(
+ result.is_ok(),
+ "test_chapter failed with {}",
+ result.err().unwrap()
+ );
+}
+
+#[test]
+fn mdbook_test_chapter_not_found() {
+ let temp = DummyBook::new().with_passing_test(true).build().unwrap();
+ let mut md = MDBook::load(temp.path()).unwrap();
+
+ assert!(md.test_chapter(vec![], Some("Bogus Chapter Name")).is_err());
+}