@@ -4,11 +4,10 @@ function assert_file_exists() {
44 bashunit::assert::should_skip && return 0
55
66 local expected=" $1 "
7- local test_fn
8- test_fn=" $( bashunit::helper::find_test_function_name) "
9- local label=" ${3:- $(bashunit:: helper:: normalize_test_function_name " $test_fn " )} "
107
118 if [ ! -f " $expected " ]; then
9+ bashunit::assert::label_to_slot " ${3:- } "
10+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
1211 bashunit::assert::mark_failed
1312 bashunit::console_results::print_failed_test " ${label} " " ${expected} " " to exist but" " do not exist"
1413 return
@@ -21,11 +20,10 @@ function assert_file_not_exists() {
2120 bashunit::assert::should_skip && return 0
2221
2322 local expected=" $1 "
24- local test_fn
25- test_fn=" $( bashunit::helper::find_test_function_name) "
26- local label=" ${3:- $(bashunit:: helper:: normalize_test_function_name " $test_fn " )} "
2723
2824 if [ -f " $expected " ]; then
25+ bashunit::assert::label_to_slot " ${3:- } "
26+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
2927 bashunit::assert::mark_failed
3028 bashunit::console_results::print_failed_test " ${label} " " ${expected} " " to not exist but" " the file exists"
3129 return
@@ -38,11 +36,10 @@ function assert_is_file() {
3836 bashunit::assert::should_skip && return 0
3937
4038 local expected=" $1 "
41- local test_fn
42- test_fn=" $( bashunit::helper::find_test_function_name) "
43- local label=" ${3:- $(bashunit:: helper:: normalize_test_function_name " $test_fn " )} "
4439
4540 if [ ! -f " $expected " ]; then
41+ bashunit::assert::label_to_slot " ${3:- } "
42+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
4643 bashunit::assert::mark_failed
4744 bashunit::console_results::print_failed_test " ${label} " " ${expected} " " to be a file" " but is not a file"
4845 return
@@ -55,11 +52,10 @@ function assert_is_file_empty() {
5552 bashunit::assert::should_skip && return 0
5653
5754 local expected=" $1 "
58- local test_fn
59- test_fn=" $( bashunit::helper::find_test_function_name) "
60- local label=" ${3:- $(bashunit:: helper:: normalize_test_function_name " $test_fn " )} "
6155
6256 if [ -s " $expected " ]; then
57+ bashunit::assert::label_to_slot " ${3:- } "
58+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
6359 bashunit::assert::mark_failed
6460 bashunit::console_results::print_failed_test " ${label} " " ${expected} " " to be empty" " but is not empty"
6561 return
@@ -75,10 +71,8 @@ function assert_files_equals() {
7571 local actual=" $2 "
7672
7773 if [ " $( diff -u " $expected " " $actual " ) " != ' ' ]; then
78- local test_fn
79- test_fn=" $( bashunit::helper::find_test_function_name) "
80- local label
81- label=" $( bashunit::helper::normalize_test_function_name " $test_fn " ) "
74+ bashunit::assert::label_to_slot
75+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
8276 bashunit::assert::mark_failed
8377
8478 bashunit::console_results::print_failed_test " ${label} " " ${expected} " " Compared" " ${actual} " \
@@ -96,10 +90,8 @@ function assert_files_not_equals() {
9690 local actual=" $2 "
9791
9892 if [ " $( diff -u " $expected " " $actual " ) " = ' ' ]; then
99- local test_fn
100- test_fn=" $( bashunit::helper::find_test_function_name) "
101- local label
102- label=" $( bashunit::helper::normalize_test_function_name " $test_fn " ) "
93+ bashunit::assert::label_to_slot
94+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
10395 bashunit::assert::mark_failed
10496
10597 bashunit::console_results::print_failed_test " ${label} " " ${expected} " " Compared" " ${actual} " \
@@ -117,10 +109,8 @@ function assert_file_contains() {
117109 local string=" $2 "
118110
119111 if ! grep -F -q " $string " " $file " ; then
120- local test_fn
121- test_fn=" $( bashunit::helper::find_test_function_name) "
122- local label
123- label=" $( bashunit::helper::normalize_test_function_name " $test_fn " ) "
112+ bashunit::assert::label_to_slot
113+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
124114 bashunit::assert::mark_failed
125115
126116 bashunit::console_results::print_failed_test " ${label} " " ${file} " " to contain" " ${string} "
@@ -137,10 +127,8 @@ function assert_file_not_contains() {
137127 local string=" $2 "
138128
139129 if grep -q " $string " " $file " ; then
140- local test_fn
141- test_fn=" $( bashunit::helper::find_test_function_name) "
142- local label
143- label=" $( bashunit::helper::normalize_test_function_name " $test_fn " ) "
130+ bashunit::assert::label_to_slot
131+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
144132 bashunit::assert::mark_failed
145133
146134 bashunit::console_results::print_failed_test " ${label} " " ${file} " " to not contain" " ${string} "
@@ -172,10 +160,8 @@ function assert_file_permissions() {
172160
173161 local expected=" $1 "
174162 local file=" $2 "
175- local test_fn
176- test_fn=" $( bashunit::helper::find_test_function_name) "
177- local label
178- label=" $( bashunit::helper::normalize_test_function_name " $test_fn " ) "
163+ bashunit::assert::label_to_slot
164+ local label=$_BASHUNIT_ASSERT_LABEL_OUT
179165
180166 if [ ! -e " $file " ]; then
181167 bashunit::assert::mark_failed
0 commit comments