diff --git a/tests/cli/build.rs b/tests/cli/build.rs new file mode 100644 index 0000000000..16b6b79bdd --- /dev/null +++ b/tests/cli/build.rs @@ -0,0 +1,29 @@ +use crate::dummy_book::DummyBook; + +use assert_cmd::Command; + +#[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 = Command::cargo_bin("mdbook").unwrap(); + 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/tests/cli/mod.rs b/tests/cli/mod.rs new file mode 100644 index 0000000000..a73a40314b --- /dev/null +++ b/tests/cli/mod.rs @@ -0,0 +1,2 @@ +mod build; +mod test; diff --git a/tests/cli.rs b/tests/cli/test.rs similarity index 70% rename from tests/cli.rs rename to tests/cli/test.rs index 9fc8b498c1..d974654d99 100644 --- a/tests/cli.rs +++ b/tests/cli/test.rs @@ -1,5 +1,3 @@ -mod dummy_book; - use crate::dummy_book::DummyBook; use assert_cmd::Command; @@ -34,29 +32,3 @@ fn mdbook_cli_detects_book_with_failing_tests() { .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()); } - -#[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 = Command::cargo_bin("mdbook").unwrap(); - 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/tests/cli_tests.rs b/tests/cli_tests.rs new file mode 100644 index 0000000000..0b005d0197 --- /dev/null +++ b/tests/cli_tests.rs @@ -0,0 +1,2 @@ +mod cli; +mod dummy_book;