-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add importize method to Resolve (#1784)
* Add importize method to Resolve A new method `importize` is added to the Resolve. This is to allow to mutate the Resolve to state where it would resemble what a consuming component would expect to see during composition. Signed-off-by: karthik2804 <[email protected]> * Updates to importize * Update the CLI to have `--importize` and `--importize-world` * Rewrite the test to use these flags and have multiple tests in one file, each with a smaller world. * Update the implementation to preserve allow-listed imports instead of removing all imports and recreating what needs to be preserved. * Enable fuzz-testing of `importize` --------- Signed-off-by: karthik2804 <[email protected]> Co-authored-by: Alex Crichton <[email protected]>
- Loading branch information
1 parent
de775dd
commit 8f247b9
Showing
13 changed files
with
830 additions
and
17 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
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
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
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
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,80 @@ | ||
// RUN[simple]: component wit --importize-world simple % | ||
// RUN[simple-component]: component embed --dummy --world simple % | \ | ||
// component wit --importize | ||
// RUN[with-deps]: component wit --importize-world with-deps % | ||
// RUN[simple-toplevel]: component wit --importize-world simple-toplevel % | ||
// RUN[toplevel-deps]: component wit --importize-world toplevel-deps % | ||
// FAIL[fail1]: component wit --importize-world fail1 % | ||
// RUN[trim-imports]: component wit --importize-world trim-imports % | ||
// RUN[tricky-import]: component wit --importize-world tricky-import % | ||
|
||
package importize:importize; | ||
|
||
interface t { | ||
resource r; | ||
} | ||
interface bar { | ||
use t.{r}; | ||
record foo { | ||
x: string | ||
} | ||
importize: func(name: r); | ||
} | ||
|
||
interface qux { | ||
use bar.{foo}; | ||
blah: func(boo: foo); | ||
} | ||
|
||
interface something-else-dep { | ||
type t = u32; | ||
} | ||
|
||
world simple { | ||
export t; | ||
} | ||
|
||
world with-deps { | ||
export qux; | ||
} | ||
|
||
world simple-toplevel { | ||
export foo: func(); | ||
export something: interface { | ||
foo: func(); | ||
} | ||
} | ||
|
||
world toplevel-deps { | ||
type s = u32; | ||
export bar: func() -> s; | ||
export something-else: interface { | ||
use something-else-dep.{t}; | ||
bar: func() -> t; | ||
} | ||
} | ||
|
||
world fail1 { | ||
type foo = u32; | ||
export foo: func() -> foo; | ||
} | ||
|
||
interface a {} | ||
interface b {} | ||
|
||
world trim-imports { | ||
import a; | ||
import foo: func(); | ||
import bar: interface {} | ||
type t = u32; | ||
export b; | ||
} | ||
|
||
interface with-dep { | ||
type t = u32; | ||
} | ||
|
||
world tricky-import { | ||
use with-dep.{t}; | ||
export f: func() -> t; | ||
} |
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,4 @@ | ||
error: failed to move world exports to imports | ||
|
||
Caused by: | ||
0: world export `foo` conflicts with import of same name |
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,13 @@ | ||
package root:root; | ||
|
||
world root-importized { | ||
import importize:importize/t; | ||
} | ||
package importize:importize { | ||
interface t { | ||
resource r; | ||
} | ||
world simple { | ||
export t; | ||
} | ||
} |
Oops, something went wrong.