-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[wit-parser] select default world among multiple packages (#1675)
* [wit-parser] select default world among multiple packages Previously, `Resolve::select_world` would return an error if multiple packages were provided and no world was specified. Now, we return `Ok` in this case as long as exactly one package has exactly one world. Signed-off-by: Joel Dice <joel.dice@fermyon.com> * add `multiple-packages-one-world` test Signed-off-by: Joel Dice <joel.dice@fermyon.com> * add sad-path tests for multiple packages Signed-off-by: Joel Dice <joel.dice@fermyon.com> --------- Signed-off-by: Joel Dice <joel.dice@fermyon.com>
- Loading branch information
Showing
7 changed files
with
113 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/cli/multiple-packages-multiple-worlds-in-package.wit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// FAIL: component embed --dummy --wat % | ||
|
||
package test:foo1 { | ||
interface bar { | ||
baz: func(s: string) -> string; | ||
} | ||
} | ||
|
||
package test:foo2 { | ||
interface bar { | ||
baz: func(s: string) -> string; | ||
} | ||
} | ||
|
||
package test:hola { | ||
world hello { | ||
import test:foo1/bar; | ||
export test:foo2/bar; | ||
} | ||
world some-other-world { | ||
import test:foo1/bar; | ||
export test:foo2/bar; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/cli/multiple-packages-multiple-worlds-in-package.wit.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
error: multiple worlds found; one must be explicitly chosen: | ||
test:hola/hello | ||
test:hola/some-other-world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// FAIL: component embed --dummy --wat % | ||
|
||
package test:foo1 { | ||
interface bar { | ||
baz: func(s: string) -> string; | ||
} | ||
} | ||
|
||
package test:foo2 { | ||
interface bar { | ||
baz: func(s: string) -> string; | ||
} | ||
world some-other-world { | ||
import test:foo1/bar; | ||
export bar; | ||
} | ||
} | ||
|
||
package test:hola { | ||
world hello { | ||
import test:foo1/bar; | ||
export test:foo2/bar; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
error: multiple worlds found; one must be explicitly chosen: | ||
test:foo2/some-other-world | ||
test:hola/hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// RUN: component embed --dummy --wat % | ||
|
||
package test:foo1 { | ||
interface bar { | ||
baz: func(s: string) -> string; | ||
} | ||
} | ||
|
||
package test:foo2 { | ||
interface bar { | ||
baz: func(s: string) -> string; | ||
} | ||
} | ||
|
||
package test:hola { | ||
world hello { | ||
import test:foo1/bar; | ||
export test:foo2/bar; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(module | ||
(type (;0;) (func (param i32 i32 i32))) | ||
(type (;1;) (func (param i32 i32) (result i32))) | ||
(type (;2;) (func (param i32 i32 i32 i32) (result i32))) | ||
(import "test:foo1/bar" "baz" (func (;0;) (type 0))) | ||
(func (;1;) (type 1) (param i32 i32) (result i32) | ||
unreachable | ||
) | ||
(func (;2;) (type 2) (param i32 i32 i32 i32) (result i32) | ||
unreachable | ||
) | ||
(memory (;0;) 0) | ||
(export "test:foo2/bar#baz" (func 1)) | ||
(export "memory" (memory 0)) | ||
(export "cabi_realloc" (func 2)) | ||
(@custom "component-type" (after code) "/00asm/0d/00/01/00/00/19/16wit-component-encoding/04/00/07d/01A/02/01A/04/01B/02/01@/01/01ss/00s/04/00/03baz/01/00/03/01/0dtest:foo1/bar/05/00/01B/02/01@/01/01ss/00s/04/00/03baz/01/00/04/01/0dtest:foo2/bar/05/01/04/01/0ftest:hola/hello/04/00/0b/0b/01/00/05hello/03/00/00/00//09producers/01/0cprocessed-by/01/0dwit-component/070.213.0") | ||
) |