diff --git a/src/runner.sh b/src/runner.sh index 80e51c81..727e1377 100755 --- a/src/runner.sh +++ b/src/runner.sh @@ -188,7 +188,7 @@ function runner::run_test() { subshell_output=$line fi - local runtime_output="${test_execution_result%%##ASSERTIONS_=*}" + local runtime_output="${test_execution_result%%##ASSERTIONS_*}" local runtime_error="" for error in "command not found" "unbound variable" "permission denied" \ diff --git a/tests/acceptance/bashunit_execution_error_test.sh b/tests/acceptance/bashunit_execution_error_test.sh index 6bd2df34..952cde81 100644 --- a/tests/acceptance/bashunit_execution_error_test.sh +++ b/tests/acceptance/bashunit_execution_error_test.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2155 set -euo pipefail function set_up_before_script() { @@ -7,25 +8,10 @@ function set_up_before_script() { function test_bashunit_when_a_execution_error() { local test_file=./tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh - local fixture_start fixture_end - local color_default color_red color_dim color_bold - - color_default="$(sgr 0)" - color_bold="$(sgr 1)" - color_dim="$(sgr 2)" - color_red="$(sgr 31)" - - function format_fail_title() { - printf "\n%s%s%s%s" "${color_red}" "$1" "${color_default}" "$2" - } - - function format_expect_title() { - printf "\n %s%s%s" "${color_dim}" "$1" "${color_default}" - } - - function format_expect_value() { - printf " %s%s%s" "${color_bold}" "$1" "${color_default}" - } + local color_default="$(sgr 0)" + local color_bold="$(sgr 1)" + local color_dim="$(sgr 2)" + local color_red="$(sgr 31)" function format_summary_title() { printf "\n%s%s%s" "${color_dim}" "$1" "${color_default}" @@ -35,26 +21,23 @@ function test_bashunit_when_a_execution_error() { printf " %s%s%s%s" "${color_red}" "$1" "${color_default}" "$2" } - fixture_start=$( - printf "${color_bold}%s${color_default}\n" "Running ./tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh" - format_fail_title "āœ— Failed" ": Error" - format_expect_title "Expected" - format_expect_value "'127'" - format_expect_title "to be exactly" - format_expect_value "'1'" + local fixture_start=$( + printf "%sRunning ./tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh%s\n" \ + "${color_bold}" "${color_default}" + printf "%sāœ— Error%s: Error\n" "${color_red}" "${color_default}" + printf " %sline 4: invalid_function_name: command not found%s\n" "${color_dim}" "${color_default}" ) - fixture_end=$( + local fixture_end=$( format_summary_title "Tests: " format_summary_value "1 failed" ", 1 total" format_summary_title "Assertions:" - format_summary_value "1 failed" ", 1 total" + format_summary_value "0 failed" ", 0 total" ) - todo "Add snapshots with regex to assert this test (part of the error message is localized)" - todo "Add snapshots with simple/verbose modes as in bashunit_pass_test and bashunit_fail_test" +# todo "Add snapshots with regex to assert this test (part of the error message is localized)" +# todo "Add snapshots with simple/verbose modes as in bashunit_pass_test and bashunit_fail_test" - # shellcheck disable=SC2155 - local actual="$(./bashunit --no-parallel --env "$TEST_ENV_FILE" "$test_file")" + local actual="$(./bashunit --no-parallel --detailed --env "$TEST_ENV_FILE" "$test_file")" assert_contains "$fixture_start" "$actual" assert_contains "$fixture_end" "$actual" assert_general_error "$(./bashunit --no-parallel --env "$TEST_ENV_FILE" "$test_file")" diff --git a/tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh b/tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh index 8c127dbf..266805b9 100644 --- a/tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh +++ b/tests/acceptance/fixtures/test_bashunit_when_a_execution_error.sh @@ -2,5 +2,4 @@ function test_error() { invalid_function_name arg1 arg2 - assert_true 0 }