Skip to content

Commit

Permalink
Add tests for --combined_report=lcov
Browse files Browse the repository at this point in the history
This includes tests for bazelbuild#3294.
See more context: bazelbuild#3343
  • Loading branch information
tingilee committed Nov 8, 2022
1 parent 497f92c commit 93b5d50
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/core/coverage/coverage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,19 @@ func TestPanic(t *testing.T) {

func TestCoverage(t *testing.T) {
t.Run("without-race", func(t *testing.T) {
testCoverage(t, "set")
testCoverage(t, "set", "bazel-testlogs/a_test/coverage.dat")
})

t.Run("with-race", func(t *testing.T) {
testCoverage(t, "atomic", "--@io_bazel_rules_go//go/config:race")
testCoverage(t, "atomic", "bazel-testlogs/a_test/coverage.dat", "--@io_bazel_rules_go//go/config:race")
})

t.Run("with-combined-lcov", func(t *testing.T) {
testCoverage(t, "set", "bazel-out/_coverage/_coverage_report.dat", "--combined_report=lcov")
})
}

func testCoverage(t *testing.T, expectedCoverMode string, extraArgs ...string) {
func testCoverage(t *testing.T, expectedCoverMode string, expectedCoveragePath string, extraArgs ...string) {
args := append([]string{"coverage"}, append(
extraArgs,
"--instrumentation_filter=-//:b",
Expand All @@ -193,7 +197,7 @@ func testCoverage(t *testing.T, expectedCoverMode string, extraArgs ...string) {
t.Fatal(err)
}

coveragePath := filepath.FromSlash("bazel-testlogs/a_test/coverage.dat")
coveragePath := filepath.FromSlash(expectedCoveragePath)
coverageData, err := ioutil.ReadFile(coveragePath)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 93b5d50

Please sign in to comment.