From a392cf635291881db3073060d48abf491675123b Mon Sep 17 00:00:00 2001 From: Martin Schulze Date: Tue, 14 Oct 2025 10:36:02 +0200 Subject: [PATCH] fix: too brittle invalid regex tests under bash 5.3 The exact error details depend on the system --- test/assert_line.bats | 11 +++++++++-- test/assert_output.bats | 5 +++-- test/assert_regex.bats | 5 +++-- test/assert_stderr.bats | 5 +++-- test/assert_stderr_line.bats | 5 +++-- test/refute_line.bats | 5 +++-- test/refute_output.bats | 5 +++-- test/refute_regex.bats | 5 +++-- test/refute_stderr.bats | 5 +++-- test/refute_stderr_line.bats | 5 +++-- 10 files changed, 36 insertions(+), 20 deletions(-) diff --git a/test/assert_line.bats b/test/assert_line.bats index 5a2f494..d42df0d 100755 --- a/test/assert_line.bats +++ b/test/assert_line.bats @@ -337,10 +337,17 @@ ERR_MSG run assert_line --regexp '[.*' if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + cat < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail <: returns 1 and displays an error message if is not a valid extended regular expression' { run refute_output --regexp '[.*' if (( BASH_VERSINFO[0] > 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<'ERR_MSG' + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >=3) )); then - assert_test_fail <<"ERR_MSG" + [[ "$output" =~ "invalid regular expression "([^$'\n']+) ]] + assert_test_fail <