capabilities: add minor version

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
This commit is contained in:
Stephan Renatus
2021-02-17 16:57:23 +01:00
committed by Torin Sandall
parent 18639da383
commit f817ea5a32
7 changed files with 34 additions and 25 deletions
+2 -1
View File
@@ -432,8 +432,9 @@ func (c *Compiler) compileWasm(ctx context.Context) error {
compiler := wasm.New()
found := false
have := compiler.ABIVersion()
for _, v := range c.capabilities.WasmABIVersions {
if v == compiler.ABIVersion() {
if v.Version == have.Version && v.Minor <= have.Minor {
found = true
break
}
+6 -6
View File
@@ -428,7 +428,7 @@ func TestCompilerOptimizationL2(t *testing.T) {
}
// NOTE(sr): we override this to not depend on build tags in tests
func wasmABIVersions(vs ...int) *ast.Capabilities {
func wasmABIVersions(vs ...ast.WasmABIVersion) *ast.Capabilities {
caps := ast.CapabilitiesForThisVersion()
caps.WasmABIVersions = vs
return caps
@@ -445,7 +445,7 @@ func TestCompilerWasmTarget(t *testing.T) {
test.WithTempFS(files, func(root string) {
compiler := New().WithPaths(root).WithTarget("wasm").WithEntrypoints("test/p", "test/q").
WithCapabilities(wasmABIVersions(1))
WithCapabilities(wasmABIVersions(ast.WasmABIVersion{Version: 1}))
err := compiler.Build(context.Background())
if err != nil {
t.Fatal(err)
@@ -474,7 +474,7 @@ func TestCompilerWasmTargetWithCapabilitiesMismatch(t *testing.T) {
test.WithTempFS(files, func(root string) {
compiler := New().WithPaths(root).WithTarget("wasm").WithEntrypoints("test/p", "test/q").
WithCapabilities(wasmABIVersions(0, 2))
WithCapabilities(wasmABIVersions(ast.WasmABIVersion{Version: 0}, ast.WasmABIVersion{Version: 1, Minor: 2}, ast.WasmABIVersion{Version: 2}))
err := compiler.Build(context.Background())
if err == nil {
t.Fatal("expected err, got nil")
@@ -498,7 +498,7 @@ func TestCompilerWasmTargetMultipleEntrypoints(t *testing.T) {
test.WithTempFS(files, func(root string) {
compiler := New().WithPaths(root).WithTarget("wasm").WithEntrypoints("test/p", "policy/authz").
WithCapabilities(wasmABIVersions(1))
WithCapabilities(wasmABIVersions(ast.WasmABIVersion{Version: 1}))
err := compiler.Build(context.Background())
if err != nil {
t.Fatal(err)
@@ -543,7 +543,7 @@ func TestCompilerWasmTargetEntrypointDependents(t *testing.T) {
test.WithTempFS(files, func(root string) {
compiler := New().WithPaths(root).WithTarget("wasm").WithEntrypoints("test/r", "test/z").
WithCapabilities(wasmABIVersions(1))
WithCapabilities(wasmABIVersions(ast.WasmABIVersion{Version: 1}))
err := compiler.Build(context.Background())
if err != nil {
t.Fatal(err)
@@ -595,7 +595,7 @@ func TestCompilerWasmTargetLazyCompile(t *testing.T) {
test.WithTempFS(files, func(root string) {
compiler := New().WithPaths(root).WithTarget("wasm").WithEntrypoints("test/p").WithOptimizationLevel(1).
WithCapabilities(wasmABIVersions(1))
WithCapabilities(wasmABIVersions(ast.WasmABIVersion{Version: 1}))
err := compiler.Build(context.Background())
if err != nil {
t.Fatal(err)