()
| 10 | |
| 11 | #[test] |
| 12 | fn 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] |
| 20 | runner = [ |
| 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 | " |
| 37 | package my:random; |
| 38 | |
| 39 | interface types { |
| 40 | record seed { |
| 41 | value: u32, |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | world 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)] |
| 55 | mod bindings; |
| 56 | |
| 57 | use bindings::{Seed}; |
| 58 | |
| 59 | fn rand(seed: Seed) -> u32 { |
| 60 | seed.value + 1 |
| 61 | } |
| 62 | |
| 63 | fn main() { |
| 64 | println!(""); |
| 65 | } |
| 66 | |
| 67 | #[test] |
| 68 | pub fn test_random_component() { |
| 69 | let result = rand(Seed { value: 3 }); |
nothing calls this directly
no test coverage detected