diff --git a/README.adoc b/README.adoc index df3693c..99e7acd 100644 --- a/README.adoc +++ b/README.adoc @@ -40,7 +40,7 @@ _(by the way, the documentation you are reading is itself tested with bash-unit) skip tests which name matches the given pattern. You can specify several patterns by repeating this option for each pattern. - Tests will appear in *bash_unit* output as _pending_. + Tests will appear in *bash_unit* output as _skipped_. (see also _skip_if_) *-r*:: @@ -207,7 +207,7 @@ Overall result: SUCCESS ``` You can combine the _-p_ option with _-s_ to skip some of the tests. This option accepts a pattern -as parameter and mark as pending any test function which matches this pattern. +as parameter and mark as skipped any test function which matches this pattern. ```test ./bash_unit -p fail_fails -p assert -s no -s status tests/test_core.sh @@ -215,16 +215,16 @@ as parameter and mark as pending any test function which matches this pattern. ```output Running tests in tests/test_core.sh - Running test_assert_equals_fails_when_not_equal ... PENDING - Running test_assert_matches_fails_when_not_matching ... PENDING - Running test_assert_no_diff_fails_when_diff ... PENDING - Running test_assert_no_diff_succeeds_when_no_diff ... PENDING - Running test_assert_not_equals_fails_when_equal ... PENDING - Running test_assert_not_equals_succeeds_when_not_equal ... PENDING - Running test_assert_not_matches_fails_when_matching ... PENDING - Running test_assert_not_matches_succeed_when_not_matching ... PENDING - Running test_assert_status_code_fails ... PENDING - Running test_assert_status_code_succeeds ... PENDING + Running test_assert_equals_fails_when_not_equal ... SKIPPED + Running test_assert_matches_fails_when_not_matching ... SKIPPED + Running test_assert_no_diff_fails_when_diff ... SKIPPED + Running test_assert_no_diff_succeeds_when_no_diff ... SKIPPED + Running test_assert_not_equals_fails_when_equal ... SKIPPED + Running test_assert_not_equals_succeeds_when_not_equal ... SKIPPED + Running test_assert_not_matches_fails_when_matching ... SKIPPED + Running test_assert_not_matches_succeed_when_not_matching ... SKIPPED + Running test_assert_status_code_fails ... SKIPPED + Running test_assert_status_code_succeeds ... SKIPPED Running test_assert_equals_succeed_when_equal ... SUCCESS Running test_assert_fails ... SUCCESS Running test_assert_fails_fails ... SUCCESS @@ -642,7 +642,7 @@ test_darwin_proc_does_not_exist() { will output, on a Linux system: ```output - Running test_darwin_proc_does_not_exist ... PENDING + Running test_darwin_proc_does_not_exist ... SKIPPED Running test_linux_proc_exists ... SUCCESS ``` diff --git a/bash_unit b/bash_unit index 07b8299..3b739ec 100755 --- a/bash_unit +++ b/bash_unit @@ -245,7 +245,7 @@ run_tests() { for skipped_test in $(set | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -E "$skip_pattern" | "$SED" -e 's: .*::') do notify_test_starting "$skipped_test" - notify_test_pending "$skipped_test" + notify_test_skipped "$skipped_test" done local tests_to_run="$(set | "$GREP" -E '^test.* \(\)' | "$GREP" -E "$test_pattern" | "$GREP" -v -E "$skip_pattern" | "$SED" -e 's: .*::' | maybe_shuffle)" else @@ -363,7 +363,10 @@ text_format() { echo -n "PENDING" | pretty_warning echo } - + notify_test_skipped() { + echo -n "SKIPPED" | pretty_warning + echo + } notify_test_succeeded() { echo -n "SUCCESS" | pretty_success echo @@ -406,7 +409,13 @@ tap_format() { local test="$1" echo -n "ok" | pretty_warning - echo -n "$test" | color "$BLUE" - echo " # skip test to be written" | color "$YELLOW" + echo " # todo test to be written" | color "$YELLOW" + } + notify_test_skipped() { + local test="$1" + echo -n "ok" | pretty_warning - + echo -n "$test" | color "$BLUE" + echo " # skip test not run" | color "$YELLOW" } notify_test_succeeded() { local test="$1" @@ -440,7 +449,7 @@ tap_format() { skip_if() { local condition="$1" local pattern="$2" - if eval $condition >/dev/null 2>&1 + if eval "$condition" >/dev/null 2>&1 then skip_pattern="${skip_pattern}${skip_pattern_separator}${pattern}" skip_pattern_separator="|" @@ -452,7 +461,7 @@ test_pattern="" test_pattern_separator="" skip_pattern="" skip_pattern_separator="" -randomise=0 +randomize=0 while getopts "vp:s:f:r" option do case "$option" in diff --git a/getting_started/tests/test_skipping b/getting_started/tests/test_skipping index 88e1efd..f70a18d 100644 --- a/getting_started/tests/test_skipping +++ b/getting_started/tests/test_skipping @@ -24,4 +24,4 @@ test_darwin_proc_does_not_exist() { } test_another_test_to_run_only_on_darwin() { assert "mkdir -p /tmp/foo/bar" -} \ No newline at end of file +} diff --git a/tests/test_cli.sh b/tests/test_cli.sh index 03cc5a9..4f04e01 100644 --- a/tests/test_cli.sh +++ b/tests/test_cli.sh @@ -107,8 +107,8 @@ test_skipped_tests_appear_in_output() { assert_equals "\ Running tests in test_file - Running test_three ... PENDING - Running test_two ... PENDING + Running test_three ... SKIPPED + Running test_two ... SKIPPED Running test_one ... SUCCESS Overall result: SUCCESS" \ "$bash_unit_output" diff --git a/tests/test_tap_format b/tests/test_tap_format index a9beb86..65b59b5 100644 --- a/tests/test_tap_format +++ b/tests/test_tap_format @@ -41,7 +41,7 @@ test_tap_format_for_one_pending_test() { assert_equals \ "\ # Running tests in code -ok - pending_not_yet_implemented # skip test to be written\ +ok - pending_not_yet_implemented # todo test to be written\ " \ "$(bash_unit_out_for_code <