diff --git a/src/bin/cargo/commands/info.rs b/src/bin/cargo/commands/info.rs
new file mode 100644
index 00000000000..065fcbcd9aa
--- /dev/null
+++ b/src/bin/cargo/commands/info.rs
@@ -0,0 +1,35 @@
+use anyhow::Context;
+use cargo::ops::info;
+use cargo::util::command_prelude::*;
+use cargo_util_schemas::core::PackageIdSpec;
+
+pub fn cli() -> Command {
+ Command::new("info")
+ .about("Display information about a package in the registry")
+ .arg(
+ Arg::new("package")
+ .required(true)
+ .value_name("SPEC")
+ .help_heading(heading::PACKAGE_SELECTION)
+ .help("Package to inspect"),
+ )
+ .arg_index("Registry index URL to search packages in")
+ .arg_registry("Registry to search packages in")
+ .arg_silent_suggestion()
+ .after_help(color_print::cstr!(
+ "Run `cargo help info>` for more detailed information.\n"
+ ))
+}
+
+pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
+ let package = args
+ .get_one::("package")
+ .map(String::as_str)
+ .unwrap();
+ let spec = PackageIdSpec::parse(package)
+ .with_context(|| format!("invalid package ID specification: `{package}`"))?;
+
+ let reg_or_index = args.registry_or_index(gctx)?;
+ info(&spec, gctx, reg_or_index)?;
+ Ok(())
+}
diff --git a/src/bin/cargo/commands/mod.rs b/src/bin/cargo/commands/mod.rs
index 02c3438dc47..b507226f3a9 100644
--- a/src/bin/cargo/commands/mod.rs
+++ b/src/bin/cargo/commands/mod.rs
@@ -14,6 +14,7 @@ pub fn builtin() -> Vec {
generate_lockfile::cli(),
git_checkout::cli(),
help::cli(),
+ info::cli(),
init::cli(),
install::cli(),
locate_project::cli(),
@@ -59,6 +60,7 @@ pub fn builtin_exec(cmd: &str) -> Option {
"generate-lockfile" => generate_lockfile::exec,
"git-checkout" => git_checkout::exec,
"help" => help::exec,
+ "info" => info::exec,
"init" => init::exec,
"install" => install::exec,
"locate-project" => locate_project::exec,
@@ -102,6 +104,7 @@ pub mod fix;
pub mod generate_lockfile;
pub mod git_checkout;
pub mod help;
+pub mod info;
pub mod init;
pub mod install;
pub mod locate_project;
diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs
index b32b2147dc9..0cbf8f92203 100644
--- a/src/cargo/ops/mod.rs
+++ b/src/cargo/ops/mod.rs
@@ -24,6 +24,7 @@ pub use self::cargo_update::write_manifest_upgrades;
pub use self::cargo_update::UpdateOptions;
pub use self::fix::{fix, fix_exec_rustc, fix_get_proxy_lock_addr, FixOptions};
pub use self::lockfile::{load_pkg_lockfile, resolve_to_string, write_pkg_lockfile};
+pub use self::registry::info;
pub use self::registry::modify_owners;
pub use self::registry::publish;
pub use self::registry::registry_login;
diff --git a/src/cargo/ops/registry/info/mod.rs b/src/cargo/ops/registry/info/mod.rs
new file mode 100644
index 00000000000..e4607d0e32a
--- /dev/null
+++ b/src/cargo/ops/registry/info/mod.rs
@@ -0,0 +1,287 @@
+//! Implementation of `cargo info`.
+
+use anyhow::bail;
+use cargo_credential::Operation;
+use cargo_util_schemas::core::{PackageIdSpec, PartialVersion};
+use crates_io::User;
+
+use crate::core::registry::PackageRegistry;
+use crate::core::{Dependency, Package, PackageId, PackageIdSpecQuery, Registry, Workspace};
+use crate::ops::registry::info::view::pretty_view;
+use crate::ops::registry::{get_source_id_with_package_id, RegistryOrIndex, RegistrySourceIds};
+use crate::ops::resolve_ws;
+use crate::sources::source::QueryKind;
+use crate::sources::{IndexSummary, SourceConfigMap};
+use crate::util::auth::AuthorizationErrorReason;
+use crate::util::cache_lock::CacheLockMode;
+use crate::util::command_prelude::root_manifest;
+use crate::{CargoResult, GlobalContext};
+
+mod view;
+
+pub fn info(
+ spec: &PackageIdSpec,
+ gctx: &GlobalContext,
+ reg_or_index: Option,
+) -> CargoResult<()> {
+ let source_config = SourceConfigMap::new(gctx)?;
+ let mut registry = PackageRegistry::new_with_source_config(gctx, source_config)?;
+ // Make sure we get the lock before we download anything.
+ let _lock = gctx.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?;
+ registry.lock_patches();
+
+ // If we can find it in workspace, use it as a specific version.
+ let nearest_manifest_path = root_manifest(None, gctx).ok();
+ let ws = nearest_manifest_path
+ .as_ref()
+ .and_then(|root| Workspace::new(root, gctx).ok());
+ validate_locked_and_frozen_options(ws.is_some(), gctx)?;
+ let nearest_package = ws.as_ref().and_then(|ws| {
+ nearest_manifest_path
+ .as_ref()
+ .and_then(|path| ws.members().find(|p| p.manifest_path() == path))
+ });
+ let (mut package_id, is_member) = find_pkgid_in_ws(nearest_package, ws.as_ref(), spec);
+ let (use_package_source_id, source_ids) =
+ get_source_id_with_package_id(gctx, package_id, reg_or_index.as_ref())?;
+ // If we don't use the package's source, we need to query the package ID from the specified registry.
+ if !use_package_source_id {
+ package_id = None;
+ }
+
+ let msrv_from_nearest_manifest_path_or_ws =
+ try_get_msrv_from_nearest_manifest_or_ws(nearest_package, ws.as_ref());
+ // If the workspace does not have a specific Rust version,
+ // or if the command is not called within the workspace, then fallback to the global Rust version.
+ let rustc_version = match msrv_from_nearest_manifest_path_or_ws {
+ Some(msrv) => msrv,
+ None => {
+ let current_rustc = gctx.load_global_rustc(ws.as_ref())?.version;
+ // Remove any pre-release identifiers for easier comparison.
+ // Otherwise, the MSRV check will fail if the current Rust version is a nightly or beta version.
+ semver::Version::new(
+ current_rustc.major,
+ current_rustc.minor,
+ current_rustc.patch,
+ )
+ .into()
+ }
+ };
+ // Only suggest cargo tree command when the package is not a workspace member.
+ // For workspace members, `cargo tree --package --invert` is useless. It only prints itself.
+ let suggest_cargo_tree_command = package_id.is_some() && !is_member;
+
+ let summaries = query_summaries(spec, &mut registry, &source_ids)?;
+ let package_id = match package_id {
+ Some(id) => id,
+ None => find_pkgid_in_summaries(&summaries, spec, &rustc_version, &source_ids)?,
+ };
+
+ let package = registry.get(&[package_id])?;
+ let package = package.get_one(package_id)?;
+ let owners = try_list_owners(
+ gctx,
+ &source_ids,
+ reg_or_index.as_ref(),
+ package_id.name().as_str(),
+ )?;
+ pretty_view(
+ package,
+ &summaries,
+ &owners,
+ suggest_cargo_tree_command,
+ gctx,
+ )?;
+
+ Ok(())
+}
+
+fn find_pkgid_in_ws(
+ nearest_package: Option<&Package>,
+ ws: Option<&Workspace<'_>>,
+ spec: &PackageIdSpec,
+) -> (Option, bool) {
+ let Some(ws) = ws else {
+ return (None, false);
+ };
+
+ if let Some(member) = ws.members().find(|p| spec.matches(p.package_id())) {
+ return (Some(member.package_id()), true);
+ }
+
+ let Ok((_, resolve)) = resolve_ws(ws, false) else {
+ return (None, false);
+ };
+
+ if let Some(package_id) = nearest_package
+ .map(|p| p.package_id())
+ .into_iter()
+ .flat_map(|p| resolve.deps(p))
+ .map(|(p, _)| p)
+ .filter(|&p| spec.matches(p))
+ .max_by_key(|&p| p.version())
+ {
+ return (Some(package_id), false);
+ }
+
+ if let Some(package_id) = ws
+ .members()
+ .map(|p| p.package_id())
+ .flat_map(|p| resolve.deps(p))
+ .map(|(p, _)| p)
+ .filter(|&p| spec.matches(p))
+ .max_by_key(|&p| p.version())
+ {
+ return (Some(package_id), false);
+ }
+
+ if let Some(package_id) = resolve
+ .iter()
+ .filter(|&p| spec.matches(p))
+ .max_by_key(|&p| p.version())
+ {
+ return (Some(package_id), false);
+ }
+
+ (None, false)
+}
+
+fn find_pkgid_in_summaries(
+ summaries: &[IndexSummary],
+ spec: &PackageIdSpec,
+ rustc_version: &PartialVersion,
+ source_ids: &RegistrySourceIds,
+) -> CargoResult {
+ let summary = summaries
+ .iter()
+ .filter(|s| spec.matches(s.package_id()))
+ .max_by(|s1, s2| {
+ // Check the MSRV compatibility.
+ let s1_matches = s1
+ .as_summary()
+ .rust_version()
+ .map(|v| v.is_compatible_with(rustc_version))
+ .unwrap_or_else(|| false);
+ let s2_matches = s2
+ .as_summary()
+ .rust_version()
+ .map(|v| v.is_compatible_with(rustc_version))
+ .unwrap_or_else(|| false);
+ // MSRV compatible version is preferred.
+ match (s1_matches, s2_matches) {
+ (true, false) => std::cmp::Ordering::Greater,
+ (false, true) => std::cmp::Ordering::Less,
+ // If both summaries match the current Rust version or neither do, try to
+ // pick the latest version.
+ _ => s1.package_id().version().cmp(s2.package_id().version()),
+ }
+ });
+
+ match summary {
+ Some(summary) => Ok(summary.package_id()),
+ None => {
+ anyhow::bail!(
+ "could not find `{}` in registry `{}`",
+ spec,
+ source_ids.original.url()
+ )
+ }
+ }
+}
+
+fn query_summaries(
+ spec: &PackageIdSpec,
+ registry: &mut PackageRegistry<'_>,
+ source_ids: &RegistrySourceIds,
+) -> CargoResult> {
+ // Query without version requirement to get all index summaries.
+ let dep = Dependency::parse(spec.name(), None, source_ids.original)?;
+ loop {
+ // Exact to avoid returning all for path/git
+ match registry.query_vec(&dep, QueryKind::Exact) {
+ std::task::Poll::Ready(res) => {
+ break res;
+ }
+ std::task::Poll::Pending => registry.block_until_ready()?,
+ }
+ }
+}
+
+// Try to list the login and name of all owners of a crate.
+fn try_list_owners(
+ gctx: &GlobalContext,
+ source_ids: &RegistrySourceIds,
+ reg_or_index: Option<&RegistryOrIndex>,
+ package_name: &str,
+) -> CargoResult
+
+
auto (default): Automatically detect if color support is available on the
+terminal.
+
always: Always display colors.
+
never: Never display colors.
+
+
May also be specified with the term.color
+config value.
+
+
+
+### Manifest Options
+
+
+
--locked
+
Asserts that the exact same dependencies and versions are used as when the
+existing Cargo.lock file was originally generated. Cargo will exit with an
+error when either of the following scenarios arises:
+
+
The lock file is missing.
+
Cargo attempted to change the lock file due to a different dependency resolution.
+
+
It may be used in environments where deterministic builds are desired,
+such as in CI pipelines.
+
+
+
--offline
+
Prevents Cargo from accessing the network for any reason. Without this
+flag, Cargo will stop with an error if it needs to access the network and
+the network is not available. With this flag, Cargo will attempt to
+proceed without the network if possible.
+
Beware that this may result in different dependency resolution than online
+mode. Cargo will restrict itself to crates that are downloaded locally, even
+if there might be a newer version as indicated in the local copy of the index.
+See the cargo-fetch(1) command to download dependencies before going
+offline.
+
May also be specified with the net.offlineconfig value.
+
+
+
--frozen
+
Equivalent to specifying both --locked and --offline.
+
+
+
+### Common Options
+
+
+
+
+toolchain
+
If Cargo has been installed with rustup, and the first argument to cargo
+begins with +, it will be interpreted as a rustup toolchain name (such
+as +stable or +nightly).
+See the rustup documentation
+for more information about how toolchain overrides work.
+
+
+
--configKEY=VALUE or PATH
+
Overrides a Cargo configuration value. The argument should be in TOML syntax of KEY=VALUE,
+or provided as a path to an extra configuration file. This flag may be specified multiple times.
+See the command-line overrides section for more information.
+
+
+
-CPATH
+
Changes the current working directory before executing any specified operations. This affects
+things like where cargo looks by default for the project manifest (Cargo.toml), as well as
+the directories searched for discovering .cargo/config.toml, for example. This option must
+appear before the command name, for example cargo -C path/to/my-project build.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#10098).
+
+
+
-h
+
--help
+
Prints help information.
+
+
+
-Zflag
+
Unstable (nightly-only) flags to Cargo. Run cargo -Z help for details.
+
+
+
+
+## ENVIRONMENT
+
+See [the reference](../reference/environment-variables.html) for
+details on environment variables that Cargo reads.
+
+## EXIT STATUS
+
+* `0`: Cargo succeeded.
+* `101`: Cargo failed to complete.
+
+## EXAMPLES
+
+1. Inspect the `serde` package from crates.io:
+
+ cargo info serde
+2. Inspect the `serde` package with version `1.0.0`:
+
+ cargo info serde@1.0.0
+3. Inspect the `serde` package form the local registry:
+
+ cargo info serde --registry my-registry
+
+## SEE ALSO
+
+[cargo(1)](cargo.html), [cargo-search(1)](cargo-search.html)
diff --git a/src/doc/src/commands/cargo.md b/src/doc/src/commands/cargo.md
index ccba5dc446b..f6d7fc599fc 100644
--- a/src/doc/src/commands/cargo.md
+++ b/src/doc/src/commands/cargo.md
@@ -62,6 +62,9 @@ available at .
[cargo-generate-lockfile(1)](cargo-generate-lockfile.html)\
Generate `Cargo.lock` for a project.
+[cargo-info(1)](cargo-info.html)\
+ Display information about a package in the registry. Default registry is crates.io.
+
[cargo-locate-project(1)](cargo-locate-project.html)\
Print a JSON representation of a `Cargo.toml` file's location.
@@ -338,4 +341,5 @@ stable yet and may be subject to change.
See for issues.
## SEE ALSO
+
[rustc(1)](https://doc.rust-lang.org/rustc/index.html), [rustdoc(1)](https://doc.rust-lang.org/rustdoc/index.html)
diff --git a/src/doc/src/commands/manifest-commands.md b/src/doc/src/commands/manifest-commands.md
index 98a82d8aa0b..b83e7b93044 100644
--- a/src/doc/src/commands/manifest-commands.md
+++ b/src/doc/src/commands/manifest-commands.md
@@ -1,5 +1,7 @@
# Manifest Commands
+
* [cargo add](cargo-add.md)
+* [cargo_info](cargo-info.md)
* [cargo generate-lockfile](cargo-generate-lockfile.md)
* [cargo locate-project](cargo-locate-project.md)
* [cargo metadata](cargo-metadata.md)
diff --git a/src/etc/_cargo b/src/etc/_cargo
index 0158f6bd85c..b564f5bb0e9 100644
--- a/src/etc/_cargo
+++ b/src/etc/_cargo
@@ -163,6 +163,11 @@ _cargo() {
help)
_cargo_cmds
;;
+ info)
+ _arguments -s -A "^--" $common $registry \
+ '--index=[specify registry index]:index' \
+ '*: :_guard "^-*" "crate"'
+ ;;
init)
_arguments -s -S $common $registry \
diff --git a/src/etc/cargo.bashcomp.sh b/src/etc/cargo.bashcomp.sh
index 5219b8b66ea..10212f92b90 100644
--- a/src/etc/cargo.bashcomp.sh
+++ b/src/etc/cargo.bashcomp.sh
@@ -63,6 +63,7 @@ _cargo()
local opt__fix="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_parallel $opt_targets $opt_lock --release --target --message-format --broken-code --edition --edition-idioms --allow-no-vcs --allow-dirty --allow-staged --profile --target-dir --ignore-rust-version"
local opt__generate_lockfile="$opt_common $opt_mani $opt_lock"
local opt__help="$opt_help"
+ local opt__info="$opt_common $opt_lock --registry --index"
local opt__init="$opt_common $opt_lock --bin --lib --name --vcs --edition --registry"
local opt__install="$opt_common $opt_feat $opt_parallel $opt_lock $opt_force --bin --bins --branch --debug --example --examples --git --list --path --rev --root --tag --version --registry --target --profile --no-track --ignore-rust-version"
local opt__locate_project="$opt_common $opt_mani $opt_lock --message-format --workspace"
diff --git a/src/etc/man/cargo-info.1 b/src/etc/man/cargo-info.1
new file mode 100644
index 00000000000..9c6ea85eb0d
--- /dev/null
+++ b/src/etc/man/cargo-info.1
@@ -0,0 +1,201 @@
+'\" t
+.TH "CARGO\-INFO" "1"
+.nh
+.ad l
+.ss \n[.ss] 0
+.SH "NAME"
+cargo\-info \[em] Display information about a package in the registry. Default registry is crates.io
+.SH "SYNOPSIS"
+\fBcargo info\fR [\fIoptions\fR] \fIspec\fR
+.SH "DESCRIPTION"
+This command displays information about a package in the registry. It fetches data from the package\[cq]s Cargo.toml file
+and presents it in a human\-readable format.
+.SH "OPTIONS"
+.SS "Info Options"
+.sp
+\fIspec\fR
+.RS 4
+Fetch information about the specified package. The \fIspec\fR can be a package ID, see \fBcargo\-pkgid\fR(1) for the SPEC
+format.
+If the specified package is part of the current workspace, information from the local Cargo.toml file will be displayed.
+If the \fBCargo.lock\fR file does not exist, it will be created. If no version is specified, the appropriate version will be
+selected based on the Minimum Supported Rust Version (MSRV).
+.RE
+.sp
+\fB\-\-index\fR \fIindex\fR
+.RS 4
+The URL of the registry index to use.
+.RE
+.sp
+\fB\-\-registry\fR \fIregistry\fR
+.RS 4
+Name of the registry to use. Registry names are defined in \fICargo config
+files\fR \&. If not specified, the default registry is used,
+which is defined by the \fBregistry.default\fR config key which defaults to
+\fBcrates\-io\fR\&.
+.RE
+.SS "Display Options"
+.sp
+\fB\-v\fR,
+\fB\-\-verbose\fR
+.RS 4
+Use verbose output. May be specified twice for \[lq]very verbose\[rq] output which
+includes extra output such as dependency warnings and build script output.
+May also be specified with the \fBterm.verbose\fR
+\fIconfig value\fR \&.
+.RE
+.sp
+\fB\-q\fR,
+\fB\-\-quiet\fR
+.RS 4
+Do not print cargo log messages.
+May also be specified with the \fBterm.quiet\fR
+\fIconfig value\fR \&.
+.RE
+.sp
+\fB\-\-color\fR \fIwhen\fR
+.RS 4
+Control when colored output is used. Valid values:
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fBauto\fR (default): Automatically detect if color support is available on the
+terminal.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fBalways\fR: Always display colors.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fBnever\fR: Never display colors.
+.RE
+.sp
+May also be specified with the \fBterm.color\fR
+\fIconfig value\fR \&.
+.RE
+.SS "Manifest Options"
+.sp
+\fB\-\-locked\fR
+.RS 4
+Asserts that the exact same dependencies and versions are used as when the
+existing \fBCargo.lock\fR file was originally generated. Cargo will exit with an
+error when either of the following scenarios arises:
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'The lock file is missing.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'Cargo attempted to change the lock file due to a different dependency resolution.
+.RE
+.sp
+It may be used in environments where deterministic builds are desired,
+such as in CI pipelines.
+.RE
+.sp
+\fB\-\-offline\fR
+.RS 4
+Prevents Cargo from accessing the network for any reason. Without this
+flag, Cargo will stop with an error if it needs to access the network and
+the network is not available. With this flag, Cargo will attempt to
+proceed without the network if possible.
+.sp
+Beware that this may result in different dependency resolution than online
+mode. Cargo will restrict itself to crates that are downloaded locally, even
+if there might be a newer version as indicated in the local copy of the index.
+See the \fBcargo\-fetch\fR(1) command to download dependencies before going
+offline.
+.sp
+May also be specified with the \fBnet.offline\fR \fIconfig value\fR \&.
+.RE
+.sp
+\fB\-\-frozen\fR
+.RS 4
+Equivalent to specifying both \fB\-\-locked\fR and \fB\-\-offline\fR\&.
+.RE
+.SS "Common Options"
+.sp
+\fB+\fR\fItoolchain\fR
+.RS 4
+If Cargo has been installed with rustup, and the first argument to \fBcargo\fR
+begins with \fB+\fR, it will be interpreted as a rustup toolchain name (such
+as \fB+stable\fR or \fB+nightly\fR).
+See the \fIrustup documentation\fR
+for more information about how toolchain overrides work.
+.RE
+.sp
+\fB\-\-config\fR \fIKEY=VALUE\fR or \fIPATH\fR
+.RS 4
+Overrides a Cargo configuration value. The argument should be in TOML syntax of \fBKEY=VALUE\fR,
+or provided as a path to an extra configuration file. This flag may be specified multiple times.
+See the \fIcommand\-line overrides section\fR for more information.
+.RE
+.sp
+\fB\-C\fR \fIPATH\fR
+.RS 4
+Changes the current working directory before executing any specified operations. This affects
+things like where cargo looks by default for the project manifest (\fBCargo.toml\fR), as well as
+the directories searched for discovering \fB\&.cargo/config.toml\fR, for example. This option must
+appear before the command name, for example \fBcargo \-C path/to/my\-project build\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#10098\fR ).
+.RE
+.sp
+\fB\-h\fR,
+\fB\-\-help\fR
+.RS 4
+Prints help information.
+.RE
+.sp
+\fB\-Z\fR \fIflag\fR
+.RS 4
+Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fR for details.
+.RE
+.SH "ENVIRONMENT"
+See \fIthe reference\fR for
+details on environment variables that Cargo reads.
+.SH "EXIT STATUS"
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fB0\fR: Cargo succeeded.
+.RE
+.sp
+.RS 4
+\h'-04'\(bu\h'+02'\fB101\fR: Cargo failed to complete.
+.RE
+.SH "EXAMPLES"
+.sp
+.RS 4
+\h'-04' 1.\h'+01'Inspect the \fBserde\fR package from crates.io:
+.sp
+.RS 4
+.nf
+ cargo info serde
+.fi
+.RE
+.RE
+.sp
+.RS 4
+\h'-04' 2.\h'+01'Inspect the \fBserde\fR package with version \fB1.0.0\fR:
+.sp
+.RS 4
+.nf
+ cargo info serde@1.0.0
+.fi
+.RE
+.RE
+.sp
+.RS 4
+\h'-04' 3.\h'+01'Inspect the \fBserde\fR package form the local registry:
+.sp
+.RS 4
+.nf
+ cargo info serde \-\-registry my\-registry
+.fi
+.RE
+.RE
+.SH "SEE ALSO"
+\fBcargo\fR(1), \fBcargo\-search\fR(1)
diff --git a/src/etc/man/cargo.1 b/src/etc/man/cargo.1
index eebcf89e43d..b285d67bd12 100644
--- a/src/etc/man/cargo.1
+++ b/src/etc/man/cargo.1
@@ -72,6 +72,10 @@ available at \&.
.br
\ \ \ \ Generate \fBCargo.lock\fR for a project.
.sp
+\fBcargo\-info\fR(1)
+.br
+\ \ \ \ Display information about a package in the registry. Default registry is crates.io.
+.sp
\fBcargo\-locate\-project\fR(1)
.br
\ \ \ \ Print a JSON representation of a \fBCargo.toml\fR file\[cq]s location.
diff --git a/tests/testsuite/cargo_info/basic/mod.rs b/tests/testsuite/cargo_info/basic/mod.rs
new file mode 100644
index 00000000000..dd10058db7c
--- /dev/null
+++ b/tests/testsuite/cargo_info/basic/mod.rs
@@ -0,0 +1,53 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ cargo_test_support::registry::Package::new("my-package", "0.1.0")
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "my-package"
+ version = "0.1.0"
+ description = "A package for testing"
+ repository = "https://github.com/hi-rustin/cargo-infromation"
+ documentation = "https://docs.rs/my-package/0.1.0"
+ license = "MIT"
+ edition = "2018"
+ rust-version = "1.50.0"
+ keywords = ["foo", "bar", "baz"]
+
+ [features]
+ default = ["feature1"]
+ feature1 = []
+ feature2 = []
+
+ [dependencies]
+ foo = "0.1.0"
+ bar = "0.2.0"
+ baz = { version = "0.3.0", optional = true }
+
+ [[bin]]
+ name = "my_bin"
+
+ [lib]
+ name = "my_lib"
+ "#,
+ )
+ .file("src/bin/my_bin.rs", "")
+ .file("src/lib.rs", "")
+ .publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/basic/stderr.term.svg b/tests/testsuite/cargo_info/basic/stderr.term.svg
new file mode 100644
index 00000000000..5d324184d55
--- /dev/null
+++ b/tests/testsuite/cargo_info/basic/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/basic/stdout.term.svg b/tests/testsuite/cargo_info/basic/stdout.term.svg
new file mode 100644
index 00000000000..d5e381d76bd
--- /dev/null
+++ b/tests/testsuite/cargo_info/basic/stdout.term.svg
@@ -0,0 +1,51 @@
+
diff --git a/tests/testsuite/cargo_info/features/mod.rs b/tests/testsuite/cargo_info/features/mod.rs
new file mode 100644
index 00000000000..303b589a867
--- /dev/null
+++ b/tests/testsuite/cargo_info/features/mod.rs
@@ -0,0 +1,23 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ cargo_test_support::registry::Package::new("my-package", "0.1.1")
+ .feature("default", &["feature1", "feature2"])
+ .feature("feature1", &[])
+ .feature("feature2", &[])
+ .publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/features/stderr.term.svg b/tests/testsuite/cargo_info/features/stderr.term.svg
new file mode 100644
index 00000000000..62667b6f800
--- /dev/null
+++ b/tests/testsuite/cargo_info/features/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/features/stdout.term.svg b/tests/testsuite/cargo_info/features/stdout.term.svg
new file mode 100644
index 00000000000..c79747b9be0
--- /dev/null
+++ b/tests/testsuite/cargo_info/features/stdout.term.svg
@@ -0,0 +1,44 @@
+
diff --git a/tests/testsuite/cargo_info/features_activated_over_limit/mod.rs b/tests/testsuite/cargo_info/features_activated_over_limit/mod.rs
new file mode 100644
index 00000000000..49fadef3e9b
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_activated_over_limit/mod.rs
@@ -0,0 +1,36 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ const MANY_FEATURES_COUNT: usize = 200;
+ const DEFAULT_FEATURES_COUNT: usize = 100;
+
+ init_registry_without_token();
+ let mut test_package =
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package");
+ let features = (0..MANY_FEATURES_COUNT)
+ .map(|i| format!("eyes{i:03}"))
+ .collect::>();
+ for name in &features {
+ test_package.feature(name.as_str(), &[]);
+ }
+ let default_features = features
+ .iter()
+ .take(DEFAULT_FEATURES_COUNT)
+ .map(|s| s.as_str())
+ .collect::>();
+ test_package.feature("default", &default_features);
+ test_package.publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("your-face")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/features_activated_over_limit/stderr.term.svg b/tests/testsuite/cargo_info/features_activated_over_limit/stderr.term.svg
new file mode 100644
index 00000000000..de41e3894c1
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_activated_over_limit/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/features_activated_over_limit/stdout.term.svg b/tests/testsuite/cargo_info/features_activated_over_limit/stdout.term.svg
new file mode 100644
index 00000000000..53f0e5a02e5
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_activated_over_limit/stdout.term.svg
@@ -0,0 +1,43 @@
+
diff --git a/tests/testsuite/cargo_info/features_activated_over_limit_verbose/mod.rs b/tests/testsuite/cargo_info/features_activated_over_limit_verbose/mod.rs
new file mode 100644
index 00000000000..95b4dfdb76b
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_activated_over_limit_verbose/mod.rs
@@ -0,0 +1,37 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ const MANY_FEATURES_COUNT: usize = 200;
+ const DEFAULT_FEATURES_COUNT: usize = 100;
+
+ init_registry_without_token();
+ let mut test_package =
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package");
+ let features = (0..MANY_FEATURES_COUNT)
+ .map(|i| format!("eyes{i:03}"))
+ .collect::>();
+ for name in &features {
+ test_package.feature(name.as_str(), &[]);
+ }
+ let default_features = features
+ .iter()
+ .take(DEFAULT_FEATURES_COUNT)
+ .map(|s| s.as_str())
+ .collect::>();
+ test_package.feature("default", &default_features);
+ test_package.publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("your-face")
+ .arg("--verbose")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/features_activated_over_limit_verbose/stderr.term.svg b/tests/testsuite/cargo_info/features_activated_over_limit_verbose/stderr.term.svg
new file mode 100644
index 00000000000..4856382c623
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_activated_over_limit_verbose/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/features_activated_over_limit_verbose/stdout.term.svg b/tests/testsuite/cargo_info/features_activated_over_limit_verbose/stdout.term.svg
new file mode 100644
index 00000000000..e16531b3249
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_activated_over_limit_verbose/stdout.term.svg
@@ -0,0 +1,441 @@
+
diff --git a/tests/testsuite/cargo_info/features_deactivated_over_limit/mod.rs b/tests/testsuite/cargo_info/features_deactivated_over_limit/mod.rs
new file mode 100644
index 00000000000..ad6bfa03c3f
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_deactivated_over_limit/mod.rs
@@ -0,0 +1,36 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ const MANY_FEATURES_COUNT: usize = 200;
+ const DEFAULT_FEATURES_COUNT: usize = 20;
+
+ init_registry_without_token();
+ let mut test_package =
+ cargo_test_support::registry::Package::new("your-face", "99999.0.0+my-package");
+ let features = (0..MANY_FEATURES_COUNT)
+ .map(|i| format!("eyes{i:03}"))
+ .collect::>();
+ for name in &features {
+ test_package.feature(name.as_str(), &[]);
+ }
+ let default_features = features
+ .iter()
+ .take(DEFAULT_FEATURES_COUNT)
+ .map(|s| s.as_str())
+ .collect::>();
+ test_package.feature("default", &default_features);
+ test_package.publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("your-face")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/features_deactivated_over_limit/stderr.term.svg b/tests/testsuite/cargo_info/features_deactivated_over_limit/stderr.term.svg
new file mode 100644
index 00000000000..de41e3894c1
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_deactivated_over_limit/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/features_deactivated_over_limit/stdout.term.svg b/tests/testsuite/cargo_info/features_deactivated_over_limit/stdout.term.svg
new file mode 100644
index 00000000000..cfadcd506ec
--- /dev/null
+++ b/tests/testsuite/cargo_info/features_deactivated_over_limit/stdout.term.svg
@@ -0,0 +1,83 @@
+
diff --git a/tests/testsuite/cargo_info/git_dependency/mod.rs b/tests/testsuite/cargo_info/git_dependency/mod.rs
new file mode 100644
index 00000000000..5872aee3070
--- /dev/null
+++ b/tests/testsuite/cargo_info/git_dependency/mod.rs
@@ -0,0 +1,44 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{basic_manifest, file, git, project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ let baz = git::new("baz", |project| {
+ project
+ .file("Cargo.toml", &basic_manifest("baz", "0.1.0"))
+ .file("src/lib.rs", "")
+ });
+
+ let foo = project()
+ .file(
+ "Cargo.toml",
+ &format!(
+ r#"
+ [package]
+ name = "foo"
+ version = "0.1.0"
+
+ [dependencies]
+ baz = {{ git = '{}' }}
+ "#,
+ baz.url()
+ ),
+ )
+ .file("src/lib.rs", "")
+ .build();
+
+ let project_root = foo.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg_line("--verbose foo")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq("");
+}
diff --git a/tests/testsuite/cargo_info/git_dependency/stdout.term.svg b/tests/testsuite/cargo_info/git_dependency/stdout.term.svg
new file mode 100644
index 00000000000..ded341482ad
--- /dev/null
+++ b/tests/testsuite/cargo_info/git_dependency/stdout.term.svg
@@ -0,0 +1,40 @@
+
diff --git a/tests/testsuite/cargo_info/help/mod.rs b/tests/testsuite/cargo_info/help/mod.rs
new file mode 100644
index 00000000000..edaa377d522
--- /dev/null
+++ b/tests/testsuite/cargo_info/help/mod.rs
@@ -0,0 +1,13 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+#[cargo_test]
+fn case() {
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("--help")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq("");
+}
diff --git a/tests/testsuite/cargo_info/help/stdout.term.svg b/tests/testsuite/cargo_info/help/stdout.term.svg
new file mode 100644
index 00000000000..8cefda8b1f2
--- /dev/null
+++ b/tests/testsuite/cargo_info/help/stdout.term.svg
@@ -0,0 +1,72 @@
+
diff --git a/tests/testsuite/cargo_info/mod.rs b/tests/testsuite/cargo_info/mod.rs
new file mode 100644
index 00000000000..4e8f48e161f
--- /dev/null
+++ b/tests/testsuite/cargo_info/mod.rs
@@ -0,0 +1,38 @@
+mod basic;
+mod features;
+mod features_activated_over_limit;
+mod features_activated_over_limit_verbose;
+mod features_deactivated_over_limit;
+mod git_dependency;
+mod help;
+mod not_found;
+mod path_dependency;
+mod pick_msrv_compatible_package;
+mod pick_msrv_compatible_package_within_ws;
+mod pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws;
+mod specify_empty_version_with_url;
+mod specify_version_outside_ws;
+mod specify_version_with_url_but_registry_is_not_matched;
+mod specify_version_within_ws_and_conflict_with_lockfile;
+mod specify_version_within_ws_and_match_with_lockfile;
+mod transitive_dependency_within_ws;
+mod verbose;
+mod with_frozen_outside_ws;
+mod with_frozen_within_ws;
+mod with_locked_outside_ws;
+mod with_locked_within_ws;
+mod with_locked_within_ws_and_pick_the_package;
+mod with_offline;
+mod with_quiet;
+mod within_ws;
+mod within_ws_and_pick_ws_package;
+mod within_ws_with_alternative_registry;
+mod within_ws_without_lockfile;
+
+// Initialize the registry without a token.
+// Otherwise, it will try to list owners of the crate and fail.
+pub(crate) fn init_registry_without_token() {
+ let _reg = cargo_test_support::registry::RegistryBuilder::new()
+ .no_configure_token()
+ .build();
+}
diff --git a/tests/testsuite/cargo_info/not_found/in b/tests/testsuite/cargo_info/not_found/in
new file mode 120000
index 00000000000..e9fe1ca7b01
--- /dev/null
+++ b/tests/testsuite/cargo_info/not_found/in
@@ -0,0 +1 @@
+../within_workspace.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_info/not_found/mod.rs b/tests/testsuite/cargo_info/not_found/mod.rs
new file mode 100644
index 00000000000..bccfe0345e5
--- /dev/null
+++ b/tests/testsuite/cargo_info/not_found/mod.rs
@@ -0,0 +1,24 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("unknown")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/not_found/out/Cargo.lock b/tests/testsuite/cargo_info/not_found/out/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/not_found/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/not_found/out/Cargo.toml b/tests/testsuite/cargo_info/not_found/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/not_found/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/not_found/out/src/lib.rs b/tests/testsuite/cargo_info/not_found/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/not_found/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/not_found/stderr.term.svg b/tests/testsuite/cargo_info/not_found/stderr.term.svg
new file mode 100644
index 00000000000..7ce41f4a41f
--- /dev/null
+++ b/tests/testsuite/cargo_info/not_found/stderr.term.svg
@@ -0,0 +1,30 @@
+
diff --git a/tests/testsuite/cargo_info/path_dependency/in/Cargo.lock b/tests/testsuite/cargo_info/path_dependency/in/Cargo.lock
new file mode 100644
index 00000000000..378b02cf7b7
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/in/Cargo.lock
@@ -0,0 +1,14 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "crate1"
+version = "0.0.0"
+
+[[package]]
+name = "foo"
+version = "0.0.0"
+dependencies = [
+ "crate1",
+]
diff --git a/tests/testsuite/cargo_info/path_dependency/in/Cargo.toml b/tests/testsuite/cargo_info/path_dependency/in/Cargo.toml
new file mode 100644
index 00000000000..be36b12df49
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/in/Cargo.toml
@@ -0,0 +1,9 @@
+[workspace]
+members = ["crates/*"]
+
+[package]
+name = "foo"
+version = "0.0.0"
+
+[dependencies]
+crate1 = { path = "./crates/crate1" }
diff --git a/tests/testsuite/cargo_info/path_dependency/in/crates/crate1/Cargo.toml b/tests/testsuite/cargo_info/path_dependency/in/crates/crate1/Cargo.toml
new file mode 100644
index 00000000000..7a87e72a96e
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/in/crates/crate1/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "crate1"
+version = "0.0.0"
+
+[dependencies]
diff --git a/tests/testsuite/cargo_info/path_dependency/in/crates/crate1/src/lib.rs b/tests/testsuite/cargo_info/path_dependency/in/crates/crate1/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/in/crates/crate1/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/path_dependency/in/src/lib.rs b/tests/testsuite/cargo_info/path_dependency/in/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/in/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/path_dependency/mod.rs b/tests/testsuite/cargo_info/path_dependency/mod.rs
new file mode 100644
index 00000000000..3c086895362
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/mod.rs
@@ -0,0 +1,24 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg_line("--verbose foo")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq("");
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/path_dependency/out/Cargo.lock b/tests/testsuite/cargo_info/path_dependency/out/Cargo.lock
new file mode 100644
index 00000000000..378b02cf7b7
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/out/Cargo.lock
@@ -0,0 +1,14 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "crate1"
+version = "0.0.0"
+
+[[package]]
+name = "foo"
+version = "0.0.0"
+dependencies = [
+ "crate1",
+]
diff --git a/tests/testsuite/cargo_info/path_dependency/out/Cargo.toml b/tests/testsuite/cargo_info/path_dependency/out/Cargo.toml
new file mode 100644
index 00000000000..be36b12df49
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/out/Cargo.toml
@@ -0,0 +1,9 @@
+[workspace]
+members = ["crates/*"]
+
+[package]
+name = "foo"
+version = "0.0.0"
+
+[dependencies]
+crate1 = { path = "./crates/crate1" }
diff --git a/tests/testsuite/cargo_info/path_dependency/out/crates/crate1/Cargo.toml b/tests/testsuite/cargo_info/path_dependency/out/crates/crate1/Cargo.toml
new file mode 100644
index 00000000000..7a87e72a96e
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/out/crates/crate1/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "crate1"
+version = "0.0.0"
+
+[dependencies]
diff --git a/tests/testsuite/cargo_info/path_dependency/out/crates/crate1/src/lib.rs b/tests/testsuite/cargo_info/path_dependency/out/crates/crate1/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/out/crates/crate1/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/path_dependency/out/src/lib.rs b/tests/testsuite/cargo_info/path_dependency/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/path_dependency/stdout.term.svg b/tests/testsuite/cargo_info/path_dependency/stdout.term.svg
new file mode 100644
index 00000000000..426c2aa388b
--- /dev/null
+++ b/tests/testsuite/cargo_info/path_dependency/stdout.term.svg
@@ -0,0 +1,40 @@
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package/mod.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package/mod.rs
new file mode 100644
index 00000000000..87f9f2aa4c7
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package/mod.rs
@@ -0,0 +1,24 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ cargo_test_support::registry::Package::new("my-package", "0.1.1+my-package")
+ .rust_version("1.0.0")
+ .publish();
+ cargo_test_support::registry::Package::new("my-package", "0.2.0+my-package")
+ .rust_version("1.9876.0")
+ .publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package/stderr.term.svg b/tests/testsuite/cargo_info/pick_msrv_compatible_package/stderr.term.svg
new file mode 100644
index 00000000000..51426fe9046
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package/stdout.term.svg b/tests/testsuite/cargo_info/pick_msrv_compatible_package/stdout.term.svg
new file mode 100644
index 00000000000..51b4f54fdf8
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/Cargo.toml
new file mode 100644
index 00000000000..792cd9914d7
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/Cargo.toml
@@ -0,0 +1,2 @@
+[workspace]
+members = ["crate*"]
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate1/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate1/Cargo.toml
new file mode 100644
index 00000000000..e64842dc4ea
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate1/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "crate1"
+version = "0.0.0"
+rust-version = "1.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate1/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate2/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate2/Cargo.toml
new file mode 100644
index 00000000000..308a2b91037
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate2/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "crate2"
+version = "0.0.0"
+rust-version = "1.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate2/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/in/crate2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/mod.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/mod.rs
new file mode 100644
index 00000000000..b662a8fd5fe
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/mod.rs
@@ -0,0 +1,32 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
+ cargo_test_support::registry::Package::new("my-package", "0.2.0")
+ .rust_version("1.0.0")
+ .publish();
+ cargo_test_support::registry::Package::new("my-package", "0.2.1")
+ .rust_version("1.9876.0")
+ .publish();
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root.join("crate1");
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/Cargo.lock
new file mode 100644
index 00000000000..6934c7f24bf
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/Cargo.lock
@@ -0,0 +1,10 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "crate1"
+version = "0.0.0"
+
+[[package]]
+name = "crate2"
+version = "0.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/Cargo.toml
new file mode 100644
index 00000000000..792cd9914d7
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/Cargo.toml
@@ -0,0 +1,2 @@
+[workspace]
+members = ["crate*"]
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate1/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate1/Cargo.toml
new file mode 100644
index 00000000000..e64842dc4ea
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate1/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "crate1"
+version = "0.0.0"
+rust-version = "1.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate1/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate2/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate2/Cargo.toml
new file mode 100644
index 00000000000..308a2b91037
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate2/Cargo.toml
@@ -0,0 +1,5 @@
+[package]
+name = "crate2"
+version = "0.0.0"
+rust-version = "1.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate2/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/out/crate2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/stderr.term.svg b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/stderr.term.svg
new file mode 100644
index 00000000000..fa6295303b4
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/stdout.term.svg b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/stdout.term.svg
new file mode 100644
index 00000000000..2c521f36a13
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/Cargo.toml
new file mode 100644
index 00000000000..792cd9914d7
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/Cargo.toml
@@ -0,0 +1,2 @@
+[workspace]
+members = ["crate*"]
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate1/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate1/Cargo.toml
new file mode 100644
index 00000000000..60422fea1e4
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate1/Cargo.toml
@@ -0,0 +1,4 @@
+[package]
+name = "crate1"
+version = "0.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate1/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate2/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate2/Cargo.toml
new file mode 100644
index 00000000000..e1d2a463576
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate2/Cargo.toml
@@ -0,0 +1,4 @@
+[package]
+name = "crate2"
+version = "0.0.0"
+rust-version = "1.0.0"
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate2/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/in/crate2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/mod.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/mod.rs
new file mode 100644
index 00000000000..0a57bb3954f
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/mod.rs
@@ -0,0 +1,32 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ cargo_test_support::registry::Package::new("my-package", "0.1.0").publish();
+ cargo_test_support::registry::Package::new("my-package", "0.2.0")
+ .rust_version("1.0.0")
+ .publish();
+ cargo_test_support::registry::Package::new("my-package", "0.2.1")
+ .rust_version("1.70.0")
+ .publish();
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root.join("crate1");
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/Cargo.lock b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/Cargo.lock
new file mode 100644
index 00000000000..6934c7f24bf
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/Cargo.lock
@@ -0,0 +1,10 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "crate1"
+version = "0.0.0"
+
+[[package]]
+name = "crate2"
+version = "0.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/Cargo.toml
new file mode 100644
index 00000000000..792cd9914d7
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/Cargo.toml
@@ -0,0 +1,2 @@
+[workspace]
+members = ["crate*"]
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate1/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate1/Cargo.toml
new file mode 100644
index 00000000000..60422fea1e4
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate1/Cargo.toml
@@ -0,0 +1,4 @@
+[package]
+name = "crate1"
+version = "0.0.0"
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate1/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate2/Cargo.toml b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate2/Cargo.toml
new file mode 100644
index 00000000000..e1d2a463576
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate2/Cargo.toml
@@ -0,0 +1,4 @@
+[package]
+name = "crate2"
+version = "0.0.0"
+rust-version = "1.0.0"
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate2/src/lib.rs b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/out/crate2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/stderr.term.svg b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/stderr.term.svg
new file mode 100644
index 00000000000..fa6295303b4
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/stdout.term.svg b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/stdout.term.svg
new file mode 100644
index 00000000000..2c521f36a13
--- /dev/null
+++ b/tests/testsuite/cargo_info/pick_msrv_compatible_package_within_ws_and_use_msrv_from_ws/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/specify_empty_version_with_url/mod.rs b/tests/testsuite/cargo_info/specify_empty_version_with_url/mod.rs
new file mode 100644
index 00000000000..ee6c90ec275
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_empty_version_with_url/mod.rs
@@ -0,0 +1,22 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{file, registry::RegistryBuilder};
+
+#[cargo_test]
+fn case() {
+ let _ = RegistryBuilder::new()
+ .alternative()
+ .no_configure_token()
+ .build();
+ cargo_test_support::registry::Package::new("my-package", "99999.0.0-alpha.1+my-package")
+ .alternative(true)
+ .publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("https://crates.io")
+ .arg("--registry=alternative")
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/specify_empty_version_with_url/stderr.term.svg b/tests/testsuite/cargo_info/specify_empty_version_with_url/stderr.term.svg
new file mode 100644
index 00000000000..9893f1e611b
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_empty_version_with_url/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_outside_ws/mod.rs b/tests/testsuite/cargo_info/specify_version_outside_ws/mod.rs
new file mode 100644
index 00000000000..bfc36dfd7fd
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_outside_ws/mod.rs
@@ -0,0 +1,20 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in ["0.1.1+my-package", "0.2.0+my-package", "0.2.3+my-package"] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package@0.2")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/specify_version_outside_ws/stderr.term.svg b/tests/testsuite/cargo_info/specify_version_outside_ws/stderr.term.svg
new file mode 100644
index 00000000000..d607725e42c
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_outside_ws/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_outside_ws/stdout.term.svg b/tests/testsuite/cargo_info/specify_version_outside_ws/stdout.term.svg
new file mode 100644
index 00000000000..31a21fb5ecd
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_outside_ws/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_with_url_but_registry_is_not_matched/mod.rs b/tests/testsuite/cargo_info/specify_version_with_url_but_registry_is_not_matched/mod.rs
new file mode 100644
index 00000000000..3d460ccf495
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_with_url_but_registry_is_not_matched/mod.rs
@@ -0,0 +1,22 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{file, registry::RegistryBuilder};
+
+#[cargo_test]
+fn case() {
+ let _ = RegistryBuilder::new()
+ .alternative()
+ .no_configure_token()
+ .build();
+ cargo_test_support::registry::Package::new("my-package", "99999.0.0-alpha.1+my-package")
+ .alternative(true)
+ .publish();
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("https://crates.io/my-package")
+ .arg("--registry=alternative")
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/specify_version_with_url_but_registry_is_not_matched/stderr.term.svg b/tests/testsuite/cargo_info/specify_version_with_url_but_registry_is_not_matched/stderr.term.svg
new file mode 100644
index 00000000000..319478675f9
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_with_url_but_registry_is_not_matched/stderr.term.svg
@@ -0,0 +1,30 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/in b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/in
new file mode 120000
index 00000000000..e9fe1ca7b01
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/in
@@ -0,0 +1 @@
+../within_workspace.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/mod.rs b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/mod.rs
new file mode 100644
index 00000000000..a433b78e63c
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/mod.rs
@@ -0,0 +1,36 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package@0.4")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.lock b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.toml b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/src/lib.rs b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/stderr.term.svg b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/stderr.term.svg
new file mode 100644
index 00000000000..c7cd6790414
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/stdout.term.svg b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/stdout.term.svg
new file mode 100644
index 00000000000..78c9f57e0c7
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_conflict_with_lockfile/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/in b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/in
new file mode 120000
index 00000000000..e9fe1ca7b01
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/in
@@ -0,0 +1 @@
+../within_workspace.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/mod.rs b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/mod.rs
new file mode 100644
index 00000000000..736a9928627
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/mod.rs
@@ -0,0 +1,36 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package@0.1")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.lock b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.toml b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/src/lib.rs b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/stderr.term.svg b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/stderr.term.svg
new file mode 100644
index 00000000000..4514d2f7765
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/stdout.term.svg b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/stdout.term.svg
new file mode 100644
index 00000000000..711160ec528
--- /dev/null
+++ b/tests/testsuite/cargo_info/specify_version_within_ws_and_match_with_lockfile/stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct1-stderr.term.svg b/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct1-stderr.term.svg
new file mode 100644
index 00000000000..5e89a97034e
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct1-stderr.term.svg
@@ -0,0 +1,29 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct1-stdout.term.svg b/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct1-stdout.term.svg
new file mode 100644
index 00000000000..f6033862451
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct1-stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct2-stdout.term.svg b/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct2-stdout.term.svg
new file mode 100644
index 00000000000..dac150a5ac5
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/direct2-stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/Cargo.lock b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/Cargo.lock
new file mode 100644
index 00000000000..b0b918f897f
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/Cargo.lock
@@ -0,0 +1,85 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "dep1"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "my-package 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "dep2"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "my-package 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "dep3"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "my-package 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "direct1"
+version = "0.0.0"
+dependencies = [
+ "my-package 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "direct2"
+version = "0.0.0"
+dependencies = [
+ "my-package 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "my-package"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "my-package"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "my-package"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "transitive1"
+version = "0.0.0"
+dependencies = [
+ "dep1 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "transitive123"
+version = "0.0.0"
+dependencies = [
+ "dep1 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dep2 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dep3 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "transitive2"
+version = "0.0.0"
+dependencies = [
+ "dep2 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[metadata]
+"checksum dep1 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5d1a0cb2ca0bb8c8ed7623c0309c3b25092b11cb2d578e35ec8e5d280faa5c"
+"checksum dep2 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed104779d80bde57bdbefd4bcd27e6948caab7f0b8ded30a5cb125a8cba814c8"
+"checksum dep3 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15fd0baaa7ffd9dd001841b029542f4744180449bc01fff2c40a6d2fd974457e"
+"checksum my-package 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3325a560d0542c9d7bc4a0737e74ea3734fd756a707fd50bea8bc0e5ad1ae74f"
+"checksum my-package 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "597285c86228731859f5b5f08b11731cc5cb150d0a5373572522ff726cb97411"
+"checksum my-package 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee062f199bc0f6afc7e97e1518710462b921272773202d8636a59a12a791a"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/Cargo.toml
new file mode 100644
index 00000000000..c66a4d73cae
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/Cargo.toml
@@ -0,0 +1,2 @@
+[workspace]
+members = ["crates/*"]
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct1/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct1/Cargo.toml
new file mode 100644
index 00000000000..3890a357430
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct1/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "direct1"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+my-package = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct1/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct2/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct2/Cargo.toml
new file mode 100644
index 00000000000..a2c34bd6786
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct2/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "direct2"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+my-package = "2"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct2/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/direct2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive1/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive1/Cargo.toml
new file mode 100644
index 00000000000..c22a9f9c0e8
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive1/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "transitive1"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+dep1 = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive1/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive123/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive123/Cargo.toml
new file mode 100644
index 00000000000..f08bf5faabb
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive123/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "transitive123"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+[dependencies]
+dep1 = "1"
+dep2 = "1"
+dep3 = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive123/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive123/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive2/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive2/Cargo.toml
new file mode 100644
index 00000000000..0e25fd0008d
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive2/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "transitive2"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+dep2 = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive2/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/crates/transitive2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/in/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/mod.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/mod.rs
new file mode 100644
index 00000000000..9e553b36c6c
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/mod.rs
@@ -0,0 +1,78 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ // 99.0.0 is unused
+ for ver in ["1.0.0", "2.0.0", "3.0.0", "99.0.0"] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+ // Dep1 depends on 3.0.0, Dep2 depends on 2.0.0, Dep3 depends on 1.0.0
+ cargo_test_support::registry::Package::new("dep1", "1.0.0")
+ .dep("my-package", "1.0.0")
+ .publish();
+ cargo_test_support::registry::Package::new("dep2", "1.0.0")
+ .dep("my-package", "2.0.0")
+ .publish();
+ cargo_test_support::registry::Package::new("dep3", "1.0.0")
+ .dep("my-package", "3.0.0")
+ .publish();
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let transitive1_root = project_root.join("crates/transitive1");
+ let transitive2_root = project_root.join("crates/transitive2");
+ let direct1_root = project_root.join("crates/direct1");
+ let direct2_root = project_root.join("crates/direct2");
+ let ws_directory = &project_root;
+ let transitive1_directory = &transitive1_root;
+ let transitive2_directory = &transitive2_root;
+ let direct1_directory = &direct1_root;
+ let direct2_directory = &direct2_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(ws_directory)
+ .assert()
+ .stdout_eq(file!["ws-stdout.term.svg"])
+ .stderr_eq(file!["ws-stderr.term.svg"]);
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(transitive1_directory)
+ .assert()
+ .stdout_eq(file!["transitive1-stdout.term.svg"])
+ .stderr_eq("");
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(transitive2_directory)
+ .assert()
+ .stdout_eq(file!["transitive2-stdout.term.svg"])
+ .stderr_eq("");
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(direct1_directory)
+ .assert()
+ .stdout_eq(file!["direct1-stdout.term.svg"])
+ .stderr_eq(file!["direct1-stderr.term.svg"]);
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(direct2_directory)
+ .assert()
+ .stdout_eq(file!["direct2-stdout.term.svg"])
+ .stderr_eq("");
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/Cargo.lock
new file mode 100644
index 00000000000..b0b918f897f
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/Cargo.lock
@@ -0,0 +1,85 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+[[package]]
+name = "dep1"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "my-package 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "dep2"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "my-package 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "dep3"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "my-package 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "direct1"
+version = "0.0.0"
+dependencies = [
+ "my-package 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "direct2"
+version = "0.0.0"
+dependencies = [
+ "my-package 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "my-package"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "my-package"
+version = "2.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "my-package"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "transitive1"
+version = "0.0.0"
+dependencies = [
+ "dep1 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "transitive123"
+version = "0.0.0"
+dependencies = [
+ "dep1 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dep2 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dep3 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "transitive2"
+version = "0.0.0"
+dependencies = [
+ "dep2 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[metadata]
+"checksum dep1 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5d1a0cb2ca0bb8c8ed7623c0309c3b25092b11cb2d578e35ec8e5d280faa5c"
+"checksum dep2 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed104779d80bde57bdbefd4bcd27e6948caab7f0b8ded30a5cb125a8cba814c8"
+"checksum dep3 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15fd0baaa7ffd9dd001841b029542f4744180449bc01fff2c40a6d2fd974457e"
+"checksum my-package 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3325a560d0542c9d7bc4a0737e74ea3734fd756a707fd50bea8bc0e5ad1ae74f"
+"checksum my-package 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "597285c86228731859f5b5f08b11731cc5cb150d0a5373572522ff726cb97411"
+"checksum my-package 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee062f199bc0f6afc7e97e1518710462b921272773202d8636a59a12a791a"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/Cargo.toml
new file mode 100644
index 00000000000..c66a4d73cae
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/Cargo.toml
@@ -0,0 +1,2 @@
+[workspace]
+members = ["crates/*"]
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct1/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct1/Cargo.toml
new file mode 100644
index 00000000000..3890a357430
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct1/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "direct1"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+my-package = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct1/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct2/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct2/Cargo.toml
new file mode 100644
index 00000000000..a2c34bd6786
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct2/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "direct2"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+my-package = "2"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct2/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/direct2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive1/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive1/Cargo.toml
new file mode 100644
index 00000000000..c22a9f9c0e8
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive1/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "transitive1"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+dep1 = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive1/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive1/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive123/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive123/Cargo.toml
new file mode 100644
index 00000000000..f08bf5faabb
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive123/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "transitive123"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+[dependencies]
+dep1 = "1"
+dep2 = "1"
+dep3 = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive123/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive123/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive2/Cargo.toml b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive2/Cargo.toml
new file mode 100644
index 00000000000..0e25fd0008d
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive2/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "transitive2"
+version = "0.0.0"
+rust-version = "1.0.0"
+
+
+[dependencies]
+dep2 = "1"
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive2/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/crates/transitive2/src/lib.rs
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/src/lib.rs b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/transitive1-stdout.term.svg b/tests/testsuite/cargo_info/transitive_dependency_within_ws/transitive1-stdout.term.svg
new file mode 100644
index 00000000000..dac150a5ac5
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/transitive1-stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/transitive2-stdout.term.svg b/tests/testsuite/cargo_info/transitive_dependency_within_ws/transitive2-stdout.term.svg
new file mode 100644
index 00000000000..dac150a5ac5
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/transitive2-stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/ws-stderr.term.svg b/tests/testsuite/cargo_info/transitive_dependency_within_ws/ws-stderr.term.svg
new file mode 100644
index 00000000000..b64062c8142
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/ws-stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/transitive_dependency_within_ws/ws-stdout.term.svg b/tests/testsuite/cargo_info/transitive_dependency_within_ws/ws-stdout.term.svg
new file mode 100644
index 00000000000..dac150a5ac5
--- /dev/null
+++ b/tests/testsuite/cargo_info/transitive_dependency_within_ws/ws-stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/cargo_info/verbose/mod.rs b/tests/testsuite/cargo_info/verbose/mod.rs
new file mode 100644
index 00000000000..2afb5c19975
--- /dev/null
+++ b/tests/testsuite/cargo_info/verbose/mod.rs
@@ -0,0 +1,53 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ cargo_test_support::registry::Package::new("my-package", "0.1.0")
+ .file(
+ "Cargo.toml",
+ r#"
+ [package]
+ name = "my-package"
+ version = "0.1.0"
+ description = "A package for testing"
+ repository = "https://github.com/hi-rustin/cargo-infromation"
+ documentation = "https://docs.rs/my-package/0.1.0"
+ license = "MIT"
+ edition = "2018"
+ rust-version = "1.50.0"
+ keywords = ["foo", "bar", "baz"]
+
+ [features]
+ default = ["feature1"]
+ feature1 = []
+ feature2 = []
+
+ [dependencies]
+ foo = "0.1.0"
+ bar = "0.2.0"
+ baz = { version = "0.3.0", optional = true }
+
+ [[bin]]
+ name = "my_bin"
+
+ [lib]
+ name = "my_lib"
+ "#,
+ )
+ .file("src/bin/my_bin.rs", "")
+ .file("src/lib.rs", "")
+ .publish();
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--verbose")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/verbose/stderr.term.svg b/tests/testsuite/cargo_info/verbose/stderr.term.svg
new file mode 100644
index 00000000000..dc88c4285a5
--- /dev/null
+++ b/tests/testsuite/cargo_info/verbose/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/verbose/stdout.term.svg b/tests/testsuite/cargo_info/verbose/stdout.term.svg
new file mode 100644
index 00000000000..9b03148d9b3
--- /dev/null
+++ b/tests/testsuite/cargo_info/verbose/stdout.term.svg
@@ -0,0 +1,59 @@
+
diff --git a/tests/testsuite/cargo_info/with_frozen_outside_ws/mod.rs b/tests/testsuite/cargo_info/with_frozen_outside_ws/mod.rs
new file mode 100644
index 00000000000..c04f6934ed3
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_outside_ws/mod.rs
@@ -0,0 +1,30 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--frozen")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/with_frozen_outside_ws/stderr.term.svg b/tests/testsuite/cargo_info/with_frozen_outside_ws/stderr.term.svg
new file mode 100644
index 00000000000..e695bb9fb59
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_outside_ws/stderr.term.svg
@@ -0,0 +1,27 @@
+
diff --git a/tests/testsuite/cargo_info/with_frozen_within_ws/in b/tests/testsuite/cargo_info/with_frozen_within_ws/in
new file mode 120000
index 00000000000..e9fe1ca7b01
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_within_ws/in
@@ -0,0 +1 @@
+../within_workspace.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_info/with_frozen_within_ws/mod.rs b/tests/testsuite/cargo_info/with_frozen_within_ws/mod.rs
new file mode 100644
index 00000000000..3881f64a880
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_within_ws/mod.rs
@@ -0,0 +1,37 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("unknown")
+ .arg("--frozen")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.toml b/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_within_ws/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/with_frozen_within_ws/out/src/lib.rs b/tests/testsuite/cargo_info/with_frozen_within_ws/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_within_ws/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/with_frozen_within_ws/stderr.term.svg b/tests/testsuite/cargo_info/with_frozen_within_ws/stderr.term.svg
new file mode 100644
index 00000000000..5d329b55ad1
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_frozen_within_ws/stderr.term.svg
@@ -0,0 +1,27 @@
+
diff --git a/tests/testsuite/cargo_info/with_locked_outside_ws/mod.rs b/tests/testsuite/cargo_info/with_locked_outside_ws/mod.rs
new file mode 100644
index 00000000000..6678ac7a380
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_outside_ws/mod.rs
@@ -0,0 +1,30 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--locked")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/with_locked_outside_ws/stderr.term.svg b/tests/testsuite/cargo_info/with_locked_outside_ws/stderr.term.svg
new file mode 100644
index 00000000000..2d9641b8ecf
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_outside_ws/stderr.term.svg
@@ -0,0 +1,27 @@
+
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws/in b/tests/testsuite/cargo_info/with_locked_within_ws/in
new file mode 120000
index 00000000000..e9fe1ca7b01
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws/in
@@ -0,0 +1 @@
+../within_workspace.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws/mod.rs b/tests/testsuite/cargo_info/with_locked_within_ws/mod.rs
new file mode 100644
index 00000000000..4f958d75eef
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws/mod.rs
@@ -0,0 +1,37 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("unknown")
+ .arg("--locked")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.toml b/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws/out/src/lib.rs b/tests/testsuite/cargo_info/with_locked_within_ws/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws/stderr.term.svg b/tests/testsuite/cargo_info/with_locked_within_ws/stderr.term.svg
new file mode 100644
index 00000000000..12b850a2837
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws/stderr.term.svg
@@ -0,0 +1,30 @@
+
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/in/Cargo.toml b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/in/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/in/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/in/src/lib.rs b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/in/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/in/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/mod.rs b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/mod.rs
new file mode 100644
index 00000000000..a04d9ec0150
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/mod.rs
@@ -0,0 +1,37 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--locked")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/out/Cargo.toml b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/out/src/lib.rs b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/stderr.term.svg b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/stderr.term.svg
new file mode 100644
index 00000000000..094f2f61c76
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/stderr.term.svg
@@ -0,0 +1,31 @@
+
diff --git a/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/stdout.term.svg b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/stdout.term.svg
new file mode 100644
index 00000000000..6024659dc97
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_locked_within_ws_and_pick_the_package/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/with_offline/mod.rs b/tests/testsuite/cargo_info/with_offline/mod.rs
new file mode 100644
index 00000000000..1b0b71610f7
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_offline/mod.rs
@@ -0,0 +1,30 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--offline")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .failure()
+ .stdout_eq("")
+ .stderr_eq(file!["stderr.term.svg"]);
+}
diff --git a/tests/testsuite/cargo_info/with_offline/stderr.term.svg b/tests/testsuite/cargo_info/with_offline/stderr.term.svg
new file mode 100644
index 00000000000..d811fbcd069
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_offline/stderr.term.svg
@@ -0,0 +1,27 @@
+
diff --git a/tests/testsuite/cargo_info/with_quiet/mod.rs b/tests/testsuite/cargo_info/with_quiet/mod.rs
new file mode 100644
index 00000000000..9c5d0cdb9a2
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_quiet/mod.rs
@@ -0,0 +1,30 @@
+use cargo_test_support::file;
+use cargo_test_support::prelude::*;
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--quiet")
+ .arg("--registry=dummy-registry")
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq("");
+}
diff --git a/tests/testsuite/cargo_info/with_quiet/stdout.term.svg b/tests/testsuite/cargo_info/with_quiet/stdout.term.svg
new file mode 100644
index 00000000000..6024659dc97
--- /dev/null
+++ b/tests/testsuite/cargo_info/with_quiet/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/within_workspace.in/Cargo.lock b/tests/testsuite/cargo_info/within_workspace.in/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_workspace.in/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/within_workspace.in/Cargo.toml b/tests/testsuite/cargo_info/within_workspace.in/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_workspace.in/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/within_workspace.in/src/lib.rs b/tests/testsuite/cargo_info/within_workspace.in/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_workspace.in/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws/in b/tests/testsuite/cargo_info/within_ws/in
new file mode 120000
index 00000000000..e9fe1ca7b01
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws/in
@@ -0,0 +1 @@
+../within_workspace.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_info/within_ws/mod.rs b/tests/testsuite/cargo_info/within_ws/mod.rs
new file mode 100644
index 00000000000..f057b582179
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws/mod.rs
@@ -0,0 +1,36 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ "20.0.0+my-package",
+ "99999.0.0+my-package",
+ "99999.0.0-alpha.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/within_ws/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws/out/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/within_ws/out/Cargo.toml b/tests/testsuite/cargo_info/within_ws/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/within_ws/out/src/lib.rs b/tests/testsuite/cargo_info/within_ws/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws/stderr.term.svg b/tests/testsuite/cargo_info/within_ws/stderr.term.svg
new file mode 100644
index 00000000000..4514d2f7765
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws/stdout.term.svg b/tests/testsuite/cargo_info/within_ws/stdout.term.svg
new file mode 100644
index 00000000000..711160ec528
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws/stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.lock b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.lock
new file mode 100644
index 00000000000..cf3fed84f81
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.2.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61758fedb08b81e9c6967f0661a54feb83fb38eb4bde3614119fbc1d03c1cedf"
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.toml b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.toml
new file mode 100644
index 00000000000..443359c3980
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.2.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/src/lib.rs b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/in/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/mod.rs b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/mod.rs
new file mode 100644
index 00000000000..cc93e23f627
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/mod.rs
@@ -0,0 +1,27 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ cargo_test_support::registry::Package::new("my-package", "0.1.1+my-package").publish();
+ cargo_test_support::registry::Package::new("cargo-list-test-fixture", "0.1.1+my-package")
+ .publish();
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("cargo-list-test-fixture")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq("");
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.lock
new file mode 100644
index 00000000000..cf3fed84f81
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.2.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "61758fedb08b81e9c6967f0661a54feb83fb38eb4bde3614119fbc1d03c1cedf"
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.toml b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.toml
new file mode 100644
index 00000000000..443359c3980
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.2.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/src/lib.rs b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/stdout.term.svg b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/stdout.term.svg
new file mode 100644
index 00000000000..c83baf47563
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_and_pick_ws_package/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/in b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/in
new file mode 120000
index 00000000000..e9fe1ca7b01
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/in
@@ -0,0 +1 @@
+../within_workspace.in
\ No newline at end of file
diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/mod.rs b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/mod.rs
new file mode 100644
index 00000000000..21579d68194
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/mod.rs
@@ -0,0 +1,30 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, registry::RegistryBuilder, Project};
+use cargo_test_support::{current_dir, file};
+
+#[cargo_test]
+fn case() {
+ let _ = RegistryBuilder::new()
+ .alternative()
+ .no_configure_token()
+ .build();
+ cargo_test_support::registry::Package::new("my-package", "99999.0.0-alpha.1+my-package")
+ .alternative(true)
+ .publish();
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=alternative")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.lock
new file mode 100644
index 00000000000..e9ede42b3cb
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.1.1+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "21c0013931e013e890da011e601d9e8514359837da12125e7e89157d9349dcb7"
diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.toml b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.toml
new file mode 100644
index 00000000000..a200a736b98
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.1"
diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/src/lib.rs b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/stderr.term.svg b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/stderr.term.svg
new file mode 100644
index 00000000000..69ddaf3115c
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/stderr.term.svg
@@ -0,0 +1,33 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_with_alternative_registry/stdout.term.svg b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/stdout.term.svg
new file mode 100644
index 00000000000..30bf52d0cc8
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_with_alternative_registry/stdout.term.svg
@@ -0,0 +1,36 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/in/Cargo.toml b/tests/testsuite/cargo_info/within_ws_without_lockfile/in/Cargo.toml
new file mode 100644
index 00000000000..75b2d3d13b8
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/in/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.2"
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/in/src/lib.rs b/tests/testsuite/cargo_info/within_ws_without_lockfile/in/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/in/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/mod.rs b/tests/testsuite/cargo_info/within_ws_without_lockfile/mod.rs
new file mode 100644
index 00000000000..6236c449540
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/mod.rs
@@ -0,0 +1,33 @@
+use cargo_test_support::prelude::*;
+use cargo_test_support::{compare::assert_ui, current_dir, file, Project};
+
+use super::init_registry_without_token;
+
+#[cargo_test]
+fn case() {
+ init_registry_without_token();
+ for ver in [
+ "0.1.1+my-package",
+ "0.2.0+my-package",
+ "0.2.3+my-package",
+ "0.4.1+my-package",
+ ] {
+ cargo_test_support::registry::Package::new("my-package", ver).publish();
+ }
+
+ let project = Project::from_template(current_dir!().join("in"));
+ let project_root = project.root();
+ let cwd = &project_root;
+
+ snapbox::cmd::Command::cargo_ui()
+ .arg("info")
+ .arg("my-package")
+ .arg("--registry=dummy-registry")
+ .current_dir(cwd)
+ .assert()
+ .success()
+ .stdout_eq(file!["stdout.term.svg"])
+ .stderr_eq(file!["stderr.term.svg"]);
+
+ assert_ui().subset_matches(current_dir!().join("out"), &project_root);
+}
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.lock b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.lock
new file mode 100644
index 00000000000..3d372c49933
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.lock
@@ -0,0 +1,16 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+dependencies = [
+ "my-package",
+]
+
+[[package]]
+name = "my-package"
+version = "0.2.3+my-package"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5da91d4048b3b4623431ca790831b8b334ef87b6c1b0338889029a9b199f08a8"
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.toml b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.toml
new file mode 100644
index 00000000000..75b2d3d13b8
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/Cargo.toml
@@ -0,0 +1,8 @@
+[workspace]
+
+[package]
+name = "cargo-list-test-fixture"
+version = "0.0.0"
+
+[dependencies]
+my-package = "0.2"
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/out/src/lib.rs b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/src/lib.rs
new file mode 100644
index 00000000000..8b137891791
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/out/src/lib.rs
@@ -0,0 +1 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg b/tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg
new file mode 100644
index 00000000000..a81aeeae5cf
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/stderr.term.svg
@@ -0,0 +1,39 @@
+
diff --git a/tests/testsuite/cargo_info/within_ws_without_lockfile/stdout.term.svg b/tests/testsuite/cargo_info/within_ws_without_lockfile/stdout.term.svg
new file mode 100644
index 00000000000..22479c200f3
--- /dev/null
+++ b/tests/testsuite/cargo_info/within_ws_without_lockfile/stdout.term.svg
@@ -0,0 +1,42 @@
+
diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs
index 271d333e2ef..d8f85d16fd4 100644
--- a/tests/testsuite/main.rs
+++ b/tests/testsuite/main.rs
@@ -34,6 +34,7 @@ mod cargo_fix;
mod cargo_generate_lockfile;
mod cargo_git_checkout;
mod cargo_help;
+mod cargo_info;
mod cargo_init;
mod cargo_install;
mod cargo_locate_project;