Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion internal/coverage/coverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,5 @@ func (c *Coverage) removeModuleFromPath(p *cover.Profile) string {
path := strings.ReplaceAll(p.FileName, c.mod.Name+"/", "")
path, _ = filepath.Rel(c.mod.CallingDir, path)

return path
return filepath.ToSlash(path) // normalize to slashes
}
18 changes: 18 additions & 0 deletions internal/coverage/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,3 +215,21 @@
})
}
}

func TestIsCovered_PathsWithSlashes(t *testing.T) {
profile := coverage.Profile{

Check failure on line 220 in internal/coverage/profile_test.go

View workflow job for this annotation

GitHub Actions / Validate source code with linters

File is not properly formatted (goimports)
"internal/coverage/file.go": []coverage.Block{
{StartLine: 10, StartCol: 1, EndLine: 20, EndCol: 1},
},
}

pos := token.Position{
Filename: "internal/coverage/file.go",
Line: 15,
Column: 5,
}

if !profile.IsCovered(pos) {
t.Error("expected position to be covered")
}
}
12 changes: 10 additions & 2 deletions internal/engine/stubs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package engine_test

import (
"errors"
"fmt"
"go/token"
"io"
"os"
Expand Down Expand Up @@ -56,8 +57,15 @@ func viperReset() {

func loadFixture(fixture, fromPackage string) (fstest.MapFS, gomodule.GoModule, func()) {
//nolint:gosec // test code reading test fixtures
f, _ := os.Open(fixture)
src, _ := io.ReadAll(f)
f, err := os.Open(fixture)
if err != nil {
panic(fmt.Sprintf("failed to open test fixture %s: %v", fixture, err))
}
src, err := io.ReadAll(f)
if err != nil {
_ = f.Close()
panic(fmt.Sprintf("failed to read test fixture %s: %v", fixture, err))
}
filename := filenameFromFixture(fixture)
mapFS := fstest.MapFS{
filename: {Data: src},
Expand Down
Loading