Skip to content

Commit 50d4c39

Browse files
updated CI, fixed issues, fixed some comments
1 parent c395ba4 commit 50d4c39

7 files changed

Lines changed: 50 additions & 19 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ concurrency:
1616

1717
env:
1818
GO_VERSION: 1.21.13
19-
NODE_VERSION: 18
20-
GOLANGCI_VERSION: v1.53.3
19+
NODE_VERSION: 24
20+
GOLANGCI_VERSION: v1.59.1
2121
SOURCE_MAP_SUPPORT: true
2222
GOPATH: ${{ github.workspace }}/go
2323
GOPHERJS_PATH: ${{ github.workspace }}/go/src/github.com/${{ github.repository }}
@@ -71,9 +71,6 @@ jobs:
7171
name: Darwin Smoke
7272
runs-on: macos-latest
7373
timeout-minutes: 10
74-
env:
75-
# Node version '12' is not found for darwin.
76-
NODE_VERSION: 20
7774
steps:
7875
- uses: actions/checkout@v4
7976
with:
@@ -99,11 +96,12 @@ jobs:
9996
- uses: actions/checkout@v4
10097
with:
10198
path: ${{ env.GOPHERJS_PATH }}
99+
fetch-depth: 0
102100
- uses: actions/setup-go@v5
103101
with:
104102
go-version: ${{ env.GO_VERSION }}
105103
- name: Install golangci-lint
106-
uses: golangci/golangci-lint-action@v3
104+
uses: golangci/golangci-lint-action@v6
107105
with:
108106
working-directory: ${{ env.GOPHERJS_PATH }}
109107
version: ${{ env.GOLANGCI_VERSION }}
@@ -186,7 +184,7 @@ jobs:
186184
filter:
187185
- name: non-crypto
188186
pattern: '-Pve "^crypto"'
189-
- name: cypto
187+
- name: crypto
190188
pattern: '-Pe "^crypto"'
191189
steps:
192190
- uses: actions/checkout@v4

.golangci.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[run]
22
timeout = "1m"
33

