|
138 | 138 | assert_equals 2 $(ps | grep pts | wc -l) |
139 | 139 | } |
140 | 140 |
|
141 | | -test_run_all_tests_even_in_case_of_failure() { |
142 | | - bash_unit_output=$($BASH_UNIT <(cat << EOF |
143 | | -function test_succeed() { assert true ; } |
144 | | -function test_fails() { assert false ; } |
145 | | -EOF |
146 | | -) | sed -e 's:/dev/fd/[0-9]*:test_file:') |
147 | | - |
148 | | - assert_equals "\ |
149 | | -Running tests in test_file |
150 | | -Running test_fails... FAILURE |
151 | | -test_file:2:test_fails() |
152 | | -Running test_succeed... SUCCESS" "$bash_unit_output" |
153 | | -} |
154 | | - |
155 | | -test_exit_code_not_0_in_case_of_failure() { |
156 | | - assert_fail "$BASH_UNIT <(cat << EOF |
157 | | -function test_succeed() { assert true ; } |
158 | | -function test_fails() { assert false ; } |
159 | | -EOF |
160 | | -)" |
161 | | -} |
162 | | - |
163 | | -test_run_all_file_parameters() { |
164 | | - bash_unit_output=$($BASH_UNIT \ |
165 | | - <(echo "test_one() { echo -n ; }") \ |
166 | | - <(echo "test_two() { echo -n ; }") \ |
167 | | - | sed -e 's:/dev/fd/[0-9]*:test_file:' \ |
168 | | - ) |
169 | | - |
170 | | - assert_equals "\ |
171 | | -Running tests in test_file |
172 | | -Running test_one... SUCCESS |
173 | | -Running tests in test_file |
174 | | -Running test_two... SUCCESS" "$bash_unit_output" |
175 | | -} |
176 | | - |
177 | | -test_run_only_tests_that_match_pattern() { |
178 | | - bash_unit_output=$($BASH_UNIT -p one \ |
179 | | - <(echo "test_one() { echo -n ; }") \ |
180 | | - <(echo "test_two() { echo -n ; }") \ |
181 | | - | sed -e 's:/dev/fd/[0-9]*:test_file:' \ |
182 | | - ) |
183 | | - |
184 | | - assert_equals "\ |
185 | | -Running tests in test_file |
186 | | -Running test_one... SUCCESS |
187 | | -Running tests in test_file" "$bash_unit_output" |
188 | | -} |
189 | | - |
190 | | -test_fails_when_test_file_does_not_exist() { |
191 | | - assert_fail "$BASH_UNIT /not_exist/not_exist" |
192 | | -} |
193 | | - |
194 | | -test_display_usage_when_test_file_does_not_exist() { |
195 | | - bash_unit_output=$($BASH_UNIT /not_exist/not_exist 2>&1 >/dev/null | line 1) |
196 | | - |
197 | | - assert_equals "file does not exist: /not_exist/not_exist"\ |
198 | | - "$bash_unit_output" |
199 | | -} |
200 | | - |
201 | | -test_bash_unit_succeed_when_no_failure_even_if_no_teardown() { |
202 | | - #FIX https://github.com/pgrange/bash_unit/issues/8 |
203 | | - assert "$BASH_UNIT <(echo 'test_success() { echo -n ; }')" |
204 | | -} |
205 | | - |
206 | | -test_bash_unit_runs_teardown_even_in_case_of_failure() { |
207 | | - #FIX https://github.com/pgrange/bash_unit/issues/10 |
208 | | - assert_equals "ran teardown" \ |
209 | | - "$($BASH_UNIT <(echo 'test_fail() { fail ; } ; teardown() { echo "ran teardown" >&2 ; }') 2>&1 >/dev/null)" |
210 | | -} |
211 | | - |
212 | | -test_one_test_should_stop_after_first_assertion_failure() { |
213 | | - #FIX https://github.com/pgrange/bash_unit/issues/10 |
214 | | - assert_equals "before failure" \ |
215 | | - "$($BASH_UNIT <(echo 'test_fail() { echo "before failure" >&2 ; fail ; echo "after failure" >&2 ; }') 2>&1 >/dev/null)" |
216 | | - |
217 | | -} |
218 | | - |
219 | | -test_one_test_should_stop_when_assert_fails() { |
220 | | - #FIX https://github.com/pgrange/bash_unit/issues/26 |
221 | | - assert_equals "before failure" \ |
222 | | - "$($BASH_UNIT <(echo 'test_fail() { echo "before failure" >&2 ; assert false ; echo "after failure" >&2 ; }') 2>&1 >/dev/null)" |
223 | | - |
224 | | -} |
225 | | - |
226 | 141 | test_bash_unit_changes_cwd_to_current_test_file_directory() { |
227 | 142 | assert "ls ../tests/$(basename "$BASH_SOURCE")" \ |
228 | 143 | "bash_unit should change current working directory to match the directory of the currenlty running test" |
@@ -312,5 +227,3 @@ mute() { |
312 | 227 | notify_stdout () { echo -n ; } |
313 | 228 | notify_stderr () { echo -n ; } |
314 | 229 | } |
315 | | - |
316 | | -BASH_UNIT="eval FORCE_COLOR=false ../bash_unit" |
0 commit comments