Skip to content

Duplicate test functions go undetected under --parallel #1147

Description

@Chemaclass

Problem

A file defining the same test function twice is caught sequentially and ignored
entirely under --parallel — the mode CI runs.

function test_same() { assert_same 1 1; }
function test_same() { assert_same 2 2; }
$ bashunit --no-parallel dup_test.sh
Duplicate test functions found
Duplicate functions: test_same          # exit 1

$ bashunit --parallel dup_test.sh
✓ Passed: Same
 All tests passed                        # exit 0

This matters because bash silently discards the first definition: one of the two
tests never runs. The check exists precisely to catch that, and it is off in the
mode most projects use in CI.

Cause

check_duplicate_functions runs inside call_test_functions, which
load_test_files backgrounds per file under --parallel. The state it sets
dies with the subshell, exactly like the counter in #1145 — only .result
files cross that boundary.

Fix

Run the duplicate check in the parent, before the per-file dispatch, so it is
independent of the run mode.

Also

The report names no line numbers:

Duplicate functions: test_same

In a long test file that means hunting for the second definition by hand. The
awk pass already walks every line, so recording them costs nothing.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions