diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ec4b3e..17cc733 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,9 @@ jobs: - name: Build run: go build -v ./... - name: Test - run: make test + run: | + make test + make test-wasm - name: Checks run: | make checks diff --git a/Makefile b/Makefile index 2728016..365770b 100644 --- a/Makefile +++ b/Makefile @@ -20,9 +20,13 @@ test: tools/ts go tool covdata textfmt -i=./coverage/covdata -o ./coverage/covprofile go tool cover -html=./coverage/covprofile -o ./coverage/coverage.html -just_test: +just-test: go test -v -vet=all -timeout 15m ./... +test-wasm: +# https://go.dev/wiki/WebAssembly#executing-webassembly-with-nodejs + PATH="$$PATH:$$(go env GOROOT)/lib/wasm" GOOS=js GOARCH=wasm go test -timeout 15m ./... + .PHONY: short-test short-test: go test -v -short ./... diff --git a/conncheck_test.go b/conncheck_test.go index 3576f13..f450cc9 100644 --- a/conncheck_test.go +++ b/conncheck_test.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "net" + "runtime" "syscall" "testing" "time" @@ -19,6 +20,9 @@ import ( ) func TestDo(t *testing.T) { + if runtime.GOOS != "windows" && !IsUnix { + t.Skip("not supported on this platform") + } t.Run("plain", func(t *testing.T) { testSocketConn(t, nil) diff --git a/flags_non_aix_unix.go b/flags_non_aix_unix.go index a6431af..deccd66 100644 --- a/flags_non_aix_unix.go +++ b/flags_non_aix_unix.go @@ -1,4 +1,4 @@ -//go:build !windows && !aix +//go:build unix && !aix package conncheck diff --git a/ostype_generic_test.go b/ostype_generic_test.go new file mode 100644 index 0000000..fff2340 --- /dev/null +++ b/ostype_generic_test.go @@ -0,0 +1,5 @@ +//go:build !unix + +package conncheck_test + +const IsUnix = false diff --git a/ostype_unix_test.go b/ostype_unix_test.go new file mode 100644 index 0000000..26e1d37 --- /dev/null +++ b/ostype_unix_test.go @@ -0,0 +1,5 @@ +//go:build unix + +package conncheck_test + +const IsUnix = true diff --git a/peek_generic.go b/peek_generic.go new file mode 100644 index 0000000..4bf1b59 --- /dev/null +++ b/peek_generic.go @@ -0,0 +1,9 @@ +//go:build !windows && !unix + +package conncheck + +import "syscall" + +func tryPeek(rawConn syscall.RawConn) Status { + return StatusUnknown +} diff --git a/peek_unix.go b/peek_unix.go index e38b547..71bf3c6 100644 --- a/peek_unix.go +++ b/peek_unix.go @@ -1,4 +1,4 @@ -//go:build !windows +//go:build unix package conncheck