Fix error message tests for Alpine Linux (#956)

This commit is contained in:
Casey Rodarmor 2021-08-27 17:01:50 -07:00 committed by GitHub
parent dbf142369b
commit 4f9a77fff6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 17 deletions

View File

@ -160,9 +160,10 @@ fn status_error() {
.output()
.unwrap();
assert_eq!(
String::from_utf8_lossy(&output.stderr),
"error: Chooser `exit-2` failed: exit code: 2\n",
assert!(
Regex::new("^error: Chooser `exit-2` failed: exit (code|status): 2\n$")
.unwrap()
.is_match(str::from_utf8(&output.stderr).unwrap())
);
assert_eq!(output.status.code().unwrap(), 2);

View File

@ -91,7 +91,7 @@ test! {
echo XYZ
",
args: ("--command", "false"),
stderr: "error: Command `false` failed: exit code: 1\n",
stderr_regex: "error: Command `false` failed: exit (code|status): 1\n",
status: EXIT_FAILURE,
}

View File

@ -79,9 +79,10 @@ fn status_error() {
.output()
.unwrap();
assert_eq!(
String::from_utf8_lossy(&output.stderr),
"error: Editor `exit-2` failed: exit code: 2\n"
assert!(
Regex::new("^error: Editor `exit-2` failed: exit (code|status): 2\n$")
.unwrap()
.is_match(str::from_utf8(&output.stderr).unwrap(),)
);
assert_eq!(output.status.code().unwrap(), 2);

View File

@ -3,7 +3,7 @@ use crate::common::*;
use pretty_assertions::assert_eq;
macro_rules! test {
(
{
name: $name:ident,
$(justfile: $justfile:expr,)?
$(args: ($($arg:tt),*),)?
@ -11,9 +11,10 @@ macro_rules! test {
$(stdin: $stdin:expr,)?
$(stdout: $stdout:expr,)?
$(stderr: $stderr:expr,)?
$(stderr_regex: $stderr_regex:expr,)?
$(status: $status:expr,)?
$(shell: $shell:expr,)?
) => {
} => {
#[test]
fn $name() {
let test = crate::test::Test::new();
@ -24,6 +25,7 @@ macro_rules! test {
$(let test = test.shell($shell);)?
$(let test = test.status($status);)?
$(let test = test.stderr($stderr);)?
$(let test = test.stderr_regex($stderr_regex);)?
$(let test = test.stdin($stdin);)?
$(let test = test.stdout($stdout);)?