Skip to content

Parallel test execution does not work when coverage is enabled #2334

@turbolent

Description

@turbolent

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThe issue represents a bug, malfunction, regression

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions