-
-
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
a4a395a
commit 32942ad
Showing
2 changed files
with
46 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,42 @@ | ||
// Copyright (c) The datatest-stable Contributors | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
#[test] | ||
fn run_example() { | ||
let output = std::process::Command::new("cargo") | ||
.args(["nextest", "run", "--test=example", "--color=never"]) | ||
.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("cargo nextest stderr should be 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}", | ||
); | ||
} | ||
} |