Skip to content

Commit 4ccb5a8

Browse files
committed
fix(test): make tag tests compatible with strict mode
1 parent c3d383e commit 4ccb5a8

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

tests/acceptance/bashunit_tag_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function test_tag_nonexistent_runs_zero_tests() {
7979
local test_file=./tests/acceptance/fixtures/test_bashunit_with_tags.sh
8080
local output
8181

82-
output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --tag nonexistent "$test_file" 2>&1)
82+
output=$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --tag nonexistent "$test_file" 2>&1) || true
8383

8484
assert_contains "0 total" "$output"
8585
}

tests/unit/helpers_tag_test.sh

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,69 +39,77 @@ function test_function_matches_tags_include_match() {
3939
local include_tags="slow"
4040
local exclude_tags=""
4141

42-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
43-
assert_successful_code "$?"
42+
local exit_code=0
43+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
44+
assert_same 0 "$exit_code"
4445
}
4546

4647
function test_function_matches_tags_include_no_match() {
4748
local tags="fast"
4849
local include_tags="slow"
4950
local exclude_tags=""
5051

51-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
52-
assert_general_error "$?"
52+
local exit_code=0
53+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
54+
assert_same 1 "$exit_code"
5355
}
5456

5557
function test_function_matches_tags_exclude_match() {
5658
local tags="slow,database"
5759
local include_tags=""
5860
local exclude_tags="slow"
5961

60-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
61-
assert_general_error "$?"
62+
local exit_code=0
63+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
64+
assert_same 1 "$exit_code"
6265
}
6366

6467
function test_function_matches_tags_exclude_wins_over_include() {
6568
local tags="slow,database"
6669
local include_tags="database"
6770
local exclude_tags="slow"
6871

69-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
70-
assert_general_error "$?"
72+
local exit_code=0
73+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
74+
assert_same 1 "$exit_code"
7175
}
7276

7377
function test_function_matches_tags_no_tags_with_include_filter() {
7478
local tags=""
7579
local include_tags="slow"
7680
local exclude_tags=""
7781

78-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
79-
assert_general_error "$?"
82+
local exit_code=0
83+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
84+
assert_same 1 "$exit_code"
8085
}
8186

8287
function test_function_matches_tags_no_tags_with_exclude_filter() {
8388
local tags=""
8489
local include_tags=""
8590
local exclude_tags="slow"
8691

87-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
88-
assert_successful_code "$?"
92+
local exit_code=0
93+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
94+
assert_same 0 "$exit_code"
8995
}
9096

9197
function test_function_matches_tags_multiple_include_or_logic() {
9298
local tags="fast"
9399
local include_tags="slow,fast"
94100
local exclude_tags=""
95101

96-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
97-
assert_successful_code "$?"
102+
local exit_code=0
103+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
104+
assert_same 0 "$exit_code"
98105
}
99106

100107
function test_function_matches_tags_multiple_exclude_or_logic() {
101108
local tags="fast"
102109
local include_tags=""
103110
local exclude_tags="slow,fast"
104111

105-
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags"
106-
assert_general_error "$?"
112+
local exit_code=0
113+
bashunit::helper::function_matches_tags "$tags" "$include_tags" "$exclude_tags" || exit_code=$?
114+
assert_same 1 "$exit_code"
107115
}

0 commit comments

Comments
 (0)