Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a9618cb

Browse files
committedSep 22, 2019
Fix byte sizes
1 parent e301872 commit a9618cb

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed
 

‎.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ on: [push]
44
jobs:
55
fmt:
66
runs-on: ubuntu-latest
7-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
7+
container: docker://nhooyr/websocket-ci@sha256:b6331f8f64803c8b1bbd2a0ee9e2547317e0de2348bccd9c8dbcc1d88ff5747f
88
steps:
99
- uses: actions/checkout@v1
1010
with:
1111
fetch-depth: 1
1212
- run: ./ci/fmt.sh
1313
lint:
1414
runs-on: ubuntu-latest
15-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
15+
container: docker://nhooyr/websocket-ci@sha256:b6331f8f64803c8b1bbd2a0ee9e2547317e0de2348bccd9c8dbcc1d88ff5747f
1616
steps:
1717
- uses: actions/checkout@v1
1818
with:
1919
fetch-depth: 1
2020
- run: ./ci/lint.sh
2121
test:
2222
runs-on: ubuntu-latest
23-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
23+
container: docker://nhooyr/websocket-ci@sha256:b6331f8f64803c8b1bbd2a0ee9e2547317e0de2348bccd9c8dbcc1d88ff5747f
2424
steps:
2525
- uses: actions/checkout@v1
2626
with:
@@ -30,7 +30,7 @@ jobs:
3030
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3131
wasm:
3232
runs-on: ubuntu-latest
33-
container: docker://nhooyr/websocket-ci@sha256:97aa0fddfcf1ba7d90a21b1e7978884b7f4c1ca9668d2ed1891ff61f778aeaf0
33+
container: docker://nhooyr/websocket-ci@sha256:b6331f8f64803c8b1bbd2a0ee9e2547317e0de2348bccd9c8dbcc1d88ff5747f
3434
steps:
3535
- uses: actions/checkout@v1
3636
with:

‎ci/fmt.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fmt() {
1818
go run go.coder.com/go-tools/cmd/goimports -w "-local=$(go list -m)" .
1919
go run mvdan.cc/sh/cmd/shfmt -i 2 -w -s -sr .
2020
# shellcheck disable=SC2046
21-
npx prettier \
21+
npx -q prettier \
2222
--write \
2323
--print-width 120 \
2424
--no-semi \

‎ci/wasm.sh

+14-12
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ set -euo pipefail
44
cd "$(dirname "${0}")"
55
cd "$(git rev-parse --show-toplevel)"
66

7-
stdout="$(mktemp -d)/stdout"
8-
mkfifo "$stdout"
9-
go run ./internal/wsecho/cmd > "$stdout" &
10-
11-
WS_ECHO_SERVER_URL="$(head -n 1 "$stdout")"
12-
137
GOOS=js GOARCH=wasm go vet ./...
8+
149
go install golang.org/x/lint/golint
1510
GOOS=js GOARCH=wasm golint -set_exit_status ./...
11+
12+
wsEchoOut="$(mktemp -d)/stdout"
13+
mkfifo "$wsEchoOut"
14+
go install ./internal/wsecho/cmd/wsecho
15+
wsecho > "$wsEchoOut" &
16+
17+
WS_ECHO_SERVER_URL="$(timeout 10s head -n 1 "$wsEchoOut")" || true
18+
if [[ -z $WS_ECHO_SERVER_URL ]]; then
19+
echo "./internal/wsecho/cmd/wsecho failed to start in 10s"
20+
exit 1
21+
fi
22+
1623
go install github.com/agnivade/wasmbrowsertest
17-
GOOS=js GOARCH=wasm go test -exec="wasmbrowsertest" ./... -args "$WS_ECHO_SERVER_URL"
24+
GOOS=js GOARCH=wasm go test -exec=wasmbrowsertest ./... -args "$WS_ECHO_SERVER_URL"
1825

19-
echo kill
20-
jobs
2126
kill %1
22-
echo wait
2327
wait -n || true
24-
jobs
25-
echo over
File renamed without changes.

‎internal/wsecho/wsecho.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ func Serve(w http.ResponseWriter, r *http.Request) {
3030

3131
// Loop echos every msg received from c until an error
3232
// occurs or the context expires.
33-
// The read limit is set to 1 << 40.
33+
// The read limit is set to 1 << 30.
3434
func Loop(ctx context.Context, c *websocket.Conn) {
3535
defer c.Close(websocket.StatusInternalError, "")
3636

37-
c.SetReadLimit(1 << 40)
37+
c.SetReadLimit(1 << 30)
3838

3939
ctx, cancel := context.WithTimeout(ctx, time.Minute)
4040
defer cancel()
4141

42-
b := make([]byte, 32768)
42+
b := make([]byte, 32<<10)
4343
echo := func() error {
4444
typ, r, err := c.Reader(ctx)
4545
if err != nil {

‎websocket_js_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ package websocket_test
22

33
import (
44
"context"
5+
"flag"
56
"net/http"
6-
"os"
77
"testing"
88
"time"
99

1010
"nhooyr.io/websocket"
1111
)
1212

13-
var wsEchoServerURL = os.Args[1]
14-
1513
func TestWebSocket(t *testing.T) {
1614
t.Parallel()
1715

18-
t.Skip("???")
16+
wsEchoServerURL := flag.Arg(0)
1917

2018
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
2119
defer cancel()

‎websocket_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -963,14 +963,14 @@ func TestAutobahn(t *testing.T) {
963963
return err
964964
}
965965
defer c.Close(websocket.StatusInternalError, "")
966-
c.SetReadLimit(1 << 40)
967966

968967
ctx := r.Context()
969968
if testingClient {
970969
wsecho.Loop(r.Context(), c)
971970
return nil
972971
}
973972

973+
c.SetReadLimit(1 << 30)
974974
err = fn(ctx, c)
975975
if err != nil {
976976
return err
@@ -997,9 +997,9 @@ func TestAutobahn(t *testing.T) {
997997
t.Fatal(err)
998998
}
999999
defer c.Close(websocket.StatusInternalError, "")
1000-
c.SetReadLimit(1 << 40)
10011000

10021001
if testingClient {
1002+
c.SetReadLimit(1 << 30)
10031003
err = fn(ctx, c)
10041004
if err != nil {
10051005
t.Fatalf("client failed: %+v", err)

0 commit comments

Comments
 (0)