diff options
Diffstat (limited to 'vendor/mdbook/tests/cli')
-rw-r--r-- | vendor/mdbook/tests/cli/build.rs | 28 | ||||
-rw-r--r-- | vendor/mdbook/tests/cli/cmd.rs | 7 | ||||
-rw-r--r-- | vendor/mdbook/tests/cli/mod.rs | 3 | ||||
-rw-r--r-- | vendor/mdbook/tests/cli/test.rs | 34 |
4 files changed, 72 insertions, 0 deletions
diff --git a/vendor/mdbook/tests/cli/build.rs b/vendor/mdbook/tests/cli/build.rs new file mode 100644 index 000000000..0daba9d72 --- /dev/null +++ b/vendor/mdbook/tests/cli/build.rs @@ -0,0 +1,28 @@ +use crate::cli::cmd::mdbook_cmd; +use crate::dummy_book::DummyBook; + +#[test] +fn mdbook_cli_dummy_book_generates_index_html() { + let temp = DummyBook::new().build().unwrap(); + + // doesn't exist before + assert!(!temp.path().join("book").exists()); + + let mut cmd = mdbook_cmd(); + cmd.arg("build").current_dir(temp.path()); + cmd.assert() + .success() + .stderr( + predicates::str::is_match(r##"Stack depth exceeded in first[\\/]recursive.md."##) + .unwrap(), + ) + .stderr(predicates::str::contains( + r##"[INFO] (mdbook::book): Running the html backend"##, + )); + + // exists afterward + assert!(temp.path().join("book").exists()); + + let index_file = temp.path().join("book/index.html"); + assert!(index_file.exists()); +} diff --git a/vendor/mdbook/tests/cli/cmd.rs b/vendor/mdbook/tests/cli/cmd.rs new file mode 100644 index 000000000..a612f3ad2 --- /dev/null +++ b/vendor/mdbook/tests/cli/cmd.rs @@ -0,0 +1,7 @@ +use assert_cmd::Command; + +pub(crate) fn mdbook_cmd() -> Command { + let mut cmd = Command::cargo_bin("mdbook").unwrap(); + cmd.env_remove("RUST_LOG"); + cmd +} diff --git a/vendor/mdbook/tests/cli/mod.rs b/vendor/mdbook/tests/cli/mod.rs new file mode 100644 index 000000000..989f443f0 --- /dev/null +++ b/vendor/mdbook/tests/cli/mod.rs @@ -0,0 +1,3 @@ +mod build; +mod cmd; +mod test; diff --git a/vendor/mdbook/tests/cli/test.rs b/vendor/mdbook/tests/cli/test.rs new file mode 100644 index 000000000..bc525d9a9 --- /dev/null +++ b/vendor/mdbook/tests/cli/test.rs @@ -0,0 +1,34 @@ +use crate::cli::cmd::mdbook_cmd; +use crate::dummy_book::DummyBook; + +use predicates::boolean::PredicateBooleanExt; + +#[test] +fn mdbook_cli_can_correctly_test_a_passing_book() { + let temp = DummyBook::new().with_passing_test(true).build().unwrap(); + + 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##"Nested_Chapter::Rustdoc_include_works_with_anchors_too \(line \d+\) ... FAILED"##).unwrap().not()); +} + +#[test] +fn mdbook_cli_detects_book_with_failing_tests() { + let temp = DummyBook::new().with_passing_test(false).build().unwrap(); + + 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##"Nested_Chapter::Rustdoc_include_works_with_anchors_too \(line \d+\) ... FAILED"##).unwrap()); +} |