File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 88 "golang.org/x/tools/cover"
99
1010 . "github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/coverage"
11+ "github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/path"
1112 "github.com/vladopajic/go-test-coverage/v2/pkg/testcoverage/testdata"
1213)
1314
@@ -97,12 +98,12 @@ func Test_findFile(t *testing.T) {
9798 file , noPrefixName , err := FindFile (prefix + "/" + filename , "" )
9899 assert .NoError (t , err )
99100 assert .Equal (t , filename , noPrefixName )
100- assert .True (t , strings .HasSuffix (file , filename ))
101+ assert .True (t , strings .HasSuffix (file , path . NormalizeForOS ( filename ) ))
101102
102103 file , noPrefixName , err = FindFile (prefix + "/" + filename , prefix )
103104 assert .NoError (t , err )
104105 assert .Equal (t , filename , noPrefixName )
105- assert .True (t , strings .HasSuffix (file , filename ))
106+ assert .True (t , strings .HasSuffix (file , path . NormalizeForOS ( filename ) ))
106107
107108 _ , _ , err = FindFile (prefix + "/main1.go" , "" )
108109 assert .Error (t , err )
Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ import (
88
99const separatorToReplace = string (filepath .Separator )
1010
11+ func NormalizeForOS (path string ) string {
12+ if runtime .GOOS != "windows" {
13+ return path
14+ }
15+
16+ return strings .ReplaceAll (path , "/" , separatorToReplace )
17+ }
18+
1119func NormalizeForTool (path string ) string {
1220 if runtime .GOOS != "windows" {
1321 return path
You can’t perform that action at this time.
0 commit comments