Skip to content

Commit 297f55d

Browse files
André Erikssoneandre
authored andcommitted
Update patches to apply for Go 1.25
1 parent 7ef42ee commit 297f55d

3 files changed

Lines changed: 48 additions & 62 deletions

File tree

patches/cover_patch.diff

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,37 @@ Since Encore's code generation adds some extra files, this doesn't quite work.
66
This patch fixes this by skipping over these files, and reading the source file
77
using 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
2322
diff --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) {

patches/testing_patch.diff

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,51 @@ test runs against global state. This patch introduces a per test level callback
66
test and not have state between tests interfere with each other.
77

88
diff --git a/src/testing/testing.go b/src/testing/testing.go
9-
index 5c06aea5f8..0db6bb40ab 100644
9+
index 3475bfca4a..074755aef1 100644
1010
--- a/src/testing/testing.go
1111
+++ b/src/testing/testing.go
12-
@@ -767,6 +767,12 @@ func (c *common) frameSkip(skip int) runtime.Frame {
13-
// and inserts the final newline if needed and indentation spaces for formatting.
14-
// This function must be called with c.mu held.
15-
func (c *common) decorate(s string, skip int) string {
12+
@@ -1017,6 +1017,12 @@ func (c *common) FailNow() {
13+
// indentation and the final newline if necessary. It prefixes the string
14+
// with the file and line of the call site.
15+
func (c *common) log(s string) {
1616
+ // allow encore to capture the log as well;
1717
+ // we do it here so that all the branches which result in a log message
18-
+ // during tests get captured, however we do it _before_ the liens get modified
18+
+ // during tests get captured, however we do it _before_ the lines get modified
1919
+ // and indented.
20-
+ encoreTestLog(s, skip+1)
20+
+ encoreTestLog(s, 3)
2121
+
22-
frame := c.frameSkip(skip)
23-
file := frame.File
24-
line := frame.Line
25-
@@ -1479,10 +1485,14 @@ func (t *T) Parallel() {
22+
s = strings.TrimSuffix(s, "\n")
23+
24+
// Second and subsequent lines are indented 4 spaces. This is in addition to
25+
@@ -1704,11 +1710,15 @@ func (t *T) Parallel() {
2626
}
2727
running.Delete(t.name)
28-
28+
2929
+ encorePauseTest(t)
3030
+
3131
t.signal <- true // Release calling test.
3232
<-t.parent.barrier // Wait for the parent test to complete.
33-
t.context.waitParallel()
34-
33+
t.tstate.waitParallel()
34+
parallelStart.Add(1)
35+
3536
+ encoreResumeTest(t)
3637
+
3738
if t.chatty != nil {
3839
t.chatty.Updatef(t.name, "=== CONT %s\n", t.name)
3940
}
40-
@@ -1538,6 +1548,7 @@ var errNilPanicOrGoexit = errors.New("test executed panic(nil) or runtime.Goexit
41-
41+
@@ -1773,6 +1783,7 @@ var errNilPanicOrGoexit = errors.New("test executed panic(nil) or runtime.Goexit
42+
4243
func tRunner(t *T, fn func(t *T)) {
4344
t.runner = callerName(0)
4445
+ encoreStartTest(t, fn)
45-
46+
4647
// When this goroutine is done, either because fn(t)
4748
// returned normally or because a test failure triggered
48-
@@ -1545,6 +1556,7 @@ func tRunner(t *T, fn func(t *T)) {
49+
@@ -1780,6 +1791,7 @@ func tRunner(t *T, fn func(t *T)) {
4950
// a signal saying that the test is done.
5051
defer func() {
5152
t.checkRaces()
5253
+ encoreEndTest(t)
53-
54+
5455
// TODO(#61034): This is the wrong place for this check.
5556
if t.Failed() {

patches/version_patch.diff

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ to:
1010
`go version go1.21.0-encore darwin/arm64`
1111

1212
diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
13-
index 8973a87168..8fd7b01a15 100644
13+
index 024050c2dd..01be354b3d 100644
1414
--- a/src/cmd/dist/build.go
1515
+++ b/src/cmd/dist/build.go
16-
@@ -393,7 +393,8 @@ func findgoversion() string {
16+
@@ -406,7 +406,8 @@ func findgoversion() string {
1717
// its content if available, which is empty at this point.
1818
// Only use the VERSION file if it is non-empty.
1919
if b != "" {
@@ -22,13 +22,13 @@ index 8973a87168..8fd7b01a15 100644
2222
+ return strings.TrimSuffix(b, "-encore") + "-encore"
2323
}
2424
}
25-
26-
@@ -424,7 +425,7 @@ func findgoversion() string {
25+
26+
@@ -441,7 +442,7 @@ func findgoversion() string {
2727
if m == nil {
2828
fatalf("internal/goversion/goversion.go does not contain 'const Version = ...'")
2929
}
30-
- version := fmt.Sprintf("devel go1.%s-", m[1])
31-
+ version := fmt.Sprintf("devel go1.%s-encore-", m[1])
30+
- version := fmt.Sprintf("go1.%s-devel_", m[1])
31+
+ version := fmt.Sprintf("go1.%s-devel-encore_", m[1])
3232
version += chomp(run(goroot, CheckExit, "git", "log", "-n", "1", "--format=format:%h %cd", "HEAD"))
33-
33+
3434
// Cache version.

0 commit comments

Comments
 (0)