Skip to content

Commit

Permalink
fixup! wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nhooyr committed Sep 28, 2023
1 parent 382864a commit 8b59455
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions autobahn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ func TestAutobahn(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
defer cancel()

wstestURL, closeFn, err := wstestClientServer(ctx)
wstestURL, closeFn, err := wstestServer(ctx)
assert.Success(t, err)
defer closeFn()
defer func() {
assert.Success(t, closeFn())
}()

err = waitWS(ctx, wstestURL)
assert.Success(t, err)
Expand Down Expand Up @@ -107,7 +109,9 @@ func waitWS(ctx context.Context, url string) error {
return ctx.Err()
}

func wstestClientServer(ctx context.Context) (url string, closeFn func(), err error) {
// TODO: Let docker pick the port and use docker port to find it.
// Does mean we can't use -i but that's fine.
func wstestServer(ctx context.Context) (url string, closeFn func() error, err error) {
serverAddr, err := unusedListenAddr()
if err != nil {
return "", nil, err
Expand All @@ -130,7 +134,7 @@ func wstestClientServer(ctx context.Context) (url string, closeFn func(), err er
return "", nil, fmt.Errorf("failed to write spec: %w", err)
}

ctx, cancel := context.WithTimeout(context.Background(), time.Hour)
ctx, cancel := context.WithTimeout(ctx, time.Hour)
defer func() {
if err != nil {
cancel()
Expand All @@ -147,7 +151,6 @@ func wstestClientServer(ctx context.Context) (url string, closeFn func(), err er
"-v", fmt.Sprintf("%s:%[1]s", specFile),
"-v", fmt.Sprintf("%s/ci:/ci", wd),
fmt.Sprintf("-p=%s:%s", serverAddr, serverPort),
"--name=fuzzingserver",
"crossbario/autobahn-testsuite",
)
args = append(args, "wstest", "--mode", "fuzzingserver", "--spec", specFile,
Expand All @@ -167,9 +170,12 @@ func wstestClientServer(ctx context.Context) (url string, closeFn func(), err er
}

// TODO: kill
return url, func() {
// TODO: super kill
wstest.Process.Kill()
return url, func() error {
err = wstest.Process.Kill()
if err != nil {
return fmt.Errorf("failed to kill wstest: %w", err)
}
return nil
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ if ! command -v wasmbrowsertest >/dev/null; then
fi

fmt
#AUTOBAHN=1 go test -race --timeout=1h ./... "$@"
go test -race --timeout=1h ./... "$@"

0 comments on commit 8b59455

Please sign in to comment.