sbt/testing
PandaMan 20ce3abe5f
[2.x] fix: Fixes testing EventHandler race condition
**Problem**
ScalaTest's `AsyncFunSuite` invokes the test framework's event handler **asynchronously**. sbt's `TestFramework` was collecting events in a **`ListBuffer`**, which is not thread-safe. With multiple suites (e.g. `IgnoreBugTestA` and `IgnoreBugTestB`), concurrent `handle()` calls could corrupt the buffer, so events from the second suite were lost or merged incorrectly and the summary showed wrong suite/test counts.

**Solution**
Replaced the event buffer in `sbt.TestFramework`'s `EventHandler` with a **thread-safe** collection: **`CopyOnWriteArrayList`** (from `java.util.concurrent`). Event handling now uses:
- `CopyOnWriteArrayList[Event]` for `results`
- `results.add(e)` in the handler
- `results.asScala.toList` when building `TestEvent` / `SuiteResult` (via `scala.jdk.CollectionConverters._`)

This preserves ordering and ensures all suites' events are reported correctly when using async styles like `AsyncFunSuite` with `test`/`ignore`.
2026-02-09 10:55:06 -05:00
..
src [2.x] fix: Fixes testing EventHandler race condition 2026-02-09 10:55:06 -05:00
NOTICE Transfer copyright to Scala Center 2023-06-20 16:39:07 +02:00