-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test for
cargo nextest run
on the example test harness
- Loading branch information
1 parent
6ec18d5
commit 3799e6b
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,7 @@ walkdir = "2.5.0" | |
[[test]] | ||
name = "example" | ||
harness = false | ||
|
||
[[test]] | ||
name = "run_example" | ||
harness = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#[test] | ||
fn run_example() { | ||
let output = std::process::Command::new("cargo") | ||
.args(["nextest", "run", "--test=example"]) | ||
.env("DATATEST_FULL_SCAN_FORBIDDEN", "1") | ||
.output() | ||
.expect("Failed to run `cargo nextest`"); | ||
|
||
// It's a pain to make assertions on byte slices (even a subslice check isn't easy) | ||
// and it's also difficult to print nice error messages. So we just assume all | ||
// nextest output will be utf8 and convert it. | ||
let stderr = std::str::from_utf8(&output.stderr).expect("Failed to convert stderr to utf-8"); | ||
|
||
assert!( | ||
output.status.success(), | ||
"Command failed (exit status: {}, stderr: {stderr})", | ||
output.status | ||
); | ||
|
||
let lines: &[&str] = &[ | ||
"datatest-stable::example test_artifact::::colon::dir/::.txt", | ||
"datatest-stable::example test_artifact::::colon::dir/a.txt", | ||
"datatest-stable::example test_artifact::a.txt", | ||
"datatest-stable::example test_artifact_utf8::::colon::dir/::.txt", | ||
"datatest-stable::example test_artifact::b.txt", | ||
"datatest-stable::example test_artifact_utf8::::colon::dir/a.txt", | ||
"datatest-stable::example test_artifact_utf8::a.txt", | ||
"datatest-stable::example test_artifact_utf8::c.skip.txt", | ||
"datatest-stable::example test_artifact_utf8::b.txt", | ||
"9 tests run: 9 passed, 0 skipped", | ||
]; | ||
|
||
for line in lines { | ||
assert!( | ||
stderr.contains(line), | ||
"Expected to find substring\n {line}\nin stderr\n {stderr}", | ||
); | ||
} | ||
} |