MCPcopy Create free account
hub / github.com/bytecodealliance/cargo-component / it_runs_test_with_command_component

Function it_runs_test_with_command_component

tests/test.rs:12–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10
11#[test]
12fn it_runs_test_with_command_component() -> Result<()> {
13 let project = Project::new("foo-bar", false)?;
14
15 fs::create_dir_all(project.root().join(".cargo"))?;
16 fs::write(
17 project.root().join(".cargo/config.toml"),
18 r#"
19[target.wasm32-wasip1]
20runner = [
21 "wasmtime",
22 "-C",
23 "cache=no",
24 "-W",
25 "component-model",
26 "-S",
27 "preview2",
28 "-S",
29 "cli",
30]"#,
31 )?;
32
33 fs::create_dir_all(project.root().join("wit"))?;
34 fs::write(
35 project.root().join("wit/world.wit"),
36 "
37package my:random;
38
39interface types {
40 record seed {
41 value: u32,
42 }
43}
44
45world generator {
46 use types.{seed};
47 import get-seed: func() -> seed;
48}",
49 )?;
50
51 fs::write(
52 project.root().join("src/main.rs"),
53 r#"
54#[allow(warnings)]
55mod bindings;
56
57use bindings::{Seed};
58
59fn rand(seed: Seed) -> u32 {
60 seed.value + 1
61}
62
63fn main() {
64 println!("");
65}
66
67#[test]
68pub fn test_random_component() {
69 let result = rand(Seed { value: 3 });

Callers

nothing calls this directly

Calls 2

rootMethod · 0.80
cargo_componentMethod · 0.80

Tested by

no test coverage detected