onflow / onflow/flow-cli

Parallel test execution does not work when coverage is enabled

Open
#2,334 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Go
Stars
209
Forks
87
Avg merge
1d 17h
Merged PRs (30d)
3

Description

Problem

#2299 made test execution concurrent.

However, it does not work when running with coverage enabled.

For example, see https://github.com/onflow/flow-core-contracts/actions/runs/24682268286/job/72182352680?pr=605#step:7:425

$ flow test --cover --covercode="contracts" tests/*_test.cdc

fatal error: concurrent map read and map write

goroutine 46 [running]:
internal/runtime/maps.fatal({0x320a91b?, 0xc00298e3b0?})
	/root/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.1.linux-amd64/src/runtime/panic.go:1046 +0x18
github.com/onflow/cadence/runtime.(*CoverageReport).IsLocationExcluded(...)
	/root/go/pkg/mod/github.com/onflow/cadence@v1.10.2/runtime/coverage.go:151
github.com/onflow/cadence/runtime.(*CoverageReport).AddLineHit(0xc000df2ae0, {0x3ba82a0, 0xc00298e3b0}, 0x1ff)
	/root/go/pkg/mod/github.com/onflow/cadence@v1.10.2/runtime/coverage.go:160 +0x45
Steps to Reproduce
  • Run tests in parallel, with coverage enabled
Acceptance Criteria

Coverage can be collected when running tests.

Additional Info

The coverage report in Cadence is currently not thread-safe. We need to either disable concurrent test execution when coverage is enabled, or add ideally make the coverage report thread-safe.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the flow test command using --cover and --covercode, then trace how concurrent test execution reaches Cadence's CoverageReport.AddLineHit and IsLocationExcluded, as shown in the stack trace. Compare the two stated approaches: disabling concurrency for coverage or making coverage collection thread-safe. Done means parallel tests with coverage complete without the concurrent map panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.