@@ -6,52 +6,37 @@ Since Encore's code generation adds some extra files, this doesn't quite work.
66This patch fixes this by skipping over these files, and reading the source file
77using the overlay file system instead of directly from disk.
88
9- diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
10- index 7c0c104883..3cf8bb1fd3 100644
11- --- a/src/cmd/go/internal/load/pkg.go
12- +++ b/src/cmd/go/internal/load/pkg.go
13- @@ -3438,7 +3438,7 @@ func DeclareCoverVars(p *Package, files ...string) map[string]*CoverVar {
14- sum := sha256.Sum256([]byte(p.ImportPath))
15- h := fmt.Sprintf("%x", sum[:6])
16- for _, file := range files {
17- - if base.IsTestFile(file) {
18- + if base.IsTestFile(file) || strings.Contains(file, "encore_internal__") {
19- continue
20- }
21- // For a package that is "local" (imported via ./ import or command line, outside GOPATH),
22-
9+ diff --git a/src/cmd/go/internal/test/cover.go b/src/cmd/go/internal/test/cover.go
10+ index e295c2d90f..599a88731e 100644
11+ --- a/src/cmd/go/internal/test/cover.go
12+ +++ b/src/cmd/go/internal/test/cover.go
13+ @@ -69,7 +69,7 @@ func mergeCoverProfile(file string) {
14+ base.Errorf("test wrote malformed coverage profile %s: header %q, expected %q: %v", file, string(buf), expect, err)
15+ return
16+ }
17+ - _, err = io.Copy(coverMerge.f, r)
18+ + err = copyCoverageProfile(r, coverMerge.f)
19+ if err != nil {
20+ base.Errorf("saving coverage profile: %v", err)
21+ return
2322diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
24- index 9cf3362fbf..d309ac021c 100644
23+ index 63fd13f754..eeb79cd7f5 100644
2524--- a/src/cmd/go/internal/work/exec.go
2625+++ b/src/cmd/go/internal/work/exec.go
27- @@ -627 ,7 +627 ,7 @@ OverlayLoop:
26+ @@ -647 ,7 +647 ,7 @@ OverlayLoop:
2827 outfiles := []string{}
2928 infiles := []string{}
3029 for i, file := range str.StringList(gofiles, cgofiles) {
3130- if base.IsTestFile(file) {
3231+ if base.IsTestFile(file) || strings.Contains(file, "encore_internal__") {
3332 continue // Not covering this file.
3433 }
35-
36- @@ -646 ,6 +646 ,7 @@ OverlayLoop:
37- key = file
34+
35+ @@ -663 ,6 +663 ,7 @@ OverlayLoop:
36+ coverFile = objdir + file
3837 }
3938 coverFile = strings.TrimSuffix(coverFile, ".go") + ".cover.go"
4039+ sourceFile = fsys.Actual(sourceFile)
41- if cfg.Experiment.CoverageRedesign {
42- infiles = append(infiles, sourceFile)
43- outfiles = append(outfiles, coverFile)
44-
45- diff --git a/src/cmd/go/internal/test/cover.go b/src/cmd/go/internal/test/cover.go
46- index f614458dc4..cc449e41c3 100644
47- --- a/src/cmd/go/internal/test/cover.go
48- +++ b/src/cmd/go/internal/test/cover.go
49- @@ -69,7 +69,7 @@ func mergeCoverProfile(ew io.Writer, file string) {
50- fmt.Fprintf(ew, "error: test wrote malformed coverage profile %s.\n", file)
51- return
52- }
53- - _, err = io.Copy(coverMerge.f, r)
54- + err = copyCoverageProfile(r, coverMerge.f)
55- if err != nil {
56- fmt.Fprintf(ew, "error: saving coverage profile: %v\n", err)
57- }
40+ infiles = append(infiles, sourceFile)
41+ outfiles = append(outfiles, coverFile)
42+ if i < len(gofiles) {
0 commit comments