Skip to content

Commit

Permalink
Moves test-only symbols out of wazero package (#597)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
codefromthecrypt authored May 28, 2022
1 parent f9a59d2 commit d992373
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 8 deletions.
3 changes: 0 additions & 3 deletions config_supported.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions config_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions internal/engine/compiler/arch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions internal/engine/compiler/arch_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions internal/engine/compiler/arch_arm64.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions internal/engine/compiler/arch_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/tetratelabs/wazero/internal/wazeroir"
)

const isSupported = false

// archContext is empty on an unsupported architecture.
type archContext struct{}

Expand Down
3 changes: 2 additions & 1 deletion internal/integration_test/engine/adhoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down
3 changes: 2 additions & 1 deletion internal/integration_test/engine/hammer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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())
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit d992373

Please sign in to comment.