MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / build_rust_tests

Method build_rust_tests

crates/test-programs/artifacts/build.rs:174–217  ·  view source on GitHub ↗
(&mut self, tests: &mut Vec<Test>)

Source from the content-addressed store, hash-verified

172 }
173
174 fn build_rust_tests(&mut self, tests: &mut Vec<Test>) {
175 println!("cargo:rerun-if-env-changed=MIRI_TEST_CWASM_DIR");
176 let release_mode = env::var_os("MIRI_TEST_CWASM_DIR").is_some();
177
178 let mut cmd = cargo();
179 cmd.arg("build");
180 if release_mode {
181 cmd.arg("--release");
182 }
183 cmd.arg("--target=wasm32-wasip1")
184 .arg("--package=test-programs")
185 .env("CARGO_TARGET_DIR", &self.out_dir)
186 .env("CARGO_PROFILE_DEV_DEBUG", "2")
187 .env("RUSTFLAGS", rustflags())
188 .env_remove("CARGO_ENCODED_RUSTFLAGS");
189 eprintln!("running: {cmd:?}");
190 let status = cmd.status().unwrap();
191 assert!(status.success());
192
193 let meta = cargo_metadata::MetadataCommand::new().exec().unwrap();
194 let targets = meta
195 .packages
196 .iter()
197 .find(|p| p.name == "test-programs")
198 .unwrap()
199 .targets
200 .iter()
201 .filter(move |t| t.kind == &[cargo_metadata::TargetKind::Bin])
202 .map(|t| &t.name)
203 .collect::<Vec<_>>();
204
205 for target in targets {
206 let wasm = self
207 .out_dir
208 .join("wasm32-wasip1")
209 .join(if release_mode { "release" } else { "debug" })
210 .join(format!("{target}.wasm"));
211 self.read_deps_of(&wasm);
212 tests.push(Test {
213 core_wasm: Some(wasm),
214 name: target.to_string(),
215 })
216 }
217 }
218
219 // Build the WASI Preview 1 adapter, and get the binary:
220 fn build_adapter(

Callers 1

buildMethod · 0.80

Calls 15

statusMethod · 0.80
read_deps_ofMethod · 0.80
cargoFunction · 0.70
rustflagsFunction · 0.70
newFunction · 0.50
is_someMethod · 0.45
argMethod · 0.45
envMethod · 0.45
unwrapMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected