Skip to content

Commit

Permalink
Fix error message tests for Alpine Linux (#956)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Aug 28, 2021
1 parent dbf1423 commit 4f9a77f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
7 changes: 4 additions & 3 deletions tests/choose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
7 changes: 4 additions & 3 deletions tests/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 12 additions & 10 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ use crate::common::*;
use pretty_assertions::assert_eq;

macro_rules! test {
(
name: $name:ident,
{
name: $name:ident,
$(justfile: $justfile:expr,)?
$(args: ($($arg:tt),*),)?
$(env: { $($env_key:literal : $env_value:literal,)* },)?
$(stdin: $stdin:expr,)?
$(stdout: $stdout:expr,)?
$(stderr: $stderr:expr,)?
$(status: $status:expr,)?
$(shell: $shell:expr,)?
) => {
$(args: ($($arg:tt),*),)?
$(env: { $($env_key:literal : $env_value:literal,)* },)?
$(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();
Expand All @@ -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);)?

Expand Down

0 comments on commit 4f9a77f

Please sign in to comment.