From a37d1229493dd376eb43cd0c49f453f3a9da30ae Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Thu, 18 Jan 2024 00:27:56 -0500 Subject: [PATCH] test: show pkgid spec + query doesnt work with `--package` --- tests/testsuite/check.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index 55d24f04a..640fe588e 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -3,6 +3,7 @@ use std::fmt::{self, Write}; use crate::messages::raw_rustc_output; +use cargo_test_support::compare; use cargo_test_support::install::exe; use cargo_test_support::paths::CargoPathExt; use cargo_test_support::registry::Package; @@ -1519,3 +1520,40 @@ fn versionless_package() { ) .run(); } + +#[cargo_test] +fn pkgid_querystring_works() { + let git_project = git::new("gitdep", |p| { + p.file("Cargo.toml", &basic_manifest("gitdep", "1.0.0")) + .file("src/lib.rs", "") + }); + let p = project() + .file( + "Cargo.toml", + &format!( + r#" + [package] + name = "foo" + + [dependencies] + gitdep = {{ git = "{}", branch = "master" }} + "#, + git_project.url() + ), + ) + .file("src/lib.rs", "") + .build(); + + p.cargo("generate-lockfile").run(); + + let output = p.cargo("pkgid").arg("gitdep").exec_with_output().unwrap(); + let gitdep_pkgid = String::from_utf8(output.stdout).unwrap(); + let gitdep_pkgid = gitdep_pkgid.trim(); + compare::assert_match_exact("git+file://[..]/gitdep?branch=master#1.0.0", &gitdep_pkgid); + + p.cargo("build -p") + .arg(gitdep_pkgid) + .with_status(101) + .with_stderr("[ERROR] package pattern(s) `git+file:///[..]/gitdep?branch=master#1.0.0` not found in workspace `[CWD]`") + .run(); +}