Move cli tests to their own subdir

This commit is contained in:
Michael Howell 2021-07-29 14:42:54 -07:00 committed by Eric Huss
parent 11b1e86187
commit 9bede85efa
4 changed files with 33 additions and 28 deletions

29
tests/cli/build.rs Normal file
View File

@ -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());
}

2
tests/cli/mod.rs Normal file
View File

@ -0,0 +1,2 @@
mod build;
mod test;

View File

@ -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());
}

2
tests/cli_tests.rs Normal file
View File

@ -0,0 +1,2 @@
mod cli;
mod dummy_book;