Merge pull request #1777 from trofi/ignore-RUST_LOG
tests/cli: ignore user's RUST_LOG= environment variable in tests
This commit is contained in:
commit
a5dcd78393
|
@ -1,7 +1,6 @@
|
||||||
|
use crate::cli::cmd::mdbook_cmd;
|
||||||
use crate::dummy_book::DummyBook;
|
use crate::dummy_book::DummyBook;
|
||||||
|
|
||||||
use assert_cmd::Command;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mdbook_cli_dummy_book_generates_index_html() {
|
fn mdbook_cli_dummy_book_generates_index_html() {
|
||||||
let temp = DummyBook::new().build().unwrap();
|
let temp = DummyBook::new().build().unwrap();
|
||||||
|
@ -9,7 +8,7 @@ fn mdbook_cli_dummy_book_generates_index_html() {
|
||||||
// doesn't exist before
|
// doesn't exist before
|
||||||
assert!(!temp.path().join("book").exists());
|
assert!(!temp.path().join("book").exists());
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("mdbook").unwrap();
|
let mut cmd = mdbook_cmd();
|
||||||
cmd.arg("build").current_dir(temp.path());
|
cmd.arg("build").current_dir(temp.path());
|
||||||
cmd.assert()
|
cmd.assert()
|
||||||
.success()
|
.success()
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -1,2 +1,3 @@
|
||||||
mod build;
|
mod build;
|
||||||
|
mod cmd;
|
||||||
mod test;
|
mod test;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
|
use crate::cli::cmd::mdbook_cmd;
|
||||||
use crate::dummy_book::DummyBook;
|
use crate::dummy_book::DummyBook;
|
||||||
|
|
||||||
use assert_cmd::Command;
|
|
||||||
use predicates::boolean::PredicateBooleanExt;
|
use predicates::boolean::PredicateBooleanExt;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn mdbook_cli_can_correctly_test_a_passing_book() {
|
fn mdbook_cli_can_correctly_test_a_passing_book() {
|
||||||
let temp = DummyBook::new().with_passing_test(true).build().unwrap();
|
let temp = DummyBook::new().with_passing_test(true).build().unwrap();
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("mdbook").unwrap();
|
let mut cmd = mdbook_cmd();
|
||||||
cmd.arg("test").current_dir(temp.path());
|
cmd.arg("test").current_dir(temp.path());
|
||||||
cmd.assert().success()
|
cmd.assert().success()
|
||||||
.stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())
|
.stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())
|
||||||
|
@ -22,7 +22,7 @@ fn mdbook_cli_can_correctly_test_a_passing_book() {
|
||||||
fn mdbook_cli_detects_book_with_failing_tests() {
|
fn mdbook_cli_detects_book_with_failing_tests() {
|
||||||
let temp = DummyBook::new().with_passing_test(false).build().unwrap();
|
let temp = DummyBook::new().with_passing_test(false).build().unwrap();
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("mdbook").unwrap();
|
let mut cmd = mdbook_cmd();
|
||||||
cmd.arg("test").current_dir(temp.path());
|
cmd.arg("test").current_dir(temp.path());
|
||||||
cmd.assert().failure()
|
cmd.assert().failure()
|
||||||
.stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())
|
.stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())
|
||||||
|
|
Loading…
Reference in New Issue