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

Function it_prints_workspace_metadata

tests/metadata.rs:41–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40#[test]
41fn it_prints_workspace_metadata() -> Result<()> {
42 let dir = Rc::new(TempDir::new()?);
43 let root = dir.path().to_owned();
44 let project = Project::new_uninitialized(dir, root);
45
46 project.file(
47 "baz/Cargo.toml",
48 r#"[package]
49name = "baz"
50version = "0.1.0"
51edition = "2024"
52
53[dependencies]
54"#,
55 )?;
56
57 project.file("baz/src/lib.rs", "")?;
58
59 project
60 .cargo_component(["new", "--lib", "foo"])
61 .assert()
62 .stderr(contains("Updated manifest of package `foo`"))
63 .success();
64
65 project
66 .cargo_component(["new", "--lib", "bar"])
67 .assert()
68 .stderr(contains("Updated manifest of package `bar`"))
69 .success();
70
71 // Add the workspace after all of the packages have been created.
72 project.file(
73 "Cargo.toml",
74 r#"[workspace]
75members = ["foo", "bar", "baz"]
76"#,
77 )?;
78
79 project
80 .cargo_component(["metadata", "--format-version", "1"])
81 .assert()
82 .stdout(
83 contains(r#"name":"foo","version":"0.1.0""#).and(
84 contains(r#"name":"bar","version":"0.1.0""#)
85 .and(contains(r#"name":"baz","version":"0.1.0""#)),
86 ),
87 )
88 .success();
89
90 Ok(())
91}

Callers

nothing calls this directly

Calls 3

pathMethod · 0.80
cargo_componentMethod · 0.80
fileMethod · 0.45

Tested by

no test coverage detected