@@ -814,7 +814,12 @@ function bashunit::runner::run_test() {
814814 if [ " $current_assertions_failed " != " $_BASHUNIT_ASSERTIONS_FAILED " ]; then
815815 bashunit::state::add_tests_failed
816816 bashunit::reports::add_test_failed " $test_file " " $label " " $duration " " $total_assertions " " $subshell_output "
817- bashunit::runner::write_failure_result_output " $test_file " " $fn_name " " $subshell_output "
817+ local assertion_runtime_output
818+ assertion_runtime_output=" $(
819+ bashunit::runner::extract_assertion_runtime_output " $runtime_output " " $subshell_output "
820+ ) "
821+ bashunit::runner::write_failure_result_output \
822+ " $test_file " " $fn_name " " $subshell_output " " $assertion_runtime_output "
818823
819824 bashunit::internal_log " Test failed" " $label "
820825
@@ -949,6 +954,111 @@ function bashunit::runner::decode_subshell_output() {
949954 bashunit::helper::decode_base64 " $test_output_base64 "
950955}
951956
957+ function bashunit::runner::is_simple_progress_output() {
958+ local output=" $1 "
959+
960+ [ -n " $output " ] || return 1
961+
962+ local color
963+ for color in \
964+ " $_BASHUNIT_COLOR_DEFAULT " \
965+ " $_BASHUNIT_COLOR_PASSED " \
966+ " $_BASHUNIT_COLOR_FAILED " \
967+ " $_BASHUNIT_COLOR_SKIPPED " \
968+ " $_BASHUNIT_COLOR_INCOMPLETE " \
969+ " $_BASHUNIT_COLOR_SNAPSHOT " \
970+ " $_BASHUNIT_COLOR_RISKY " ; do
971+ [ -n " $color " ] && output=" ${output// " $color " / } "
972+ done
973+
974+ local i
975+ local char
976+ for (( i = 0 ; i < ${# output} ; i++ )) ; do
977+ char=" ${output: $i : 1} "
978+ case " $char " in
979+ " ." | " F" | " S" | " I" | " N" | " R" | " E" | " ?" ) ;;
980+ * ) return 1 ;;
981+ esac
982+ done
983+
984+ return 0
985+ }
986+
987+ function bashunit::runner::line_starts_with_result_marker() {
988+ local line=" $1 "
989+ local marker
990+ local -a result_markers
991+ result_markers=(
992+ " ${_BASHUNIT_COLOR_PASSED} ✓ Passed"
993+ " ${_BASHUNIT_COLOR_FAILED} ✗ Failed"
994+ " ${_BASHUNIT_COLOR_FAILED} ✗ Error"
995+ " ${_BASHUNIT_COLOR_SKIPPED} ↷ Skipped"
996+ " ${_BASHUNIT_COLOR_INCOMPLETE} ✒ Incomplete"
997+ " ${_BASHUNIT_COLOR_SNAPSHOT} ✎ Snapshot"
998+ " ${_BASHUNIT_COLOR_RISKY} ⚠ Risky"
999+ " ✓ Passed"
1000+ " ✗ Failed"
1001+ " ✗ Error"
1002+ " ↷ Skipped"
1003+ " ✒ Incomplete"
1004+ " ✎ Snapshot"
1005+ " ⚠ Risky"
1006+ )
1007+
1008+ for marker in " ${result_markers[@]} " ; do
1009+ case " $line " in
1010+ " $marker " * ) return 0 ;;
1011+ esac
1012+ done
1013+
1014+ return 1
1015+ }
1016+
1017+ function bashunit::runner::line_exists_in_output() {
1018+ local needle=" $1 "
1019+ local haystack=" $2 "
1020+ local line
1021+
1022+ while IFS= read -r line || [ -n " $line " ]; do
1023+ [ " $line " = " $needle " ] && return 0
1024+ done <<< " $haystack"
1025+
1026+ return 1
1027+ }
1028+
1029+ function bashunit::runner::extract_assertion_runtime_output() {
1030+ local runtime_output=" $1 "
1031+ local rendered_assertion_output=" $2 "
1032+ local filtered_output=" "
1033+ local line
1034+
1035+ while IFS= read -r line || [ -n " $line " ]; do
1036+ if bashunit::runner::line_exists_in_output " $line " " $rendered_assertion_output " ; then
1037+ continue
1038+ fi
1039+ if bashunit::runner::is_simple_progress_output " $line " ; then
1040+ continue
1041+ fi
1042+ if bashunit::runner::line_starts_with_result_marker " $line " ; then
1043+ continue
1044+ fi
1045+
1046+ [ -n " $filtered_output " ] && filtered_output=" $filtered_output " $' \n '
1047+ filtered_output=" $filtered_output$line "
1048+ done <<< " $runtime_output"
1049+
1050+ runtime_output=" $filtered_output "
1051+
1052+ while [ -n " $runtime_output " ]; do
1053+ case " $runtime_output " in
1054+ * $' \n ' ) runtime_output=" ${runtime_output% $' \n ' } " ;;
1055+ * ) break ;;
1056+ esac
1057+ done
1058+
1059+ echo " $runtime_output "
1060+ }
1061+
9521062function bashunit::runner::parse_result() {
9531063 local fn_name=$1
9541064 shift
0 commit comments