Changes RuntimeConfig to an interface and exposes WithWasmCore2 (#518)
WebAssembly Core Working Draft 1 recently came out. Before that, we had a toe-hold feature bucked called FinishedFeatures. This replaces `RuntimeConfig.WithFinishedFeatures` with `RuntimeConfig.WithWasmCore2`. This also adds `WithWasmCore1` for those who want to lock into 1.0 features as opposed to relying on defaults. This also fixes some design debt where we hadn't finished migrating public types that require constructor functions (NewXxx) to interfaces. By using interfaces, we prevent people from accidentally initializing key configuration directly (via &Xxx), causing nil field refs. This also helps prevent confusion about how to use the type (ex pointer or not) as there's only one way (as an interface). See https://github.com/tetratelabs/wazero/issues/516 Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
@@ -362,12 +362,12 @@ func TestNewModuleBuilder_Build(t *testing.T) {
|
||||
func TestNewModuleBuilder_Build_Errors(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input func(*RuntimeConfig) ModuleBuilder
|
||||
input func(RuntimeConfig) ModuleBuilder
|
||||
expectedErr string
|
||||
}{
|
||||
{
|
||||
name: "memory min > limit", // only one test to avoid duplicating tests in module_test.go
|
||||
input: func(cfg *RuntimeConfig) ModuleBuilder {
|
||||
input: func(cfg RuntimeConfig) ModuleBuilder {
|
||||
return NewRuntimeWithConfig(cfg).NewModuleBuilder("").
|
||||
ExportMemory("memory", math.MaxUint32)
|
||||
},
|
||||
@@ -375,7 +375,7 @@ func TestNewModuleBuilder_Build_Errors(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "memory cap < min", // only one test to avoid duplicating tests in module_test.go
|
||||
input: func(cfg *RuntimeConfig) ModuleBuilder {
|
||||
input: func(cfg RuntimeConfig) ModuleBuilder {
|
||||
cfg = cfg.WithMemoryCapacityPages(func(minPages uint32, maxPages *uint32) uint32 {
|
||||
return 1
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user