From b7273e54bfe7ef2aa7bc3a44fd34edc725b0403f Mon Sep 17 00:00:00 2001 From: Marin Nozhchev Date: Mon, 8 Jun 2026 17:28:14 +0300 Subject: [PATCH 1/3] fix: ensure the module compiles on unsupported platforms skip but compile tests on unsupported platforms --- .github/workflows/ci.yml | 4 +++- Makefile | 7 ++++++- conncheck_test.go | 8 ++++++++ flags_non_aix_unix.go | 2 +- peek_generic.go | 9 +++++++++ peek_unix.go | 2 +- 6 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 peek_generic.go 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..a1b7438 100644 --- a/Makefile +++ b/Makefile @@ -20,9 +20,14 @@ 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 + export 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..4121ea0 100644 --- a/conncheck_test.go +++ b/conncheck_test.go @@ -9,6 +9,7 @@ import ( "errors" "fmt" "net" + "runtime" "syscall" "testing" "time" @@ -19,6 +20,13 @@ import ( ) func TestDo(t *testing.T) { + switch runtime.GOOS { + case "windows": + case "linux": + case "darwin": + default: + 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/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 From fb43183a3f6838e1667f6a1b4db94bce5fc29523 Mon Sep 17 00:00:00 2001 From: Marin Nozhchev Date: Mon, 8 Jun 2026 17:33:17 +0300 Subject: [PATCH 2/3] fixup --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a1b7438..365770b 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,7 @@ just-test: test-wasm: # https://go.dev/wiki/WebAssembly#executing-webassembly-with-nodejs - export PATH="$$PATH:$$(go env GOROOT)/lib/wasm" - GOOS=js GOARCH=wasm go test -timeout 15m ./... + PATH="$$PATH:$$(go env GOROOT)/lib/wasm" GOOS=js GOARCH=wasm go test -timeout 15m ./... .PHONY: short-test short-test: From 5e35e5a4edae5b086f614301a51a191584c2c86c Mon Sep 17 00:00:00 2001 From: Marin Nozhchev Date: Mon, 8 Jun 2026 17:43:19 +0300 Subject: [PATCH 3/3] fixup --- conncheck_test.go | 6 +----- ostype_generic_test.go | 5 +++++ ostype_unix_test.go | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 ostype_generic_test.go create mode 100644 ostype_unix_test.go diff --git a/conncheck_test.go b/conncheck_test.go index 4121ea0..f450cc9 100644 --- a/conncheck_test.go +++ b/conncheck_test.go @@ -20,11 +20,7 @@ import ( ) func TestDo(t *testing.T) { - switch runtime.GOOS { - case "windows": - case "linux": - case "darwin": - default: + if runtime.GOOS != "windows" && !IsUnix { t.Skip("not supported on this platform") } 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