Repository navigation
fix(runner): detect duplicate test functions whose brace is on the next line - #1427
Merged
Chemaclass merged 1 commit intoOct 29, 2026
Merged
Conversation
…xt line
The awk definition pattern required the opening brace on the same line, so a definition written as `function test_x()` with `{` on the next line was never counted. Accept either a brace or end of line after the parentheses; the existing field match and name extraction work on the name() token alone.
Closes TypedDevs#1421
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #1421
A test file that puts the opening brace on the next line:
was not checked for duplicate test functions. Bash keeps only the last definition of a repeated name, so the first test silently never ran.
Root cause
The awk definition matcher in
src/helper/discovery.shrequired the opening brace on the same line:/...\(\)[[:space:]]*\{/A definition whose
{sits on the next line never matched, so the duplicate was never recorded.Fix
After the
name()token the pattern now accepts either an opening brace or end of line:/...\(\)[[:space:]]*(\{|$)/Same-line definitions keep matching, and the existing field match and name extraction already work on the
name()token alone. The duplicate report text is unchanged.Testing
test_check_duplicate_functions_with_the_brace_on_the_next_lineintests/unit/helper/helper_test.sh, next to the existing duplicate-function checks. It fails onmain(the check returned 0) and passes with the fix, also asserting the stored detailtest_twice (lines 1, 5)../bashunit tests/unit/helper/helper_test.sh— 88 passed, 140 assertions./bashunit tests/unit/runner/discovery_test.sh— 3 passed, 3 assertions./bashunit tests/acceptance/bashunit_duplicate_parallel_test.sh— 4 passed, 8 assertions (parallel and sequential reports, line numbers, no-duplicate file)Manual fixtures covering both styles in both modes: