From 5465e6a451938dcf4d1e032909cfef7da1b7814c Mon Sep 17 00:00:00 2001 From: Rustin170506 Date: Tue, 17 Dec 2024 21:39:18 +0800 Subject: [PATCH] fix: remove unsupported embedded workspace check from `cargo pkgid` command Signed-off-by: Rustin170506 --- src/bin/cargo/commands/pkgid.rs | 7 ------- tests/testsuite/script.rs | 13 ++++++++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bin/cargo/commands/pkgid.rs b/src/bin/cargo/commands/pkgid.rs index 5fcf85b8f..aa98dc5c3 100644 --- a/src/bin/cargo/commands/pkgid.rs +++ b/src/bin/cargo/commands/pkgid.rs @@ -18,13 +18,6 @@ pub fn cli() -> Command { pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { let ws = args.workspace(gctx)?; - if ws.root_maybe().is_embedded() { - return Err(anyhow::format_err!( - "{} is unsupported by `cargo pkgid`", - ws.root_manifest().display() - ) - .into()); - } if args.is_present_with_zero_values("package") { print_available_packages(&ws)? } diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index 3c31c77f3..8db5fcc12 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -1297,18 +1297,25 @@ fn cmd_verify_project_with_embedded() { .run(); } -#[cargo_test] +#[cargo_test(nightly, reason = "edition2024 hasn't hit stable yet")] fn cmd_pkgid_with_embedded() { let p = cargo_test_support::project() .file("script.rs", ECHO_SCRIPT) .build(); + p.cargo("-Zscript script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .run(); + + // FIXME: It should be `path+[ROOTURL]/foo/script.rs#script@0.0.0`. p.cargo("-Zscript pkgid --manifest-path script.rs") .masquerade_as_nightly_cargo(&["script"]) - .with_status(101) + .with_stdout_data(str![[r#" +path+[ROOTURL]/foo#script@0.0.0 + +"#]]) .with_stderr_data(str![[r#" [WARNING] `package.edition` is unspecified, defaulting to `2024` -[ERROR] [ROOT]/foo/script.rs is unsupported by `cargo pkgid` "#]]) .run();