@@ -16,75 +16,87 @@ function console_results::render_result() {
1616 printf " \n\n"
1717 fi
1818
19+ # Cache state values to avoid repeated subshell invocations
20+ local tests_passed=$_TESTS_PASSED
21+ local tests_skipped=$_TESTS_SKIPPED
22+ local tests_incomplete=$_TESTS_INCOMPLETE
23+ local tests_snapshot=$_TESTS_SNAPSHOT
24+ local tests_failed=$_TESTS_FAILED
25+ local assertions_passed=$_ASSERTIONS_PASSED
26+ local assertions_skipped=$_ASSERTIONS_SKIPPED
27+ local assertions_incomplete=$_ASSERTIONS_INCOMPLETE
28+ local assertions_snapshot=$_ASSERTIONS_SNAPSHOT
29+ local assertions_failed=$_ASSERTIONS_FAILED
30+
1931 local total_tests=0
20- (( total_tests += $(state :: get_tests_passed ) ) ) || true
21- (( total_tests += $(state :: get_tests_skipped ) ) ) || true
22- (( total_tests += $(state :: get_tests_incomplete ) ) ) || true
23- (( total_tests += $(state :: get_tests_snapshot ) ) ) || true
24- (( total_tests += $(state :: get_tests_failed ) ) ) || true
32+ (( total_tests += tests_passed )) || true
33+ (( total_tests += tests_skipped )) || true
34+ (( total_tests += tests_incomplete )) || true
35+ (( total_tests += tests_snapshot )) || true
36+ (( total_tests += tests_failed )) || true
2537
2638 local total_assertions=0
27- (( total_assertions += $(state :: get_assertions_passed ) ) ) || true
28- (( total_assertions += $(state :: get_assertions_skipped ) ) ) || true
29- (( total_assertions += $(state :: get_assertions_incomplete ) ) ) || true
30- (( total_assertions += $(state :: get_assertions_snapshot ) ) ) || true
31- (( total_assertions += $(state :: get_assertions_failed ) ) ) || true
39+ (( total_assertions += assertions_passed )) || true
40+ (( total_assertions += assertions_skipped )) || true
41+ (( total_assertions += assertions_incomplete )) || true
42+ (( total_assertions += assertions_snapshot )) || true
43+ (( total_assertions += assertions_failed )) || true
3244
3345 printf " %sTests: %s" " $_COLOR_FAINT " " $_COLOR_DEFAULT "
34- if [[ " $( state::get_tests_passed ) " -gt 0 ]] || [[ " $( state::get_assertions_passed ) " -gt 0 ]]; then
35- printf " %s%s passed%s," " $_COLOR_PASSED " " $( state::get_tests_passed ) " " $_COLOR_DEFAULT "
46+ if [[ " $tests_passed " -gt 0 ]] || [[ " $assertions_passed " -gt 0 ]]; then
47+ printf " %s%s passed%s," " $_COLOR_PASSED " " $tests_passed " " $_COLOR_DEFAULT "
3648 fi
37- if [[ " $( state::get_tests_skipped ) " -gt 0 ]] || [[ " $( state::get_assertions_skipped ) " -gt 0 ]]; then
38- printf " %s%s skipped%s," " $_COLOR_SKIPPED " " $( state::get_tests_skipped ) " " $_COLOR_DEFAULT "
49+ if [[ " $tests_skipped " -gt 0 ]] || [[ " $assertions_skipped " -gt 0 ]]; then
50+ printf " %s%s skipped%s," " $_COLOR_SKIPPED " " $tests_skipped " " $_COLOR_DEFAULT "
3951 fi
40- if [[ " $( state::get_tests_incomplete ) " -gt 0 ]] || [[ " $( state::get_assertions_incomplete ) " -gt 0 ]]; then
41- printf " %s%s incomplete%s," " $_COLOR_INCOMPLETE " " $( state::get_tests_incomplete ) " " $_COLOR_DEFAULT "
52+ if [[ " $tests_incomplete " -gt 0 ]] || [[ " $assertions_incomplete " -gt 0 ]]; then
53+ printf " %s%s incomplete%s," " $_COLOR_INCOMPLETE " " $tests_incomplete " " $_COLOR_DEFAULT "
4254 fi
43- if [[ " $( state::get_tests_snapshot ) " -gt 0 ]] || [[ " $( state::get_assertions_snapshot ) " -gt 0 ]]; then
44- printf " %s%s snapshot%s," " $_COLOR_SNAPSHOT " " $( state::get_tests_snapshot ) " " $_COLOR_DEFAULT "
55+ if [[ " $tests_snapshot " -gt 0 ]] || [[ " $assertions_snapshot " -gt 0 ]]; then
56+ printf " %s%s snapshot%s," " $_COLOR_SNAPSHOT " " $tests_snapshot " " $_COLOR_DEFAULT "
4557 fi
46- if [[ " $( state::get_tests_failed ) " -gt 0 ]] || [[ " $( state::get_assertions_failed ) " -gt 0 ]]; then
47- printf " %s%s failed%s," " $_COLOR_FAILED " " $( state::get_tests_failed ) " " $_COLOR_DEFAULT "
58+ if [[ " $tests_failed " -gt 0 ]] || [[ " $assertions_failed " -gt 0 ]]; then
59+ printf " %s%s failed%s," " $_COLOR_FAILED " " $tests_failed " " $_COLOR_DEFAULT "
4860 fi
4961 printf " %s total\n" " $total_tests "
5062
5163 printf " %sAssertions:%s" " $_COLOR_FAINT " " $_COLOR_DEFAULT "
52- if [[ " $( state::get_tests_passed ) " -gt 0 ]] || [[ " $( state::get_assertions_passed ) " -gt 0 ]]; then
53- printf " %s%s passed%s," " $_COLOR_PASSED " " $( state::get_assertions_passed ) " " $_COLOR_DEFAULT "
64+ if [[ " $tests_passed " -gt 0 ]] || [[ " $assertions_passed " -gt 0 ]]; then
65+ printf " %s%s passed%s," " $_COLOR_PASSED " " $assertions_passed " " $_COLOR_DEFAULT "
5466 fi
55- if [[ " $( state::get_tests_skipped ) " -gt 0 ]] || [[ " $( state::get_assertions_skipped ) " -gt 0 ]]; then
56- printf " %s%s skipped%s," " $_COLOR_SKIPPED " " $( state::get_assertions_skipped ) " " $_COLOR_DEFAULT "
67+ if [[ " $tests_skipped " -gt 0 ]] || [[ " $assertions_skipped " -gt 0 ]]; then
68+ printf " %s%s skipped%s," " $_COLOR_SKIPPED " " $assertions_skipped " " $_COLOR_DEFAULT "
5769 fi
58- if [[ " $( state::get_tests_incomplete ) " -gt 0 ]] || [[ " $( state::get_assertions_incomplete ) " -gt 0 ]]; then
59- printf " %s%s incomplete%s," " $_COLOR_INCOMPLETE " " $( state::get_assertions_incomplete ) " " $_COLOR_DEFAULT "
70+ if [[ " $tests_incomplete " -gt 0 ]] || [[ " $assertions_incomplete " -gt 0 ]]; then
71+ printf " %s%s incomplete%s," " $_COLOR_INCOMPLETE " " $assertions_incomplete " " $_COLOR_DEFAULT "
6072 fi
61- if [[ " $( state::get_tests_snapshot ) " -gt 0 ]] || [[ " $( state::get_assertions_snapshot ) " -gt 0 ]]; then
62- printf " %s%s snapshot%s," " $_COLOR_SNAPSHOT " " $( state::get_assertions_snapshot ) " " $_COLOR_DEFAULT "
73+ if [[ " $tests_snapshot " -gt 0 ]] || [[ " $assertions_snapshot " -gt 0 ]]; then
74+ printf " %s%s snapshot%s," " $_COLOR_SNAPSHOT " " $assertions_snapshot " " $_COLOR_DEFAULT "
6375 fi
64- if [[ " $( state::get_tests_failed ) " -gt 0 ]] || [[ " $( state::get_assertions_failed ) " -gt 0 ]]; then
65- printf " %s%s failed%s," " $_COLOR_FAILED " " $( state::get_assertions_failed ) " " $_COLOR_DEFAULT "
76+ if [[ " $tests_failed " -gt 0 ]] || [[ " $assertions_failed " -gt 0 ]]; then
77+ printf " %s%s failed%s," " $_COLOR_FAILED " " $assertions_failed " " $_COLOR_DEFAULT "
6678 fi
6779 printf " %s total\n" " $total_assertions "
6880
69- if [[ " $( state::get_tests_failed ) " -gt 0 ]]; then
81+ if [[ " $tests_failed " -gt 0 ]]; then
7082 printf " \n%s%s%s\n" " $_COLOR_RETURN_ERROR " " Some tests failed " " $_COLOR_DEFAULT "
7183 console_results::print_execution_time
7284 return 1
7385 fi
7486
75- if [[ " $( state::get_tests_incomplete ) " -gt 0 ]]; then
87+ if [[ " $tests_incomplete " -gt 0 ]]; then
7688 printf " \n%s%s%s\n" " $_COLOR_RETURN_INCOMPLETE " " Some tests incomplete " " $_COLOR_DEFAULT "
7789 console_results::print_execution_time
7890 return 0
7991 fi
8092
81- if [[ " $( state::get_tests_skipped ) " -gt 0 ]]; then
93+ if [[ " $tests_skipped " -gt 0 ]]; then
8294 printf " \n%s%s%s\n" " $_COLOR_RETURN_SKIPPED " " Some tests skipped " " $_COLOR_DEFAULT "
8395 console_results::print_execution_time
8496 return 0
8597 fi
8698
87- if [[ " $( state::get_tests_snapshot ) " -gt 0 ]]; then
99+ if [[ " $tests_snapshot " -gt 0 ]]; then
88100 printf " \n%s%s%s\n" " $_COLOR_RETURN_SNAPSHOT " " Some snapshots created " " $_COLOR_DEFAULT "
89101 console_results::print_execution_time
90102 return 0
0 commit comments