Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/coverage/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ package coverage

import (
"go/token"
"os"
"strings"
)

// Profile is implemented as a map holding a slice of Block per each filename.
type Profile map[string][]Block

// IsCovered checks if the given token.Position is covered by the coverage Profile.
func (p Profile) IsCovered(pos token.Position) bool {
// normalise path separators
if strings.ContainsRune(pos.Filename, '/') {
pos.Filename = strings.ReplaceAll(pos.Filename, "/", string(os.PathSeparator))
}

blocks, ok := p[pos.Filename]
if !ok {
return false
Expand Down
2 changes: 2 additions & 0 deletions internal/engine/stubs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func loadFixture(fixture, fromPackage string) (fstest.MapFS, gomodule.GoModule,
}

func filenameFromFixture(fix string) string {
// Replace the path separator with the OS specific one.
fix = strings.ReplaceAll(fix, "/", string(os.PathSeparator))
return strings.ReplaceAll(fix, "_go", ".go")
}

Expand Down