Refactor test-programs to build modules and components#6385
Conversation
336e465 to
cbd5c0f
Compare
…nd _components.rs The style is cribbed from preview2-prototying repo, but I ended up refactoring it a bit.
…ersions wit-bindgen 0.6.0 and wit-component 0.7.4
h2 upgraded from 0.3.16 -> 0.3.19 to fix vulnerability tempfile upgraded from 0.3.3 -> 0.3.5 to eliminate dep on vulnerable remove_dir_all
f44643f to
41e99f7
Compare
|
I am applying a temporary exception to I would typically just wait for that sort of work to finish up to land my PR, but I want to move along quickly so we can change the canonical home of the preview 2 work to this repository, which will unblock several other people. |
41e99f7 to
4745cab
Compare
| [dev-dependencies] | ||
| anyhow = { workspace = true } | ||
| tempfile = "3.1.0" | ||
| test-log = { version = "0.2", default-features = false, features = ["trace"] } |
There was a problem hiding this comment.
Oh? I've not seen this dependency before, what does it do?
There was a problem hiding this comment.
It is provides a wrapper over #[test] (or e.g. #[tokio::test] if you pass it in as an argument) which takes care of installing tracing-subscriber with an env filter before starting your test. It gets rid of a Once cell we used to do that manually.
|
|
||
| [[exemptions.h2]] | ||
| version = "0.3.16" | ||
| version = "0.3.19" |
There was a problem hiding this comment.
Could this diff be audited to avoid adding a new exemption? (assuming that this diff is a relatively small one hopefully)
There was a problem hiding this comment.
I could, I just figured that if we have an exemption I'd keep bumping it. I've been thinking about our exemptions of the tokio/hyper family (which this is a part of) is a wildcard audit for carl and sean.
| criteria = "safe-to-deploy" | ||
|
|
||
| [[exemptions.redox_syscall]] | ||
| version = "0.3.5" |
There was a problem hiding this comment.
Could you check to see if 0.2.13, which is exempted, is a small or big diff from 0.3.5? If small mind adding an audit for that? If big though it's a bit of a bummer but we can probably live with an exemption.
There was a problem hiding this comment.
I didn't want to do any sort of audit on this because it is the redox syscall layer, an OS I don't know anything about and don't think we care about in the context of this project. It just happens to be a transitive dep in some crates.
Alex asked me to do thsi for wit-component and wit-bindgen, and I found a few more (cfg-if, tempfile, filecheck, anyhow... I also reorganized the workspace dependencies section to make the ones our team maintains more clearly separated from our external dependencies.
7c4fe4a to
4c29127
Compare
|
#6385 (comment) This change was backed out as part of merging with main after #6394 landed. Thank you @itsrainy. Unfortunately, even with those fixes, there were still multiple versions of |
This is task 2 in #6370
On the tails of #6374, this adds support for
test-programsto build components out of preview 1 modules.But thats really just the side story for this PR, which rewrites the entire way that test-programs works. Over in preview2-prototyping, I got tired of doing a bunch of code generation of all the
#[test]functions, which makes it tests to read and hard to modify.So, I trimmed code generation in
test-programs/build.rsdown to the bare minimum: it calls out to cargo to build the test program crates, and then we have a functionmodule_rs()which writes a source file{test-crate}_modules.rsinto OUT_DIR. This source file defines a functionget_module(&str) -> Modulewhich gives the user the module corresponding to the binary name.For test program crates which can be built into components, you can invoke
component_rs()which creates{test-crate}_components.rsin OUT_DIR, and you useget_component(&str) -> wasmtime::component::Component. One extra argument is required: a built adapter, which is the command build ofwasi-preview1-component-adapterfrom this tree.As part of this rewrite, we generate the components for the test crates, but we don't actually execute them yet, because we need a host implementation of preview 2 to do so. Sit tight - that is coming in the very next PR!