Skip to content

Commit

Permalink
Move cli tests to their own subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle authored and ehuss committed Sep 26, 2021
1 parent 11b1e86 commit 9bede85
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 28 deletions.
29 changes: 29 additions & 0 deletions tests/cli/build.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 0 deletions tests/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod build;
mod test;
28 changes: 0 additions & 28 deletions tests/cli.rs → tests/cli/test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mod dummy_book;

use crate::dummy_book::DummyBook;

use assert_cmd::Command;
Expand Down Expand Up @@ -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 changes: 2 additions & 0 deletions tests/cli_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mod cli;
mod dummy_book;

0 comments on commit 9bede85

Please sign in to comment.