Skip to content

Commit a5dcd78

Browse files
authored
Merge pull request #1777 from trofi/ignore-RUST_LOG
tests/cli: ignore user's RUST_LOG= environment variable in tests
2 parents eb5ec2a + 2a2b51c commit a5dcd78

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

tests/cli/build.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
use crate::cli::cmd::mdbook_cmd;
12
use crate::dummy_book::DummyBook;
23

3-
use assert_cmd::Command;
4-
54
#[test]
65
fn mdbook_cli_dummy_book_generates_index_html() {
76
let temp = DummyBook::new().build().unwrap();
87

98
// doesn't exist before
109
assert!(!temp.path().join("book").exists());
1110

12-
let mut cmd = Command::cargo_bin("mdbook").unwrap();
11+
let mut cmd = mdbook_cmd();
1312
cmd.arg("build").current_dir(temp.path());
1413
cmd.assert()
1514
.success()

tests/cli/cmd.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use assert_cmd::Command;
2+
3+
pub(crate) fn mdbook_cmd() -> Command {
4+
let mut cmd = Command::cargo_bin("mdbook").unwrap();
5+
cmd.env_remove("RUST_LOG");
6+
cmd
7+
}

tests/cli/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
mod build;
2+
mod cmd;
23
mod test;

tests/cli/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
use crate::cli::cmd::mdbook_cmd;
12
use crate::dummy_book::DummyBook;
23

3-
use assert_cmd::Command;
44
use predicates::boolean::PredicateBooleanExt;
55

66
#[test]
77
fn mdbook_cli_can_correctly_test_a_passing_book() {
88
let temp = DummyBook::new().with_passing_test(true).build().unwrap();
99

10-
let mut cmd = Command::cargo_bin("mdbook").unwrap();
10+
let mut cmd = mdbook_cmd();
1111
cmd.arg("test").current_dir(temp.path());
1212
cmd.assert().success()
1313
.stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())
@@ -22,7 +22,7 @@ fn mdbook_cli_can_correctly_test_a_passing_book() {
2222
fn mdbook_cli_detects_book_with_failing_tests() {
2323
let temp = DummyBook::new().with_passing_test(false).build().unwrap();
2424

25-
let mut cmd = Command::cargo_bin("mdbook").unwrap();
25+
let mut cmd = mdbook_cmd();
2626
cmd.arg("test").current_dir(temp.path());
2727
cmd.assert().failure()
2828
.stderr(predicates::str::is_match(r##"Testing file: "([^"]+)[\\/]README.md""##).unwrap())

0 commit comments

Comments
 (0)