From 6bba2b73d730cd63b5518ac95a8ec077d3e609a4 Mon Sep 17 00:00:00 2001 From: vivganes Date: Wed, 13 Aug 2025 04:47:33 +0530 Subject: [PATCH] fix #222 --- internal/coverage/profile.go | 7 +++++++ internal/engine/stubs_test.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/internal/coverage/profile.go b/internal/coverage/profile.go index 39438859..0ef06ec9 100644 --- a/internal/coverage/profile.go +++ b/internal/coverage/profile.go @@ -18,6 +18,8 @@ package coverage import ( "go/token" + "os" + "strings" ) // Profile is implemented as a map holding a slice of Block per each filename. @@ -25,6 +27,11 @@ 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 diff --git a/internal/engine/stubs_test.go b/internal/engine/stubs_test.go index ff7c775e..7ed77b7f 100644 --- a/internal/engine/stubs_test.go +++ b/internal/engine/stubs_test.go @@ -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") }