From 92bb0a0ba906e9d3b2fa1b3eac2ef9068df4c879 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Tue, 13 Aug 2024 17:49:03 -0700 Subject: [PATCH] Context lint. Signed-off-by: Nuno Cruces --- .github/workflows/commit.yaml | 2 +- Makefile | 2 +- experimental/close_test.go | 4 +++- experimental/logging/log_listener_test.go | 4 +++- experimental/sock/sock_test.go | 4 +++- imports/assemblyscript/assemblyscript_test.go | 4 +++- imports/emscripten/emscripten_test.go | 4 +++- imports/wasi_snapshot_preview1/wasi_test.go | 4 +++- internal/engine/interpreter/interpreter_test.go | 4 +++- internal/integration_test/bench/bench_test.go | 4 +++- internal/integration_test/engine/adhoc_test.go | 4 +++- internal/wasm/gofunc_test.go | 4 +++- runtime_test.go | 4 +++- 13 files changed, 35 insertions(+), 13 deletions(-) diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index 50fcde7a54..01cd1a3f12 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -14,7 +14,7 @@ on: - 'netlify.toml' env: # Update this prior to requiring a higher minor version in go.mod - GO_VERSION: "1.22" + GO_VERSION: "1.23" defaults: run: # use bash for all operating systems unless overridden diff --git a/Makefile b/Makefile index f1ab01b353..17e264e01c 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ gofumpt := mvdan.cc/gofumpt@v0.6.0 gosimports := github.com/rinchsan/gosimports/cmd/gosimports@v0.3.8 -golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 +golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.0 asmfmt := github.com/klauspost/asmfmt/cmd/asmfmt@v1.3.2 # sync this with netlify.toml! hugo := github.com/gohugoio/hugo@v0.115.2 diff --git a/experimental/close_test.go b/experimental/close_test.go index 5c3ad81745..9d88ed89bd 100644 --- a/experimental/close_test.go +++ b/experimental/close_test.go @@ -9,8 +9,10 @@ import ( "github.com/tetratelabs/wazero/internal/testing/require" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") func TestWithCloseNotifier(t *testing.T) { tests := []struct { diff --git a/experimental/logging/log_listener_test.go b/experimental/logging/log_listener_test.go index 284cbb94f8..2cc953edbe 100644 --- a/experimental/logging/log_listener_test.go +++ b/experimental/logging/log_listener_test.go @@ -15,8 +15,10 @@ import ( "github.com/tetratelabs/wazero/internal/wasm" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") func Test_loggingListener(t *testing.T) { wasiFuncName := wasi.RandomGetName diff --git a/experimental/sock/sock_test.go b/experimental/sock/sock_test.go index d81be2d369..f14b8ab208 100644 --- a/experimental/sock/sock_test.go +++ b/experimental/sock/sock_test.go @@ -9,8 +9,10 @@ import ( "github.com/tetratelabs/wazero/internal/testing/require" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") func TestWithSockConfig(t *testing.T) { tests := []struct { diff --git a/imports/assemblyscript/assemblyscript_test.go b/imports/assemblyscript/assemblyscript_test.go index 04bb74db1e..71b4736cda 100644 --- a/imports/assemblyscript/assemblyscript_test.go +++ b/imports/assemblyscript/assemblyscript_test.go @@ -24,8 +24,10 @@ import ( "github.com/tetratelabs/wazero/sys" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") func TestAbort(t *testing.T) { tests := []struct { diff --git a/imports/emscripten/emscripten_test.go b/imports/emscripten/emscripten_test.go index 5bad84a137..3ce7eabf74 100644 --- a/imports/emscripten/emscripten_test.go +++ b/imports/emscripten/emscripten_test.go @@ -35,8 +35,10 @@ var growWasm []byte //go:embed testdata/invoke.wasm var invokeWasm []byte +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") // TestGrow is an integration test until we have an Emscripten example. func TestGrow(t *testing.T) { diff --git a/imports/wasi_snapshot_preview1/wasi_test.go b/imports/wasi_snapshot_preview1/wasi_test.go index 7b250b29b7..4808dcc916 100644 --- a/imports/wasi_snapshot_preview1/wasi_test.go +++ b/imports/wasi_snapshot_preview1/wasi_test.go @@ -18,8 +18,10 @@ import ( "github.com/tetratelabs/wazero/sys" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") const testMemoryPageSize = 1 diff --git a/internal/engine/interpreter/interpreter_test.go b/internal/engine/interpreter/interpreter_test.go index 6ac98909b3..f7606a3195 100644 --- a/internal/engine/interpreter/interpreter_test.go +++ b/internal/engine/interpreter/interpreter_test.go @@ -12,8 +12,10 @@ import ( "github.com/tetratelabs/wazero/internal/wasm" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") func TestInterpreter_peekValues(t *testing.T) { ce := &callEngine{} diff --git a/internal/integration_test/bench/bench_test.go b/internal/integration_test/bench/bench_test.go index 5cf468564f..5dacbfc699 100644 --- a/internal/integration_test/bench/bench_test.go +++ b/internal/integration_test/bench/bench_test.go @@ -14,8 +14,10 @@ import ( "github.com/tetratelabs/wazero/internal/platform" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") // caseWasm was compiled from TinyGo testdata/case.go // diff --git a/internal/integration_test/engine/adhoc_test.go b/internal/integration_test/engine/adhoc_test.go index 2f4f5e2623..fd7223e49c 100644 --- a/internal/integration_test/engine/adhoc_test.go +++ b/internal/integration_test/engine/adhoc_test.go @@ -88,8 +88,10 @@ func TestEngineInterpreter(t *testing.T) { runAllTests(t, tests, wazero.NewRuntimeConfigInterpreter().WithCloseOnContextDone(true), false) } +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") const i32, i64, f32, f64, v128 = wasm.ValueTypeI32, wasm.ValueTypeI64, wasm.ValueTypeF32, wasm.ValueTypeF64, wasm.ValueTypeV128 diff --git a/internal/wasm/gofunc_test.go b/internal/wasm/gofunc_test.go index 8b2e8b8c26..802fd53011 100644 --- a/internal/wasm/gofunc_test.go +++ b/internal/wasm/gofunc_test.go @@ -10,8 +10,10 @@ import ( "github.com/tetratelabs/wazero/internal/testing/require" ) +type arbitrary struct{} + // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. -var testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") +var testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") func Test_parseGoFunc(t *testing.T) { tests := []struct { diff --git a/runtime_test.go b/runtime_test.go index b7fce3891f..60b280b644 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -19,10 +19,12 @@ import ( "github.com/tetratelabs/wazero/sys" ) +type arbitrary struct{} + var ( binaryNamedZero = binaryencoding.EncodeModule(&wasm.Module{NameSection: &wasm.NameSection{ModuleName: "0"}}) // testCtx is an arbitrary, non-default context. Non-nil also prevents linter errors. - testCtx = context.WithValue(context.Background(), struct{}{}, "arbitrary") + testCtx = context.WithValue(context.Background(), arbitrary{}, "arbitrary") ) var _ context.Context = &HostContext{}