From 57a705e5945e043fc070d0dc3071e141fec38c5a Mon Sep 17 00:00:00 2001 From: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> Date: Fri, 19 Aug 2022 14:52:50 +0800 Subject: [PATCH] Disallows nil context and fixes linters (#754) staticcheck linters broke until recent golangci-lint. Now, normal behaviour of enforcing no nil context works again. Ex. ``` assemblyscript/assemblyscript_example_test.go:16:25: SA1012: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (staticcheck) r := wazero.NewRuntime(nil) ``` Since default lint already checks for nil context, this removes our permission of nil context args. The original reason we permitted nil is no longer valid: we once allowed context to be stashed in config, and removed that as it caused bugs. We forgot to undo allowing nil explicitly. Note: this doesn't particularly check in our code for nil context, similar as we don't particularly check in our code for nil anything else. End users should use linters as none of our parameters should be nil anyway. Signed-off-by: Adrian Cole --- .github/workflows/examples.yaml | 2 +- Makefile | 6 +-- api/wasm.go | 11 +++--- config.go | 2 - .../allocation/tinygo/testdata/greet.wasm | Bin 63160 -> 63191 bytes examples/assemblyscript/assemblyscript.go | 3 +- examples/wasi/cat.go | 1 - examples/wasi/testdata/tinygo/cat.wasm | Bin 60038 -> 60353 bytes internal/engine/compiler/engine.go | 3 +- .../fuzzcases/fuzzcases_test.go | 1 - internal/wasm/call_context.go | 8 ---- internal/wasm/global.go | 12 ------ internal/wasm/memory.go | 34 ---------------- internal/wasm/store.go | 6 --- internal/wazeroir/compiler.go | 5 +-- namespace.go | 1 - netlify.toml | 2 +- runtime.go | 9 ----- runtime_test.go | 37 +++++------------- 19 files changed, 22 insertions(+), 121 deletions(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index de715149..50983913 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -43,7 +43,7 @@ jobs: - name: Install TinyGo run: | # installing via curl so commands are similar on OS/x - tinygo_version=0.24.0 + tinygo_version=0.25.0 curl -sSL https://github.com/tinygo-org/tinygo/releases/download/v${tinygo_version}/tinygo${tinygo_version}.linux-amd64.tar.gz | sudo tar -C /usr/local -xzf - echo "TINYGOROOT=/usr/local/tinygo" >> $GITHUB_ENV echo "/usr/local/tinygo/bin" >> $GITHUB_PATH diff --git a/Makefile b/Makefile index d5e3a363..a8196c40 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ comma := , space := space += -goimports := golang.org/x/tools/cmd/goimports@v0.1.10 -golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2 +goimports := golang.org/x/tools/cmd/goimports@v0.1.12 +golangci_lint := github.com/golangci/golangci-lint/cmd/golangci-lint@v1.48.0 # sync this with netlify.toml! -hugo := github.com/gohugoio/hugo@v0.100.0 +hugo := github.com/gohugoio/hugo@v0.101.0 # Make 3.81 doesn't support '**' globbing: Set explicitly instead of recursion. all_sources := $(wildcard *.go */*.go */*/*.go */*/*/*.go */*/*/*.go */*/*/*/*.go) diff --git a/api/wasm.go b/api/wasm.go index 3c31f3e9..c427a8eb 100644 --- a/api/wasm.go +++ b/api/wasm.go @@ -157,7 +157,7 @@ type Module interface { ExportedGlobal(name string) Global // CloseWithExitCode releases resources allocated for this Module. Use a non-zero exitCode parameter to indicate a - // failure to ExportedFunction callers. When the context is nil, it defaults to context.Background. + // failure to ExportedFunction callers. // // The error returned here, if present, is about resource de-allocation (such as I/O errors). Only the last error is // returned, so a non-nil return means at least one error happened. Regardless of error, this module instance will @@ -175,7 +175,7 @@ type Module interface { // // Note: This is an interface for decoupling, not third-party implementations. All implementations are in wazero. type Closer interface { - // Close closes the resource. When the context is nil, it defaults to context.Background. + // Close closes the resource. Close(context.Context) error } @@ -267,7 +267,7 @@ type Function interface { // Call invokes the function with parameters encoded according to ParamTypes. Up to one result is returned, // encoded according to ResultTypes. An error is returned for any failure looking up or invoking the function - // including signature mismatch. When the context is nil, it defaults to context.Background. + // including signature mismatch. // // If Module.Close or Module.CloseWithExitCode were invoked during this call, the error returned may be a // sys.ExitError. Interpreting this is specific to the module. For example, some "main" functions always call a @@ -298,7 +298,7 @@ type Global interface { // Type describes the numeric type of the global. Type() ValueType - // Get returns the last known value of this global. When the context is nil, it defaults to context.Background. + // Get returns the last known value of this global. // // See Type for how to encode this value from a Go type. Get(context.Context) uint64 @@ -308,7 +308,7 @@ type Global interface { type MutableGlobal interface { Global - // Set updates the value of this global. When the context is nil, it defaults to context.Background. + // Set updates the value of this global. // // See Global.Type for how to decode this value to a Go type. Set(ctx context.Context, v uint64) @@ -318,7 +318,6 @@ type MutableGlobal interface { // // # Notes // -// - All functions accept a context.Context, which when nil, default to context.Background. // - This is an interface for decoupling, not third-party implementations. All implementations are in wazero. // - This includes all value types available in WebAssembly 1.0 (20191205) and all are encoded little-endian. // diff --git a/config.go b/config.go index 2715566e..7b8eb22d 100644 --- a/config.go +++ b/config.go @@ -309,8 +309,6 @@ func (c *compiledModule) Name() (moduleName string) { // Close implements CompiledModule.Close func (c *compiledModule) Close(_ context.Context) error { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - c.compiledEngine.DeleteCompiledModule(c.module) // It is possible the underlying may need to return an error later, but in any case this matches api.Module.Close. return nil diff --git a/examples/allocation/tinygo/testdata/greet.wasm b/examples/allocation/tinygo/testdata/greet.wasm index e2061f510b452b523f00b5c0bda431a0ea1d7eca..09547d6c0b0038cf584c408004b0556df505ff87 100755 GIT binary patch delta 429 zcmdn-mihWy<_%4Z%-pOjlUo^=GA`V#&D5+gd69C=n7q==S9c0amZF#ftK$qHEe@m?0BH#z-2$W~fiy^E17nt= z6p%e(v$A<8s}Pfe0*j-92QLGV`p@9b%g8;s-e#3DlLJ_yVFR-#FN5RX|ICU?Km`p4 zYJdhDIKbc!Qm1GoGTGl&m{DwUvaJ%M_~bTQM@EUsCv2@5B`34kDKSb-R=0Cxl%AYv z7YuaqUb_#>Kx&ep+rxaeh&WUNDf*5h^OpE6L1F)ho`)Oim3*%*#yPZ2Uo%O~WwF u$RN$o&^XB~)zsWPEzR7-#KI)i(#X`p(8Ac)4-}5FRcDl(++?f7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7=O3m+7v6CZ9V3SvO~;e(0nMKQK-9(!J_ z>8pbTFZSiIe(|fm+4z{q{BXw7r6f72<(TkU1|!$$Qxr%FaSz)J?LW#upqnMQQzkdY zxIrR!YTqHS~-D3TZf>|AStq$4JfI)i0j<|HKG}19yjSWCka!#;?F}iRn$446UzVH}huDE%c z(Ny-m<{80$%-IzY{P9%wt;F&lKkve~7tsvTUW9F7Uzs9CT={&=i}G7TW=au2v>fA_ z-%L#WyHzapqfA8D)>fDQ7l~be-)?v#u~=gh*AnUf_}@%S>i=2dv;Kp620lsj-_##V zWzYsq%M|fnE{@l`n3jpBI4}!%8aN7=1**xwvj)>Vz*kXE_}6&$0>2MT0lo?J0pEA% zE<4XJgP!QFI?vaDZan{sgZ~CJG_6$o7zI+#|8VeAAWif+kS5TafxJMPD8s?)DNNgp zmC$15h{vx@E?bS3NqEZJy(^Z7ue-wyd5<*ZHPlt*wbbp1|dQBI4ePiiTaFXl3q4 zV|6W&L(DA~{RDH@;y(|xJSlnxc~%>9k+cpocetu4)^dcoD@q=#YdI?V2l@PVc2`Bk zqv2h3P|NCy+PcP?iddwfIoz`S*q^pwMbz??nEmm@F;BCRs%J%{aZg>Wsj&jG?-1dS z$BjD9GMuK`nhMF$331}%G2@FTvs;-DY5U1H#NhKcqZ6*SK-ESw|^B2qm zuCT7>nP*32NA-^8Z>mD`-ZRW!f&ZBitKJ@K+}-d3^PpU_yZJ>~Xoxg^OI-TxbD^UA wqM~p?c<%h7h53c~)m63Oh4Tu+^9%Cx=N45})fDB|ESytYFt1u1`uF1h4|DLW#{d8T diff --git a/internal/engine/compiler/engine.go b/internal/engine/compiler/engine.go index ee9544c6..e911b6e5 100644 --- a/internal/engine/compiler/engine.go +++ b/internal/engine/compiler/engine.go @@ -96,8 +96,7 @@ type ( moduleContext struct { // moduleInstanceAddress is the address of module instance from which we initialize // the following fields. This is set whenever we enter a function or return from function calls. - // This is only used by Compiler code so mark this as nolint. - moduleInstanceAddress uintptr //nolint + moduleInstanceAddress uintptr //lint:ignore U1000 This is only used by Compiler code. // globalElement0Address is the address of the first element in the global slice, // i.e. &ModuleInstance.Globals[0] as uintptr. diff --git a/internal/integration_test/fuzzcases/fuzzcases_test.go b/internal/integration_test/fuzzcases/fuzzcases_test.go index efce2a3b..f4902688 100644 --- a/internal/integration_test/fuzzcases/fuzzcases_test.go +++ b/internal/integration_test/fuzzcases/fuzzcases_test.go @@ -3,7 +3,6 @@ package fuzzcases import ( "context" "embed" - _ "embed" "fmt" "testing" diff --git a/internal/wasm/call_context.go b/internal/wasm/call_context.go index feb8d3a9..b6440716 100644 --- a/internal/wasm/call_context.go +++ b/internal/wasm/call_context.go @@ -109,8 +109,6 @@ func (m *CallContext) CloseWithExitCode(ctx context.Context, exitCode uint32) er // // Note: The caller is responsible for removing the module from the Namespace. func (m *CallContext) close(ctx context.Context, exitCode uint32) (c bool, err error) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - closed := uint64(1) + uint64(exitCode)<<32 // Store exitCode as high-order bits. if !atomic.CompareAndSwapUint64(m.closed, 0, closed) { return false, nil @@ -165,9 +163,6 @@ func (f *importedFn) Call(ctx context.Context, params ...uint64) (ret []uint64, if f.importedFn.IsHostFunction { return nil, fmt.Errorf("directly calling host function is not supported") } - if ctx == nil { - ctx = context.Background() - } mod := f.importingModule return f.importedFn.Module.Engine.Call(ctx, mod, f.importedFn, params...) } @@ -177,9 +172,6 @@ func (f *FunctionInstance) Call(ctx context.Context, params ...uint64) (ret []ui if f.IsHostFunction { return nil, fmt.Errorf("directly calling host function is not supported") } - if ctx == nil { - ctx = context.Background() - } mod := f.Module ret, err = mod.Engine.Call(ctx, mod.CallCtx, f, params...) return diff --git a/internal/wasm/global.go b/internal/wasm/global.go index d55ee015..ba5f2737 100644 --- a/internal/wasm/global.go +++ b/internal/wasm/global.go @@ -21,15 +21,11 @@ func (g *mutableGlobal) Type() api.ValueType { // Get implements the same method as documented on api.Global. func (g *mutableGlobal) Get(_ context.Context) uint64 { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return g.g.Val } // Set implements the same method as documented on api.MutableGlobal. func (g *mutableGlobal) Set(_ context.Context, v uint64) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - g.g.Val = v } @@ -59,8 +55,6 @@ func (g globalI32) Type() api.ValueType { // Get implements the same method as documented on api.Global. func (g globalI32) Get(_ context.Context) uint64 { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return uint64(g) } @@ -81,8 +75,6 @@ func (g globalI64) Type() api.ValueType { // Get implements the same method as documented on api.Global. func (g globalI64) Get(_ context.Context) uint64 { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return uint64(g) } @@ -103,8 +95,6 @@ func (g globalF32) Type() api.ValueType { // Get implements the same method as documented on api.Global. func (g globalF32) Get(_ context.Context) uint64 { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return uint64(g) } @@ -125,8 +115,6 @@ func (g globalF64) Type() api.ValueType { // Get implements the same method as documented on api.Global. func (g globalF64) Get(_ context.Context) uint64 { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return uint64(g) } diff --git a/internal/wasm/memory.go b/internal/wasm/memory.go index c742986f..08922032 100644 --- a/internal/wasm/memory.go +++ b/internal/wasm/memory.go @@ -62,15 +62,11 @@ func NewMemoryInstance(memSec *Memory) *MemoryInstance { // Size implements the same method as documented on api.Memory. func (m *MemoryInstance) Size(_ context.Context) uint32 { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return m.size() } // ReadByte implements the same method as documented on api.Memory. func (m *MemoryInstance) ReadByte(_ context.Context, offset uint32) (byte, bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - if offset >= m.size() { return 0, false } @@ -79,8 +75,6 @@ func (m *MemoryInstance) ReadByte(_ context.Context, offset uint32) (byte, bool) // ReadUint16Le implements the same method as documented on api.Memory. func (m *MemoryInstance) ReadUint16Le(_ context.Context, offset uint32) (uint16, bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - if !m.hasSize(offset, 2) { return 0, false } @@ -89,15 +83,11 @@ func (m *MemoryInstance) ReadUint16Le(_ context.Context, offset uint32) (uint16, // ReadUint32Le implements the same method as documented on api.Memory. func (m *MemoryInstance) ReadUint32Le(_ context.Context, offset uint32) (uint32, bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return m.readUint32Le(offset) } // ReadFloat32Le implements the same method as documented on api.Memory. func (m *MemoryInstance) ReadFloat32Le(_ context.Context, offset uint32) (float32, bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - v, ok := m.readUint32Le(offset) if !ok { return 0, false @@ -107,15 +97,11 @@ func (m *MemoryInstance) ReadFloat32Le(_ context.Context, offset uint32) (float3 // ReadUint64Le implements the same method as documented on api.Memory. func (m *MemoryInstance) ReadUint64Le(_ context.Context, offset uint32) (uint64, bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return m.readUint64Le(offset) } // ReadFloat64Le implements the same method as documented on api.Memory. func (m *MemoryInstance) ReadFloat64Le(_ context.Context, offset uint32) (float64, bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - v, ok := m.readUint64Le(offset) if !ok { return 0, false @@ -125,8 +111,6 @@ func (m *MemoryInstance) ReadFloat64Le(_ context.Context, offset uint32) (float6 // Read implements the same method as documented on api.Memory. func (m *MemoryInstance) Read(_ context.Context, offset, byteCount uint32) ([]byte, bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - if !m.hasSize(offset, byteCount) { return nil, false } @@ -135,8 +119,6 @@ func (m *MemoryInstance) Read(_ context.Context, offset, byteCount uint32) ([]by // WriteByte implements the same method as documented on api.Memory. func (m *MemoryInstance) WriteByte(_ context.Context, offset uint32, v byte) bool { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - if offset >= m.size() { return false } @@ -146,8 +128,6 @@ func (m *MemoryInstance) WriteByte(_ context.Context, offset uint32, v byte) boo // WriteUint16Le implements the same method as documented on api.Memory. func (m *MemoryInstance) WriteUint16Le(_ context.Context, offset uint32, v uint16) bool { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - if !m.hasSize(offset, 2) { return false } @@ -157,36 +137,26 @@ func (m *MemoryInstance) WriteUint16Le(_ context.Context, offset uint32, v uint1 // WriteUint32Le implements the same method as documented on api.Memory. func (m *MemoryInstance) WriteUint32Le(_ context.Context, offset, v uint32) bool { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return m.writeUint32Le(offset, v) } // WriteFloat32Le implements the same method as documented on api.Memory. func (m *MemoryInstance) WriteFloat32Le(_ context.Context, offset uint32, v float32) bool { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return m.writeUint32Le(offset, math.Float32bits(v)) } // WriteUint64Le implements the same method as documented on api.Memory. func (m *MemoryInstance) WriteUint64Le(_ context.Context, offset uint32, v uint64) bool { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return m.writeUint64Le(offset, v) } // WriteFloat64Le implements the same method as documented on api.Memory. func (m *MemoryInstance) WriteFloat64Le(_ context.Context, offset uint32, v float64) bool { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return m.writeUint64Le(offset, math.Float64bits(v)) } // Write implements the same method as documented on api.Memory. func (m *MemoryInstance) Write(_ context.Context, offset uint32, val []byte) bool { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - if !m.hasSize(offset, uint32(len(val))) { return false } @@ -201,8 +171,6 @@ func MemoryPagesToBytesNum(pages uint32) (bytesNum uint64) { // Grow implements the same method as documented on api.Memory. func (m *MemoryInstance) Grow(_ context.Context, delta uint32) (result uint32, ok bool) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - // We take write-lock here as the following might result in a new slice m.mux.Lock() defer m.mux.Unlock() @@ -229,8 +197,6 @@ func (m *MemoryInstance) Grow(_ context.Context, delta uint32) (result uint32, o // PageSize returns the current memory buffer size in pages. func (m *MemoryInstance) PageSize(_ context.Context) (result uint32) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - return memoryBytesNumToPages(uint64(len(m.Buffer))) } diff --git a/internal/wasm/store.go b/internal/wasm/store.go index 545a4a5b..644bfd97 100644 --- a/internal/wasm/store.go +++ b/internal/wasm/store.go @@ -286,8 +286,6 @@ func NewStore(enabledFeatures Features, engine Engine) (*Store, *Namespace) { // NewNamespace implements the same method as documented on wazero.Runtime. func (s *Store) NewNamespace(_ context.Context) *Namespace { - // TODO: The above context isn't yet used. If it is, ensure it defaults to context.Background. - ns := newNamespace() s.mux.Lock() defer s.mux.Unlock() @@ -311,10 +309,6 @@ func (s *Store) Instantiate( sys *internalsys.Context, listeners []experimentalapi.FunctionListener, ) (*CallContext, error) { - if ctx == nil { - ctx = context.Background() - } - // Collect any imported modules to avoid locking the namespace too long. importedModuleNames := map[string]struct{}{} for _, i := range module.ImportSection { diff --git a/internal/wazeroir/compiler.go b/internal/wazeroir/compiler.go index 6550ce04..f95de602 100644 --- a/internal/wazeroir/compiler.go +++ b/internal/wazeroir/compiler.go @@ -158,8 +158,7 @@ type compiler struct { globals []*wasm.GlobalType } -// For debugging only. -// nolint +//lint:ignore U1000 for debugging only. func (c *compiler) stackDump() string { strs := make([]string, 0, len(c.stack)) for _, s := range c.stack { @@ -225,8 +224,6 @@ type CompilationResult struct { } func CompileFunctions(_ context.Context, enabledFeatures wasm.Features, module *wasm.Module) ([]*CompilationResult, error) { - // Note: If you use the context.Context param, don't forget to coerce nil to context.Background()! - functions, globals, mem, tables, err := module.AllDeclarations() if err != nil { return nil, err diff --git a/namespace.go b/namespace.go index d24219f7..f63e82a6 100644 --- a/namespace.go +++ b/namespace.go @@ -16,7 +16,6 @@ type Namespace interface { Module(moduleName string) api.Module // InstantiateModule instantiates the module namespace or errs if the configuration was invalid. - // When the context is nil, it defaults to context.Background. // // Ex. // module, _ := n.InstantiateModule(ctx, compiled, wazero.NewModuleConfig().WithName("prod")) diff --git a/netlify.toml b/netlify.toml index 75076233..3731c891 100644 --- a/netlify.toml +++ b/netlify.toml @@ -3,7 +3,7 @@ publish = "public" [build.environment] - HUGO_VERSION = "0.100.0" + HUGO_VERSION = "0.101.0" [context.production] command = "git submodule update --init && hugo --gc --minify" diff --git a/runtime.go b/runtime.go index c8548711..7c345e2e 100644 --- a/runtime.go +++ b/runtime.go @@ -49,7 +49,6 @@ type Runtime interface { CompileModule(ctx context.Context, binary []byte, config CompileConfig) (CompiledModule, error) // InstantiateModuleFromBinary instantiates a module from the WebAssembly binary (%.wasm) or errs if invalid. - // When the context is nil, it defaults to context.Background. // // Ex. // ctx := context.Background() @@ -74,7 +73,6 @@ type Runtime interface { // NewNamespace creates an empty namespace which won't conflict with any other namespace including the default. // This is more efficient than multiple runtimes, as namespaces share a compiler cache. - // When the context is nil, it defaults to context.Background. // // In simplest case, a namespace won't conflict if another has a module with the same name: // b := assemblyscript.NewBuilder(r) @@ -103,7 +101,6 @@ type Runtime interface { NewNamespace(context.Context) Namespace // CloseWithExitCode closes all the modules that have been initialized in this Runtime with the provided exit code. - // When the context is nil, it defaults to context.Background. // An error is returned if any module returns an error when closed. // // Ex. @@ -127,9 +124,6 @@ func NewRuntime(ctx context.Context) Runtime { // NewRuntimeWithConfig returns a runtime with the given configuration. func NewRuntimeWithConfig(ctx context.Context, rConfig RuntimeConfig) Runtime { - if ctx == nil { - ctx = context.Background() - } if v := ctx.Value(version.WazeroVersionKey{}); v == nil { ctx = context.WithValue(ctx, version.WazeroVersionKey{}, wazeroVersion) } @@ -202,9 +196,6 @@ func (r *runtime) CompileModule(ctx context.Context, binary []byte, cConfig Comp } func buildListeners(ctx context.Context, r *runtime, internal *wasm.Module) ([]experimentalapi.FunctionListener, error) { - if ctx == nil { - return nil, nil - } // Test to see if internal code are using an experimental feature. fnlf := ctx.Value(experimentalapi.FunctionListenerFactoryKey{}) if fnlf == nil { diff --git a/runtime_test.go b/runtime_test.go index 1d9b0ea9..22b41424 100644 --- a/runtime_test.go +++ b/runtime_test.go @@ -22,35 +22,16 @@ var ( ) func TestNewRuntimeWithConfig_version(t *testing.T) { - // Make sure nil ctx doesn't panic - tests := []struct { - name string - ctx context.Context - }{ - { - name: "not nil", - ctx: testCtx, - }, - { - name: "nil", - ctx: nil, - }, - } - for _, tc := range tests { - tt := tc - t.Run(tt.name, func(t *testing.T) { - cfg := NewRuntimeConfig().(*runtimeConfig) - oldNewEngine := cfg.newEngine - cfg.newEngine = func(ctx context.Context, features wasm.Features) wasm.Engine { - // Ensures that wazeroVersion is propagated to the engine. - v := ctx.Value(version.WazeroVersionKey{}) - require.NotNil(t, v) - require.Equal(t, wazeroVersion, v.(string)) - return oldNewEngine(ctx, features) - } - _ = NewRuntimeWithConfig(tt.ctx, cfg) - }) + cfg := NewRuntimeConfig().(*runtimeConfig) + oldNewEngine := cfg.newEngine + cfg.newEngine = func(ctx context.Context, features wasm.Features) wasm.Engine { + // Ensures that wazeroVersion is propagated to the engine. + v := ctx.Value(version.WazeroVersionKey{}) + require.NotNil(t, v) + require.Equal(t, wazeroVersion, v.(string)) + return oldNewEngine(ctx, features) } + _ = NewRuntimeWithConfig(testCtx, cfg) } func TestRuntime_CompileModule(t *testing.T) {