Moves test-only symbols out of wazero package (#597)

This moves the compiler support flag out of the public package as it was
only put there for tests. This also files modgen under the testing
subdir so that it isn't mistaken for main code.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Crypt Keeper
2022-05-27 17:32:26 -07:00
committed by GitHub
parent f9a59d269a
commit d992373ea7
11 changed files with 14 additions and 8 deletions

View File

@@ -2,9 +2,6 @@
package wazero
// CompilerSupported returns whether the compiler is supported in this environment.
const CompilerSupported = true
// NewRuntimeConfig returns NewRuntimeConfigCompiler
func NewRuntimeConfig() RuntimeConfig {
return NewRuntimeConfigCompiler()

View File

@@ -2,9 +2,6 @@
package wazero
// CompilerSupported returns whether the compiler is supported in this environment.
const CompilerSupported = false
// NewRuntimeConfig returns NewRuntimeConfigInterpreter
func NewRuntimeConfig() RuntimeConfig {
return NewRuntimeConfigInterpreter()

View File

@@ -6,6 +6,9 @@ var (
newArchContext func() archContext
)
// IsSupported returns whether the compiler is supported on this architecture.
const IsSupported = isSupported
// nativecall is used by callEngine.execWasmFunction and the entrypoint to enter the compiled native code.
// codeSegment is the pointer to the initial instruction of the compiled native code.
// ce is "*callEngine" as uintptr.

View File

@@ -4,6 +4,8 @@ import (
"github.com/tetratelabs/wazero/internal/wazeroir"
)
const isSupported = true
// init initializes variables for the amd64 architecture
func init() {
newArchContext = newArchContextImpl

View File

@@ -6,6 +6,8 @@ import (
"github.com/tetratelabs/wazero/internal/wazeroir"
)
const isSupported = true
// init initializes variables for the arm64 architecture
func init() {
newArchContext = newArchContextImpl

View File

@@ -9,6 +9,8 @@ import (
"github.com/tetratelabs/wazero/internal/wazeroir"
)
const isSupported = false
// archContext is empty on an unsupported architecture.
type archContext struct{}

View File

@@ -11,6 +11,7 @@ import (
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/api"
"github.com/tetratelabs/wazero/internal/engine/compiler"
"github.com/tetratelabs/wazero/internal/testing/require"
"github.com/tetratelabs/wazero/internal/wasm"
"github.com/tetratelabs/wazero/sys"
@@ -46,7 +47,7 @@ var tests = map[string]func(t *testing.T, r wazero.Runtime){
}
func TestEngineCompiler(t *testing.T) {
if !wazero.CompilerSupported {
if !compiler.IsSupported {
t.Skip()
}
runAllTests(t, tests, wazero.NewRuntimeConfigCompiler())

View File

@@ -6,6 +6,7 @@ import (
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/api"
"github.com/tetratelabs/wazero/internal/engine/compiler"
"github.com/tetratelabs/wazero/internal/testing/hammer"
"github.com/tetratelabs/wazero/internal/testing/require"
"github.com/tetratelabs/wazero/sys"
@@ -18,7 +19,7 @@ var hammers = map[string]func(t *testing.T, r wazero.Runtime){
}
func TestEngineCompiler_hammer(t *testing.T) {
if !wazero.CompilerSupported {
if !compiler.IsSupported {
t.Skip()
}
runAllTests(t, hammers, wazero.NewRuntimeConfigCompiler())

View File

@@ -116,6 +116,7 @@ type Runtime interface {
api.Closer
}
// NewRuntime returns a runtime with a configuration assigned by NewRuntimeConfig.
func NewRuntime() Runtime {
return NewRuntimeWithConfig(NewRuntimeConfig())
}