Skip to content

Commit 28572b2

Browse files
committed
Distinguish skipped tests from pending tests
1 parent fd17d75 commit 28572b2

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

README.adoc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ _(by the way, the documentation you are reading is itself tested with bash-unit)
4040
skip tests which name matches the given pattern.
4141
You can specify several patterns by repeating this option
4242
for each pattern.
43-
Tests will appear in *bash_unit* output as _pending_.
43+
Tests will appear in *bash_unit* output as _skipped_.
4444
(see also _skip_if_)
4545

4646
*-r*::
@@ -207,24 +207,24 @@ Overall result: SUCCESS
207207
```
208208

209209
You can combine the _-p_ option with _-s_ to skip some of the tests. This option accepts a pattern
210-
as parameter and mark as pending any test function which matches this pattern.
210+
as parameter and mark as skipped any test function which matches this pattern.
211211

212212
```test
213213
./bash_unit -p fail_fails -p assert -s no -s status tests/test_core.sh
214214
```
215215

216216
```output
217217
Running tests in tests/test_core.sh
218-
Running test_assert_equals_fails_when_not_equal ... PENDING
219-
Running test_assert_matches_fails_when_not_matching ... PENDING
220-
Running test_assert_no_diff_fails_when_diff ... PENDING
221-
Running test_assert_no_diff_succeeds_when_no_diff ... PENDING
222-
Running test_assert_not_equals_fails_when_equal ... PENDING
223-
Running test_assert_not_equals_succeeds_when_not_equal ... PENDING
224-
Running test_assert_not_matches_fails_when_matching ... PENDING
225-
Running test_assert_not_matches_succeed_when_not_matching ... PENDING
226-
Running test_assert_status_code_fails ... PENDING
227-
Running test_assert_status_code_succeeds ... PENDING
218+
Running test_assert_equals_fails_when_not_equal ... SKIPPED
219+
Running test_assert_matches_fails_when_not_matching ... SKIPPED
220+
Running test_assert_no_diff_fails_when_diff ... SKIPPED
221+
Running test_assert_no_diff_succeeds_when_no_diff ... SKIPPED
222+
Running test_assert_not_equals_fails_when_equal ... SKIPPED
223+
Running test_assert_not_equals_succeeds_when_not_equal ... SKIPPED
224+
Running test_assert_not_matches_fails_when_matching ... SKIPPED
225+
Running test_assert_not_matches_succeed_when_not_matching ... SKIPPED
226+
Running test_assert_status_code_fails ... SKIPPED
227+
Running test_assert_status_code_succeeds ... SKIPPED
228228
Running test_assert_equals_succeed_when_equal ... SUCCESS
229229
Running test_assert_fails ... SUCCESS
230230
Running test_assert_fails_fails ... SUCCESS
@@ -642,7 +642,7 @@ test_darwin_proc_does_not_exist() {
642642
will output, on a Linux system:
643643

644644
```output
645-
Running test_darwin_proc_does_not_exist ... PENDING
645+
Running test_darwin_proc_does_not_exist ... SKIPPED
646646
Running test_linux_proc_exists ... SUCCESS
647647
```
648648

bash_unit

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ run_tests() {
245245
for skipped_test in $(set | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -E "$skip_pattern" | "$SED" -e 's: .*::')
246246
do
247247
notify_test_starting "$skipped_test"
248-
notify_test_pending "$skipped_test"
248+
notify_test_skipped "$skipped_test"
249249
done
250250
local tests_to_run="$(set | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -v -E "$skip_pattern" | "$SED" -e 's: .*::' | maybe_shuffle)"
251251
else
@@ -363,7 +363,10 @@ text_format() {
363363
echo -n "PENDING" | pretty_warning
364364
echo
365365
}
366-
366+
notify_test_skipped() {
367+
echo -n "SKIPPED" | pretty_warning
368+
echo
369+
}
367370
notify_test_succeeded() {
368371
echo -n "SUCCESS" | pretty_success
369372
echo
@@ -406,7 +409,13 @@ tap_format() {
406409
local test="$1"
407410
echo -n "ok" | pretty_warning -
408411
echo -n "$test" | color "$BLUE"
409-
echo " # skip test to be written" | color "$YELLOW"
412+
echo " # todo test to be written" | color "$YELLOW"
413+
}
414+
notify_test_skipped() {
415+
local test="$1"
416+
echo -n "ok" | pretty_warning -
417+
echo -n "$test" | color "$BLUE"
418+
echo " # skip test not run" | color "$YELLOW"
410419
}
411420
notify_test_succeeded() {
412421
local test="$1"
@@ -440,7 +449,7 @@ tap_format() {
440449
skip_if() {
441450
local condition="$1"
442451
local pattern="$2"
443-
if eval $condition >/dev/null 2>&1
452+
if eval "$condition" >/dev/null 2>&1
444453
then
445454
skip_pattern="${skip_pattern}${skip_pattern_separator}${pattern}"
446455
skip_pattern_separator="|"
@@ -452,7 +461,7 @@ test_pattern=""
452461
test_pattern_separator=""
453462
skip_pattern=""
454463
skip_pattern_separator=""
455-
randomise=0
464+
randomize=0
456465
while getopts "vp:s:f:r" option
457466
do
458467
case "$option" in

getting_started/tests/test_skipping

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ test_darwin_proc_does_not_exist() {
2424
}
2525
test_another_test_to_run_only_on_darwin() {
2626
assert "mkdir -p /tmp/foo/bar"
27-
}
27+
}

tests/test_cli.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ test_skipped_tests_appear_in_output() {
107107

108108
assert_equals "\
109109
Running tests in test_file
110-
Running test_three ... PENDING
111-
Running test_two ... PENDING
110+
Running test_three ... SKIPPED
111+
Running test_two ... SKIPPED
112112
Running test_one ... SUCCESS
113113
Overall result: SUCCESS" \
114114
"$bash_unit_output"

tests/test_tap_format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test_tap_format_for_one_pending_test() {
4141
assert_equals \
4242
"\
4343
# Running tests in code
44-
ok - pending_not_yet_implemented # skip test to be written\
44+
ok - pending_not_yet_implemented # todo test to be written\
4545
" \
4646
"$(bash_unit_out_for_code <<EOF
4747
pending_not_yet_implemented() {

0 commit comments

Comments
 (0)