4-
[output]
5-
format = "colored-line-number"
6-
74
[linters]
85
disable-all = true
96
enable = [
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//go:build js
2+
3+
package testenv
4+
5+
// GOPHERJS: HasSrc reports whether the entire source tree is available
6+
// under GOROOT. Since GopherJS doesn't have the untranspiled Go source tree
7+
// available at runtime, this is always false.
8+
func HasSrc() bool {
9+
return false
10+
}

compiler/natives/src/net/http/clientserver_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@ import "testing"
77
func testTransportGCRequest(t *testing.T, mode testMode, body bool) {
88
t.Skip("The test relies on runtime.SetFinalizer(), which is not supported by GopherJS.")
99
}
10-
11-
func testWriteHeaderAfterWrite(t *testing.T, mode testMode, hijack bool) {
12-
// See: https://github.com/gopherjs/gopherjs/issues/1085
13-
t.Skip("GopherJS source maps don't preserve original function names in stack traces, which this test relied on.")
14-
}

compiler/prelude/prelude.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ var $parseCallFrame = (frame) => {
138138
}
139139
return [fnName, "", 0, 0];
140140
}
141+
142+
// Node.js 24+ (V8) includes the receiver object name in stack traces,
143+
// e.g., "Object.runtime.Callers" and "typ2.github.com/...".
144+
// The `typ2` comes from prelude\types.js in `$newType`, since the `typ`
145+
// in that function gets renamed by esbuild to `typ2`, or it can be named
146+
// anything else when minimized. To avoid false positives, the following
147+
// pattern looks for specific matches, meaning we will have some false negatives.
148+
const receiverRe = /^(?:(?:Object|typ\d*)\.)|(?:[a-zA-Z_$][a-zA-Z0-9_$]*\.(github\.com[\\|/]))/;
149+
const stripReceiver = (fnName) => fnName.replace(receiverRe, "$1");
150+
141151
$parseCallFrame = (frame) => {
142152
// FireFox
143153
const atIdx = frame.indexOf("@")
@@ -163,6 +173,7 @@ var $parseCallFrame = (frame) => {
163173
if (closeIdx === -1) closeIdx = fnName.length;
164174
fnName = fnName.substring(asIdx+4, closeIdx).trim();
165175
}
176+
fnName = stripReceiver(fnName)
166177

167178
var closeIdx = frame.indexOf(")", openIdx);
168179
if (closeIdx === -1) closeIdx = frame.length;

tests/runtime_test.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,26 @@ func Test_parseCallFrame(t *testing.T) {
118118
input: "at https://example.com/angular.min.js:31:225",
119119
want: callFrame{FuncName: "<none>", File: "https://example.com/angular.min.js", Line: 31, Col: 225},
120120
},
121+
{
122+
name: "Node.js 24+ (V8) receiver prefix for package-level function",
123+
input: "at Object.runtime.Callers (runtime.go:42:3)",
124+
want: callFrame{FuncName: "runtime.Callers", File: "runtime.go", Line: 42, Col: 3},
125+
},
126+
{
127+
name: "Node.js 24+ (V8) receiver prefix for function on type",
128+
input: "at typ2.github.com/gopherjs/gopherjs/tests.callStack.capture (runtime.go:42:3)",
129+
want: callFrame{FuncName: "github.com/gopherjs/gopherjs/tests.callStack.capture", File: "runtime.go", Line: 42, Col: 3},
130+
},
131+
{
132+
name: "Node.js 24+ (V8) receiver prefix for function on type",
133+
input: "at typ2.tests.callStack.capture (runtime.go:42:3)",
134+
want: callFrame{FuncName: "tests.callStack.capture", File: "runtime.go", Line: 42, Col: 3},
135+
},
136+
{
137+
name: "Node.js 24+ (V8) receiver prefix for function on type when minified",
138+
input: "at r.github.com/gopherjs/gopherjs/tests.callStack.capture (runtime.go:42:3)",
139+
want: callFrame{FuncName: "github.com/gopherjs/gopherjs/tests.callStack.capture", File: "runtime.go", Line: 42, Col: 3},
140+
},
121141
}
122142

123143
for _, tt := range tests {
@@ -169,8 +189,8 @@ func (c *callStack) capture(amount int) {
169189
func TestCallers(t *testing.T) {
170190
// Some of the GopherJS function names don't match upstream Go, or even the
171191
// function names in the Go source when minified.
172-
// Until https://github.com/gopherjs/gopherjs/issues/1085 is resolved, the
173-
// mismatch is difficult to avoid, but we can at least use "masked" frames to
192+
// In some cases the mismatch is difficult to avoid even with source maps,
193+
// but we can at least use "masked" frames to
174194
// make sure the number of frames matches expected.
175195
opts := cmp.Comparer(func(a, b funcName) bool {
176196
if a == masked("") || b == masked("") {

tests/shadowing_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func Test_AssertType_ImplementedBy(t *testing.T) {
5353
// This is similar to `Test_AssertType_ImplementedBy` except the loop gaurd,
5454
// `seen`, in `$methodSet` was using `e.typ.string` as the key, which caused
5555
// this test to fail since the `Container`s here both have the string
56-
// `*tests.Containers`. The way they are embedded caused the inner most one
56+
// `*tests.Container`. The way they are embedded caused the inner most one
5757
// that defines `func Do() string` to be skipped, thus the cast didn't work.
5858
// Switching the key to `e.typ.id` fixes this issue.
5959
func Test_MethodSet_Seen(t *testing.T) {
@@ -146,7 +146,7 @@ type Shadow5Container struct{ *DoEmbedded }
146146

147147
func (e *Shadow5Container) Do() string { return `Try to do` }
148148

149-
// `Container5.Do` shadows `DoEmbedded.Do`.
149+
// `Shadow5Container.Do` shadows `DoEmbedded.Do`.
150150
func Test_Shadow5(t *testing.T) {
151151
c := &Shadow5Container{}
152152
shadowCheck(t, c, `Try to do`)

0 commit comments

Comments
 (0)