Skip to content

Commit a0eb892

Browse files
Adding more overrides
1 parent 504352d commit a0eb892

File tree

8 files changed

+74
-10
lines changed

8 files changed

+74
-10
lines changed

compiler/natives/src/internal/godebug/godebug.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ func (s *Setting) Value() string {
4444
// again each time the environment variable changes
4545
// (due to use of os.Setenv, for example).
4646
//
47-
// GOPHERJS: For JS we currently will not be able
48-
// to access $GODEBUG via process.env nor watch
49-
// for changes via syscall.runtimeSetenv and
50-
// syscall.runtimeUnsetenv
47+
// GOPHERJS: Currently we don't inject a proxy into process.env to watch
48+
// for changes via syscall.runtimeSetenv and syscall.runtimeUnsetenv.
49+
// We may want to look into this in the future.
5150
func setUpdate(update func(string, string)) {}
5251

5352
func update(def, env string) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
"testing"
77
)
88

9-
func testClientTimeout(t *testing.T, h2 bool) {
9+
func testClientTimeout(t *testing.T, mode testMode) {
1010
// The original test expects Client.Timeout error to be returned, but under
1111
// GopherJS an "i/o timeout" error is frequently returned. Otherwise the test
1212
// seems to be working correctly.
1313
t.Skip("Flaky test under GopherJS.")
1414
}
1515

16-
func testClientTimeout_Headers(t *testing.T, h2 bool) {
16+
func testClientTimeout_Headers(t *testing.T, mode testMode) {
1717
// The original test expects Client.Timeout error to be returned, but under
1818
// GopherJS an "i/o timeout" error is frequently returned. Otherwise the test
1919
// seems to be working correctly.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import (
77
"testing"
88
)
99

10-
func testTransportGCRequest(t *testing.T, h2, body bool) {
10+
func testTransportGCRequest(t *testing.T, mode testMode, body bool) {
1111
t.Skip("The test relies on runtime.SetFinalizer(), which is not supported by GopherJS.")
1212
}
1313

14-
func testWriteHeaderAfterWrite(t *testing.T, h2, hijack bool) {
14+
func testWriteHeaderAfterWrite(t *testing.T, mode testMode, hijack bool) {
1515
t.Skip("GopherJS source maps don't preserve original function names in stack traces, which this test relied on.")
1616
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ package http
66
import (
77
"bufio"
88
"bytes"
9+
"context"
10+
"crypto/tls"
911
"errors"
1012
"io"
13+
"net"
1114
"net/textproto"
1215
"strconv"
16+
"sync"
17+
"sync/atomic"
1318

1419
"github.com/gopherjs/gopherjs/js"
1520
)
@@ -113,3 +118,30 @@ func (t *XHRTransport) CancelRequest(req *Request) {
113118
xhr.Call("abort")
114119
}
115120
}
121+
122+
type conn struct {
123+
server *Server
124+
cancelCtx context.CancelFunc
125+
rwc net.Conn
126+
remoteAddr string
127+
tlsState *tls.ConnectionState
128+
werr error
129+
r *connReader
130+
bufr *bufio.Reader
131+
bufw *bufio.Writer
132+
lastMethod string
133+
134+
// temporarily replacement of `atomic.Pointer[response]` for go1.20 without generics.
135+
curReq atomicResponsePointer
136+
137+
curState atomic.Uint64
138+
mu sync.Mutex
139+
hijackedv bool
140+
}
141+
142+
type atomicResponsePointer struct {
143+
v *response
144+
}
145+
146+
func (x *atomicResponsePointer) Load() *response { return x.v }
147+
func (x *atomicResponsePointer) Store(val *response) { x.v = val }

compiler/natives/src/strings/strings_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ func TestCompareStrings(t *testing.T) {
1818
}
1919

2020
func TestClone(t *testing.T) {
21-
t.Skip("conversion to reflect.StringHeader is not supported in GopherJS")
21+
t.Skip("conversion to unsafe.StringData is not supported in GopherJS")
22+
}
23+
24+
func TestMap(t *testing.T) {
25+
t.Skip("identity test uses unsafe.StringData is not supported in GopherJS")
2226
}

compiler/natives/src/sync/atomic/atomic.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,19 @@ func sameType(x, y interface{}) bool {
221221
return js.InternalObject(x).Get("constructor") == js.InternalObject(y).Get("constructor")
222222
}
223223

224-
//gopherjs:purge for go1.19 without generics
224+
// Override pointer so that the type check in the source code is satisfied
225+
// but remove the fields and methods for go1.20 without generics.
226+
// See https://cs.opensource.google/go/go/+/refs/tags/go1.20.14:src/sync/atomic/type.go;l=40
225227
type Pointer[T any] struct{}
228+
229+
//gopherjs:purge for go1.20 without generics
230+
func (x *Pointer[T]) Load() *T
231+
232+
//gopherjs:purge for go1.20 without generics
233+
func (x *Pointer[T]) Store(val *T)
234+
235+
//gopherjs:purge for go1.20 without generics
236+
func (x *Pointer[T]) Swap(new *T) (old *T)
237+
238+
//gopherjs:purge for go1.20 without generics
239+
func (x *Pointer[T]) CompareAndSwap(old, new *T) (swapped bool)

compiler/natives/src/syscall/syscall_js_wasm.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ func runtime_envs() []string {
2222
return envs
2323
}
2424

25+
func runtimeSetenv(k, v string) {
26+
setenv_c(k, v)
27+
}
28+
29+
func runtimeUnsetenv(k string) {
30+
unsetenv_c(k)
31+
}
32+
2533
func setenv_c(k, v string) {
2634
process := js.Global().Get("process")
2735
if process.IsUndefined() {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//go:build js
2+
// +build js
3+
4+
package time
5+
6+
// replaced for go1.20 temporarily without generics.
7+
var ParseRFC3339 = parseRFC3339

0 commit comments

Comments
 (0)