Skip to content

Commit a308f1a

Browse files
committed
fix: can name a test file named after an binary
If one named its test file after an binary that can be found in PATH then bash_unit was trying to source this binary instead of the test file. Also note that the path displayed in test output may not be the exact path of the file as bash_unit changes directory to the test file directory before running the test so it's a local path that is displayed. That's a problem I keep for later.
1 parent 7b68add commit a308f1a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

bash_unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ do
580580
then
581581
cd "$(dirname "$test_file")"
582582
# shellcheck disable=1090
583-
source "$(basename "$test_file")"
583+
source "./$(basename "$test_file")"
584584
else
585585
# shellcheck disable=1090
586586
source "$test_file"

tests/test_cli.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test_run_all_tests_even_in_case_of_failure() {
55
"\
66
Running tests in code
77
Running test_fails ... FAILURE
8-
code:2:test_fails()
8+
./code:2:test_fails()
99
Running test_succeed ... SUCCESS
1010
Overall resultcode: FAILURE\
1111
" \

tests/test_tap_format

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_tap_format_for_one_failing_test() {
2727
"\
2828
# Running tests in code
2929
not ok - test_not_ok
30-
# code:2:test_not_ok()
30+
# ./code:2:test_not_ok()
3131
1..1" \
3232
"$(bash_unit_out_for_code <<EOF
3333
test_not_ok() {
@@ -74,7 +74,7 @@ test_tap_format_for_failing_test_with_stdout_stderr_outputs() {
7474
not ok - test_not_ok
7575
# out> message on stdout
7676
# err> message on stderr
77-
# code:2:test_not_ok()
77+
# ./code:2:test_not_ok()
7878
1..1" \
7979
"$(bash_unit_out_for_code <<EOF
8080
test_not_ok() {
@@ -90,7 +90,7 @@ test_assertion_message_is_tap_formatted() {
9090
# Running tests in code
9191
not ok - test_not_ok
9292
# obvious failure
93-
# code:2:test_not_ok()
93+
# ./code:2:test_not_ok()
9494
1..1" \
9595
"$(bash_unit_out_for_code <<EOF
9696
test_not_ok() {
@@ -107,7 +107,7 @@ test_multi_lines_assertion_message_is_tap_formatted() {
107107
not ok - test_not_ok
108108
# obvious failure
109109
# on multiple lines
110-
# code:2:test_not_ok()
110+
# ./code:2:test_not_ok()
111111
1..1" \
112112
"$(bash_unit_out_for_code <<EOF
113113
test_not_ok() {

0 commit comments

Comments
 (0)