From 69874ab0805d9ec8fdca9c087cbf51a37b4f6e0b Mon Sep 17 00:00:00 2001 From: Cassaundra Smith Date: Thu, 15 Sep 2022 15:30:39 -0700 Subject: [PATCH 1/4] Add `remove_from_table` manifest util Needed for `cargo remove`. --- src/cargo/util/toml_mut/manifest.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/cargo/util/toml_mut/manifest.rs b/src/cargo/util/toml_mut/manifest.rs index c9a5f5d2cfa5..54d5ab0bfb51 100644 --- a/src/cargo/util/toml_mut/manifest.rs +++ b/src/cargo/util/toml_mut/manifest.rs @@ -368,6 +368,26 @@ impl LocalManifest { Ok(()) } + /// Remove entry from a Cargo.toml. + pub fn remove_from_table(&mut self, table_path: &[String], name: &str) -> CargoResult<()> { + let parent_table = self.get_table_mut(table_path)?; + + let dep = parent_table + .get_mut(name) + .filter(|t| !t.is_none()) + .ok_or_else(|| non_existent_dependency_err(name, table_path.join(".")))?; + + // remove the dependency + *dep = toml_edit::Item::None; + + // remove table if empty + if parent_table.as_table_like().unwrap().is_empty() { + *parent_table = toml_edit::Item::None; + } + + Ok(()) + } + /// Remove references to `dep_key` if its no longer present. pub fn gc_dep(&mut self, dep_key: &str) { let explicit_dep_activation = self.is_explicit_dep_activation(dep_key); @@ -517,3 +537,10 @@ fn parse_manifest_err() -> anyhow::Error { fn non_existent_table_err(table: impl std::fmt::Display) -> anyhow::Error { anyhow::format_err!("the table `{table}` could not be found.") } + +fn non_existent_dependency_err( + name: impl std::fmt::Display, + table: impl std::fmt::Display, +) -> anyhow::Error { + anyhow::format_err!("the dependency `{name}` could not be found in `{table}`.") +} From 7c218b10456eb43ce091a96c0471421f29b2d1b3 Mon Sep 17 00:00:00 2001 From: Cassaundra Smith Date: Tue, 20 Sep 2022 13:39:50 -0700 Subject: [PATCH 2/4] Format manifest feature array after edit --- src/cargo/util/toml_mut/manifest.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cargo/util/toml_mut/manifest.rs b/src/cargo/util/toml_mut/manifest.rs index 54d5ab0bfb51..9d98d581b636 100644 --- a/src/cargo/util/toml_mut/manifest.rs +++ b/src/cargo/util/toml_mut/manifest.rs @@ -524,6 +524,8 @@ fn fix_feature_activations( } } } + + feature_values.fmt(); } pub fn str_or_1_len_table(item: &toml_edit::Item) -> bool { From aebfd9acb72aa20ac0728c8c3d8ef3681f438b6a Mon Sep 17 00:00:00 2001 From: Cassaundra Smith Date: Thu, 6 Oct 2022 12:38:15 -0700 Subject: [PATCH 3/4] Add `cargo remove` subcommand --- src/bin/cargo/commands/mod.rs | 3 + src/bin/cargo/commands/remove.rs | 116 +++++++++++++++++++++++++++++++ src/bin/cargo/main.rs | 3 +- src/cargo/ops/cargo_remove.rs | 65 +++++++++++++++++ src/cargo/ops/mod.rs | 1 + 5 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 src/bin/cargo/commands/remove.rs create mode 100644 src/cargo/ops/cargo_remove.rs diff --git a/src/bin/cargo/commands/mod.rs b/src/bin/cargo/commands/mod.rs index 11534d3dd900..da3109260a41 100644 --- a/src/bin/cargo/commands/mod.rs +++ b/src/bin/cargo/commands/mod.rs @@ -26,6 +26,7 @@ pub fn builtin() -> Vec { pkgid::cli(), publish::cli(), read_manifest::cli(), + remove::cli(), report::cli(), run::cli(), rustc::cli(), @@ -68,6 +69,7 @@ pub fn builtin_exec(cmd: &str) -> Option CliResu "pkgid" => pkgid::exec, "publish" => publish::exec, "read-manifest" => read_manifest::exec, + "remove" => remove::exec, "report" => report::exec, "run" => run::exec, "rustc" => rustc::exec, @@ -110,6 +112,7 @@ pub mod package; pub mod pkgid; pub mod publish; pub mod read_manifest; +pub mod remove; pub mod report; pub mod run; pub mod rustc; diff --git a/src/bin/cargo/commands/remove.rs b/src/bin/cargo/commands/remove.rs new file mode 100644 index 000000000000..56d60c8b161e --- /dev/null +++ b/src/bin/cargo/commands/remove.rs @@ -0,0 +1,116 @@ +use cargo::core::dependency::DepKind; +use cargo::ops::cargo_remove::remove; +use cargo::ops::cargo_remove::RemoveOptions; +use cargo::ops::resolve_ws; +use cargo::util::command_prelude::*; +use cargo::util::toml_mut::manifest::DepTable; + +pub fn cli() -> clap::Command { + clap::Command::new("remove") + // Subcommand aliases are handled in `aliased_command()`. + // .alias("rm") + .about("Remove dependencies from a Cargo.toml manifest file") + .args([clap::Arg::new("dependencies") + .action(clap::ArgAction::Append) + .required(true) + .num_args(1..) + .value_name("DEP_ID") + .help("Dependencies to be removed")]) + .arg_package("Package to remove from") + .arg_manifest_path() + .arg_quiet() + .arg_dry_run("Don't actually write the manifest") + .next_help_heading("SECTION") + .args([ + clap::Arg::new("dev") + .long("dev") + .conflicts_with("build") + .action(clap::ArgAction::SetTrue) + .group("section") + .help("Remove as development dependency"), + clap::Arg::new("build") + .long("build") + .conflicts_with("dev") + .action(clap::ArgAction::SetTrue) + .group("section") + .help("Remove as build dependency"), + clap::Arg::new("target") + .long("target") + .num_args(1) + .value_name("TARGET") + .value_parser(clap::builder::NonEmptyStringValueParser::new()) + .help("Remove as dependency from the given target platform"), + ]) +} + +pub fn exec(config: &mut Config, args: &ArgMatches) -> CliResult { + let dry_run = args.dry_run(); + + let workspace = args.workspace(config)?; + let packages = args.packages_from_flags()?; + let packages = packages.get_packages(&workspace)?; + let spec = match packages.len() { + 0 => { + return Err(CliError::new( + anyhow::format_err!("no packages selected. Please specify one with `-p `"), + 101, + )); + } + 1 => packages[0], + len => { + return Err(CliError::new( + anyhow::format_err!( + "{len} packages selected. Please specify one with `-p `", + ), + 101, + )); + } + }; + + let dependencies = args + .get_many::("dependencies") + .expect("required(true)") + .cloned() + .collect(); + + let section = parse_section(args); + + let options = RemoveOptions { + config, + spec, + dependencies, + section, + dry_run, + }; + remove(&options)?; + + if !dry_run { + // Reload the workspace since we've changed dependencies + let ws = args.workspace(config)?; + resolve_ws(&ws)?; + } + + Ok(()) +} + +fn parse_section(args: &ArgMatches) -> DepTable { + let dev = args.flag("dev"); + let build = args.flag("build"); + + let kind = if dev { + DepKind::Development + } else if build { + DepKind::Build + } else { + DepKind::Normal + }; + + let mut table = DepTable::new().set_kind(kind); + + if let Some(target) = args.get_one::("target") { + assert!(!target.is_empty(), "Target specification may not be empty"); + table = table.set_target(target); + } + + table +} diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index 3c0c943e9f12..70adebb9431c 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -39,12 +39,13 @@ fn main() { /// Table for defining the aliases which come builtin in `Cargo`. /// The contents are structured as: `(alias, aliased_command, description)`. -const BUILTIN_ALIASES: [(&str, &str, &str); 5] = [ +const BUILTIN_ALIASES: [(&str, &str, &str); 6] = [ ("b", "build", "alias: build"), ("c", "check", "alias: check"), ("d", "doc", "alias: doc"), ("r", "run", "alias: run"), ("t", "test", "alias: test"), + ("rm", "remove", "alias: remove"), ]; /// Function which contains the list of all of the builtin aliases and it's diff --git a/src/cargo/ops/cargo_remove.rs b/src/cargo/ops/cargo_remove.rs new file mode 100644 index 000000000000..4866caeddace --- /dev/null +++ b/src/cargo/ops/cargo_remove.rs @@ -0,0 +1,65 @@ +//! Core of cargo-remove command + +use crate::core::Package; +use crate::util::toml_mut::manifest::DepTable; +use crate::util::toml_mut::manifest::LocalManifest; +use crate::CargoResult; +use crate::Config; + +/// Remove a dependency from a Cargo.toml manifest file. +#[derive(Debug)] +pub struct RemoveOptions<'a> { + /// Configuration information for Cargo operations + pub config: &'a Config, + /// Package to remove dependencies from + pub spec: &'a Package, + /// Dependencies to remove + pub dependencies: Vec, + /// Which dependency section to remove these from + pub section: DepTable, + /// Whether or not to actually write the manifest + pub dry_run: bool, +} + +/// Remove dependencies from a manifest +pub fn remove(options: &RemoveOptions<'_>) -> CargoResult<()> { + let dep_table = options + .section + .to_table() + .into_iter() + .map(String::from) + .collect::>(); + + let manifest_path = options.spec.manifest_path().to_path_buf(); + let mut manifest = LocalManifest::try_new(&manifest_path)?; + + for dep in &options.dependencies { + let section = if dep_table.len() >= 3 { + format!("{} for target `{}`", &dep_table[2], &dep_table[1]) + } else { + dep_table[0].clone() + }; + options + .config + .shell() + .status("Removing", format!("{dep} from {section}"))?; + + manifest.remove_from_table(&dep_table, dep)?; + + // Now that we have removed the crate, if that was the last reference to that + // crate, then we need to drop any explicitly activated features on + // that crate. + manifest.gc_dep(dep); + } + + if options.dry_run { + options + .config + .shell() + .warn("aborting remove due to dry run")?; + } else { + manifest.write()?; + } + + Ok(()) +} diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index d9895ea08825..ea04aa0be329 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -45,6 +45,7 @@ mod cargo_output_metadata; mod cargo_package; mod cargo_pkgid; mod cargo_read_manifest; +pub mod cargo_remove; mod cargo_run; mod cargo_test; mod cargo_uninstall; From 805f4245356b69dde65dc25c6f17af4ff0f2d6b7 Mon Sep 17 00:00:00 2001 From: Cassaundra Smith Date: Thu, 15 Sep 2022 15:31:11 -0700 Subject: [PATCH 4/4] Add tests for `cargo remove` --- .../cargo_remove/avoid_empty_tables/in | 1 + .../cargo_remove/avoid_empty_tables/mod.rs | 25 ++++++ .../avoid_empty_tables/out/Cargo.toml | 23 ++++++ .../avoid_empty_tables/stderr.log | 2 + .../avoid_empty_tables/stdout.log | 0 tests/testsuite/cargo_remove/build/in | 1 + tests/testsuite/cargo_remove/build/mod.rs | 25 ++++++ .../cargo_remove/build/out/Cargo.toml | 21 +++++ tests/testsuite/cargo_remove/build/stderr.log | 2 + tests/testsuite/cargo_remove/build/stdout.log | 0 tests/testsuite/cargo_remove/dev/in | 1 + tests/testsuite/cargo_remove/dev/mod.rs | 25 ++++++ .../testsuite/cargo_remove/dev/out/Cargo.toml | 23 ++++++ tests/testsuite/cargo_remove/dev/stderr.log | 2 + tests/testsuite/cargo_remove/dev/stdout.log | 0 tests/testsuite/cargo_remove/dry_run/in | 1 + tests/testsuite/cargo_remove/dry_run/mod.rs | 25 ++++++ .../cargo_remove/dry_run/out/Cargo.toml | 24 ++++++ .../cargo_remove/dry_run/out/src/lib.rs | 1 + .../testsuite/cargo_remove/dry_run/stderr.log | 2 + .../testsuite/cargo_remove/dry_run/stdout.log | 0 tests/testsuite/cargo_remove/invalid_arg/in | 1 + .../testsuite/cargo_remove/invalid_arg/mod.rs | 25 ++++++ .../cargo_remove/invalid_arg/out/Cargo.toml | 24 ++++++ .../cargo_remove/invalid_arg/stderr.log | 7 ++ .../cargo_remove/invalid_arg/stdout.log | 0 tests/testsuite/cargo_remove/invalid_dep/in | 1 + .../testsuite/cargo_remove/invalid_dep/mod.rs | 25 ++++++ .../cargo_remove/invalid_dep/out/Cargo.toml | 24 ++++++ .../cargo_remove/invalid_dep/stderr.log | 2 + .../cargo_remove/invalid_dep/stdout.log | 0 .../testsuite/cargo_remove/invalid_package/in | 1 + .../cargo_remove/invalid_package/mod.rs | 25 ++++++ .../invalid_package/out/Cargo.toml | 5 ++ .../invalid_package/out/dep-a/Cargo.toml | 23 ++++++ .../invalid_package/out/dep-a/src/lib.rs | 1 + .../invalid_package/out/dep-b/Cargo.toml | 23 ++++++ .../invalid_package/out/dep-b/src/lib.rs | 1 + .../cargo_remove/invalid_package/stderr.log | 1 + .../cargo_remove/invalid_package/stdout.log | 0 .../cargo_remove/invalid_package_multiple/in | 1 + .../invalid_package_multiple/mod.rs | 25 ++++++ .../invalid_package_multiple/out/Cargo.toml | 5 ++ .../out/dep-a/Cargo.toml | 23 ++++++ .../out/dep-a/src/lib.rs | 1 + .../out/dep-b/Cargo.toml | 23 ++++++ .../out/dep-b/src/lib.rs | 1 + .../invalid_package_multiple/stderr.log | 1 + .../invalid_package_multiple/stdout.log | 0 .../testsuite/cargo_remove/invalid_section/in | 1 + .../cargo_remove/invalid_section/mod.rs | 25 ++++++ .../invalid_section/out/Cargo.toml | 24 ++++++ .../cargo_remove/invalid_section/stderr.log | 2 + .../cargo_remove/invalid_section/stdout.log | 0 .../cargo_remove/invalid_section_dep/in | 1 + .../cargo_remove/invalid_section_dep/mod.rs | 25 ++++++ .../invalid_section_dep/out/Cargo.toml | 24 ++++++ .../invalid_section_dep/stderr.log | 2 + .../invalid_section_dep/stdout.log | 0 .../testsuite/cargo_remove/invalid_target/in | 1 + .../cargo_remove/invalid_target/mod.rs | 25 ++++++ .../invalid_target/out/Cargo.toml | 33 ++++++++ .../cargo_remove/invalid_target/stderr.log | 2 + .../cargo_remove/invalid_target/stdout.log | 0 .../cargo_remove/invalid_target_dep/in | 1 + .../cargo_remove/invalid_target_dep/mod.rs | 25 ++++++ .../invalid_target_dep/out/Cargo.toml | 33 ++++++++ .../invalid_target_dep/stderr.log | 2 + .../invalid_target_dep/stdout.log | 0 tests/testsuite/cargo_remove/mod.rs | 82 +++++++++++++++++++ tests/testsuite/cargo_remove/multiple_deps/in | 1 + .../cargo_remove/multiple_deps/mod.rs | 25 ++++++ .../cargo_remove/multiple_deps/out/Cargo.toml | 22 +++++ .../cargo_remove/multiple_deps/stderr.log | 3 + .../cargo_remove/multiple_deps/stdout.log | 0 tests/testsuite/cargo_remove/multiple_dev/in | 1 + .../cargo_remove/multiple_dev/mod.rs | 25 ++++++ .../cargo_remove/multiple_dev/out/Cargo.toml | 20 +++++ .../cargo_remove/multiple_dev/stderr.log | 3 + .../cargo_remove/multiple_dev/stdout.log | 0 tests/testsuite/cargo_remove/no_arg/in | 1 + tests/testsuite/cargo_remove/no_arg/mod.rs | 24 ++++++ .../cargo_remove/no_arg/out/Cargo.toml | 24 ++++++ .../testsuite/cargo_remove/no_arg/stderr.log | 6 ++ .../testsuite/cargo_remove/no_arg/stdout.log | 0 tests/testsuite/cargo_remove/offline/in | 1 + tests/testsuite/cargo_remove/offline/mod.rs | 35 ++++++++ .../cargo_remove/offline/out/Cargo.toml | 23 ++++++ .../testsuite/cargo_remove/offline/stderr.log | 1 + .../testsuite/cargo_remove/offline/stdout.log | 0 .../cargo_remove/optional_dep_feature/in | 1 + .../cargo_remove/optional_dep_feature/mod.rs | 25 ++++++ .../optional_dep_feature/out/Cargo.toml | 23 ++++++ .../optional_dep_feature/stderr.log | 2 + .../optional_dep_feature/stdout.log | 0 .../cargo_remove/optional_feature/in | 1 + .../cargo_remove/optional_feature/mod.rs | 25 ++++++ .../optional_feature/out/Cargo.toml | 23 ++++++ .../cargo_remove/optional_feature/stderr.log | 2 + .../cargo_remove/optional_feature/stdout.log | 0 tests/testsuite/cargo_remove/package/in | 1 + tests/testsuite/cargo_remove/package/mod.rs | 25 ++++++ .../cargo_remove/package/out/Cargo.toml | 5 ++ .../cargo_remove/package/out/dep-a/Cargo.toml | 22 +++++ .../cargo_remove/package/out/dep-a/src/lib.rs | 1 + .../cargo_remove/package/out/dep-b/Cargo.toml | 23 ++++++ .../cargo_remove/package/out/dep-b/src/lib.rs | 1 + .../testsuite/cargo_remove/package/stderr.log | 2 + .../testsuite/cargo_remove/package/stdout.log | 0 .../cargo_remove/remove-basic.in/Cargo.toml | 24 ++++++ .../cargo_remove/remove-basic.in/src/lib.rs | 1 + .../cargo_remove/remove-package.in/Cargo.toml | 5 ++ .../remove-package.in/dep-a/Cargo.toml | 23 ++++++ .../remove-package.in/dep-a/src/lib.rs | 1 + .../remove-package.in/dep-b/Cargo.toml | 23 ++++++ .../remove-package.in/dep-b/src/lib.rs | 1 + .../cargo_remove/remove-target.in/Cargo.toml | 33 ++++++++ tests/testsuite/cargo_remove/remove_basic/in | 1 + .../cargo_remove/remove_basic/mod.rs | 25 ++++++ .../cargo_remove/remove_basic/out/Cargo.toml | 23 ++++++ .../cargo_remove/remove_basic/stderr.log | 2 + .../cargo_remove/remove_basic/stdout.log | 0 tests/testsuite/cargo_remove/target/in | 1 + tests/testsuite/cargo_remove/target/mod.rs | 25 ++++++ .../cargo_remove/target/out/Cargo.toml | 30 +++++++ .../testsuite/cargo_remove/target/stderr.log | 2 + .../testsuite/cargo_remove/target/stdout.log | 0 tests/testsuite/cargo_remove/target_build/in | 1 + .../cargo_remove/target_build/mod.rs | 25 ++++++ .../cargo_remove/target_build/out/Cargo.toml | 30 +++++++ .../cargo_remove/target_build/stderr.log | 2 + .../cargo_remove/target_build/stdout.log | 0 tests/testsuite/cargo_remove/target_dev/in | 1 + .../testsuite/cargo_remove/target_dev/mod.rs | 25 ++++++ .../cargo_remove/target_dev/out/Cargo.toml | 30 +++++++ .../cargo_remove/target_dev/stderr.log | 2 + .../cargo_remove/target_dev/stdout.log | 0 .../update_lock_file/in/Cargo.lock | 58 +++++++++++++ .../update_lock_file/in/Cargo.toml | 24 ++++++ .../update_lock_file/in/src/main.rs | 1 + .../cargo_remove/update_lock_file/mod.rs | 25 ++++++ .../update_lock_file/out/Cargo.lock | 51 ++++++++++++ .../update_lock_file/out/Cargo.toml | 23 ++++++ .../update_lock_file/out/src/main.rs | 1 + .../cargo_remove/update_lock_file/stderr.log | 2 + .../cargo_remove/update_lock_file/stdout.log | 0 tests/testsuite/main.rs | 1 + 147 files changed, 1700 insertions(+) create mode 120000 tests/testsuite/cargo_remove/avoid_empty_tables/in create mode 100644 tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs create mode 100644 tests/testsuite/cargo_remove/avoid_empty_tables/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/avoid_empty_tables/stderr.log create mode 100644 tests/testsuite/cargo_remove/avoid_empty_tables/stdout.log create mode 120000 tests/testsuite/cargo_remove/build/in create mode 100644 tests/testsuite/cargo_remove/build/mod.rs create mode 100644 tests/testsuite/cargo_remove/build/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/build/stderr.log create mode 100644 tests/testsuite/cargo_remove/build/stdout.log create mode 120000 tests/testsuite/cargo_remove/dev/in create mode 100644 tests/testsuite/cargo_remove/dev/mod.rs create mode 100644 tests/testsuite/cargo_remove/dev/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/dev/stderr.log create mode 100644 tests/testsuite/cargo_remove/dev/stdout.log create mode 120000 tests/testsuite/cargo_remove/dry_run/in create mode 100644 tests/testsuite/cargo_remove/dry_run/mod.rs create mode 100644 tests/testsuite/cargo_remove/dry_run/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/dry_run/out/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/dry_run/stderr.log create mode 100644 tests/testsuite/cargo_remove/dry_run/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_arg/in create mode 100644 tests/testsuite/cargo_remove/invalid_arg/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_arg/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_arg/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_arg/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_dep/in create mode 100644 tests/testsuite/cargo_remove/invalid_dep/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_dep/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_dep/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_dep/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_package/in create mode 100644 tests/testsuite/cargo_remove/invalid_package/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_package/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_package/out/dep-a/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_package/out/dep-a/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/invalid_package/out/dep-b/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_package/out/dep-b/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/invalid_package/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_package/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_package_multiple/in create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_package_multiple/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_section/in create mode 100644 tests/testsuite/cargo_remove/invalid_section/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_section/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_section/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_section/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_section_dep/in create mode 100644 tests/testsuite/cargo_remove/invalid_section_dep/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_section_dep/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_section_dep/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_section_dep/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_target/in create mode 100644 tests/testsuite/cargo_remove/invalid_target/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_target/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_target/stdout.log create mode 120000 tests/testsuite/cargo_remove/invalid_target_dep/in create mode 100644 tests/testsuite/cargo_remove/invalid_target_dep/mod.rs create mode 100644 tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/invalid_target_dep/stderr.log create mode 100644 tests/testsuite/cargo_remove/invalid_target_dep/stdout.log create mode 100644 tests/testsuite/cargo_remove/mod.rs create mode 120000 tests/testsuite/cargo_remove/multiple_deps/in create mode 100644 tests/testsuite/cargo_remove/multiple_deps/mod.rs create mode 100644 tests/testsuite/cargo_remove/multiple_deps/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/multiple_deps/stderr.log create mode 100644 tests/testsuite/cargo_remove/multiple_deps/stdout.log create mode 120000 tests/testsuite/cargo_remove/multiple_dev/in create mode 100644 tests/testsuite/cargo_remove/multiple_dev/mod.rs create mode 100644 tests/testsuite/cargo_remove/multiple_dev/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/multiple_dev/stderr.log create mode 100644 tests/testsuite/cargo_remove/multiple_dev/stdout.log create mode 120000 tests/testsuite/cargo_remove/no_arg/in create mode 100644 tests/testsuite/cargo_remove/no_arg/mod.rs create mode 100644 tests/testsuite/cargo_remove/no_arg/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/no_arg/stderr.log create mode 100644 tests/testsuite/cargo_remove/no_arg/stdout.log create mode 120000 tests/testsuite/cargo_remove/offline/in create mode 100644 tests/testsuite/cargo_remove/offline/mod.rs create mode 100644 tests/testsuite/cargo_remove/offline/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/offline/stderr.log create mode 100644 tests/testsuite/cargo_remove/offline/stdout.log create mode 120000 tests/testsuite/cargo_remove/optional_dep_feature/in create mode 100644 tests/testsuite/cargo_remove/optional_dep_feature/mod.rs create mode 100644 tests/testsuite/cargo_remove/optional_dep_feature/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/optional_dep_feature/stderr.log create mode 100644 tests/testsuite/cargo_remove/optional_dep_feature/stdout.log create mode 120000 tests/testsuite/cargo_remove/optional_feature/in create mode 100644 tests/testsuite/cargo_remove/optional_feature/mod.rs create mode 100644 tests/testsuite/cargo_remove/optional_feature/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/optional_feature/stderr.log create mode 100644 tests/testsuite/cargo_remove/optional_feature/stdout.log create mode 120000 tests/testsuite/cargo_remove/package/in create mode 100644 tests/testsuite/cargo_remove/package/mod.rs create mode 100644 tests/testsuite/cargo_remove/package/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/package/out/dep-a/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/package/out/dep-a/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/package/out/dep-b/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/package/out/dep-b/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/package/stderr.log create mode 100644 tests/testsuite/cargo_remove/package/stdout.log create mode 100644 tests/testsuite/cargo_remove/remove-basic.in/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/remove-basic.in/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/remove-package.in/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/remove-package.in/dep-a/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/remove-package.in/dep-a/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/remove-package.in/dep-b/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/remove-package.in/dep-b/src/lib.rs create mode 100644 tests/testsuite/cargo_remove/remove-target.in/Cargo.toml create mode 120000 tests/testsuite/cargo_remove/remove_basic/in create mode 100644 tests/testsuite/cargo_remove/remove_basic/mod.rs create mode 100644 tests/testsuite/cargo_remove/remove_basic/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/remove_basic/stderr.log create mode 100644 tests/testsuite/cargo_remove/remove_basic/stdout.log create mode 120000 tests/testsuite/cargo_remove/target/in create mode 100644 tests/testsuite/cargo_remove/target/mod.rs create mode 100644 tests/testsuite/cargo_remove/target/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/target/stderr.log create mode 100644 tests/testsuite/cargo_remove/target/stdout.log create mode 120000 tests/testsuite/cargo_remove/target_build/in create mode 100644 tests/testsuite/cargo_remove/target_build/mod.rs create mode 100644 tests/testsuite/cargo_remove/target_build/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/target_build/stderr.log create mode 100644 tests/testsuite/cargo_remove/target_build/stdout.log create mode 120000 tests/testsuite/cargo_remove/target_dev/in create mode 100644 tests/testsuite/cargo_remove/target_dev/mod.rs create mode 100644 tests/testsuite/cargo_remove/target_dev/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/target_dev/stderr.log create mode 100644 tests/testsuite/cargo_remove/target_dev/stdout.log create mode 100644 tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock create mode 100644 tests/testsuite/cargo_remove/update_lock_file/in/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/update_lock_file/in/src/main.rs create mode 100644 tests/testsuite/cargo_remove/update_lock_file/mod.rs create mode 100644 tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock create mode 100644 tests/testsuite/cargo_remove/update_lock_file/out/Cargo.toml create mode 100644 tests/testsuite/cargo_remove/update_lock_file/out/src/main.rs create mode 100644 tests/testsuite/cargo_remove/update_lock_file/stderr.log create mode 100644 tests/testsuite/cargo_remove/update_lock_file/stdout.log diff --git a/tests/testsuite/cargo_remove/avoid_empty_tables/in b/tests/testsuite/cargo_remove/avoid_empty_tables/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/avoid_empty_tables/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs b/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs new file mode 100644 index 000000000000..59a2333d6f7a --- /dev/null +++ b/tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["clippy"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/avoid_empty_tables/out/Cargo.toml b/tests/testsuite/cargo_remove/avoid_empty_tables/out/Cargo.toml new file mode 100644 index 000000000000..09a9ee86e81f --- /dev/null +++ b/tests/testsuite/cargo_remove/avoid_empty_tables/out/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/avoid_empty_tables/stderr.log b/tests/testsuite/cargo_remove/avoid_empty_tables/stderr.log new file mode 100644 index 000000000000..dd71023a864c --- /dev/null +++ b/tests/testsuite/cargo_remove/avoid_empty_tables/stderr.log @@ -0,0 +1,2 @@ + Removing clippy from dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/avoid_empty_tables/stdout.log b/tests/testsuite/cargo_remove/avoid_empty_tables/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/build/in b/tests/testsuite/cargo_remove/build/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/build/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/build/mod.rs b/tests/testsuite/cargo_remove/build/mod.rs new file mode 100644 index 000000000000..f4c9dcb94dee --- /dev/null +++ b/tests/testsuite/cargo_remove/build/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--build", "semver"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/build/out/Cargo.toml b/tests/testsuite/cargo_remove/build/out/Cargo.toml new file mode 100644 index 000000000000..babdc0a99901 --- /dev/null +++ b/tests/testsuite/cargo_remove/build/out/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/build/stderr.log b/tests/testsuite/cargo_remove/build/stderr.log new file mode 100644 index 000000000000..f037ebe28cec --- /dev/null +++ b/tests/testsuite/cargo_remove/build/stderr.log @@ -0,0 +1,2 @@ + Removing semver from build-dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/build/stdout.log b/tests/testsuite/cargo_remove/build/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/dev/in b/tests/testsuite/cargo_remove/dev/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/dev/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/dev/mod.rs b/tests/testsuite/cargo_remove/dev/mod.rs new file mode 100644 index 000000000000..7d61fa954055 --- /dev/null +++ b/tests/testsuite/cargo_remove/dev/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--dev", "regex"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/dev/out/Cargo.toml b/tests/testsuite/cargo_remove/dev/out/Cargo.toml new file mode 100644 index 000000000000..40744a56671d --- /dev/null +++ b/tests/testsuite/cargo_remove/dev/out/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/dev/stderr.log b/tests/testsuite/cargo_remove/dev/stderr.log new file mode 100644 index 000000000000..c629b26b19db --- /dev/null +++ b/tests/testsuite/cargo_remove/dev/stderr.log @@ -0,0 +1,2 @@ + Removing regex from dev-dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/dev/stdout.log b/tests/testsuite/cargo_remove/dev/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/dry_run/in b/tests/testsuite/cargo_remove/dry_run/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/dry_run/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/dry_run/mod.rs b/tests/testsuite/cargo_remove/dry_run/mod.rs new file mode 100644 index 000000000000..dca189315502 --- /dev/null +++ b/tests/testsuite/cargo_remove/dry_run/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["semver", "--dry-run"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/dry_run/out/Cargo.toml b/tests/testsuite/cargo_remove/dry_run/out/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/dry_run/out/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/dry_run/out/src/lib.rs b/tests/testsuite/cargo_remove/dry_run/out/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/dry_run/out/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/dry_run/stderr.log b/tests/testsuite/cargo_remove/dry_run/stderr.log new file mode 100644 index 000000000000..8b118911c61c --- /dev/null +++ b/tests/testsuite/cargo_remove/dry_run/stderr.log @@ -0,0 +1,2 @@ + Removing semver from dependencies +warning: aborting remove due to dry run diff --git a/tests/testsuite/cargo_remove/dry_run/stdout.log b/tests/testsuite/cargo_remove/dry_run/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_arg/in b/tests/testsuite/cargo_remove/invalid_arg/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_arg/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_arg/mod.rs b/tests/testsuite/cargo_remove/invalid_arg/mod.rs new file mode 100644 index 000000000000..eac3c8b46437 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_arg/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["foo", "--flag"]) + .current_dir(cwd) + .assert() + .code(1) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_arg/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_arg/out/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_arg/out/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_arg/stderr.log b/tests/testsuite/cargo_remove/invalid_arg/stderr.log new file mode 100644 index 000000000000..683247216faf --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_arg/stderr.log @@ -0,0 +1,7 @@ +error: Found argument '--flag' which wasn't expected, or isn't valid in this context + + If you tried to supply '--flag' as a value rather than a flag, use '-- --flag' + +Usage: cargo[EXE] remove ... + +For more information try '--help' diff --git a/tests/testsuite/cargo_remove/invalid_arg/stdout.log b/tests/testsuite/cargo_remove/invalid_arg/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_dep/in b/tests/testsuite/cargo_remove/invalid_dep/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_dep/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_dep/mod.rs b/tests/testsuite/cargo_remove/invalid_dep/mod.rs new file mode 100644 index 000000000000..c4dbeae910a9 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_dep/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["invalid_dependency_name"]) + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_dep/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_dep/out/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_dep/out/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_dep/stderr.log b/tests/testsuite/cargo_remove/invalid_dep/stderr.log new file mode 100644 index 000000000000..eea124d65801 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_dep/stderr.log @@ -0,0 +1,2 @@ + Removing invalid_dependency_name from dependencies +error: the dependency `invalid_dependency_name` could not be found in `dependencies`. diff --git a/tests/testsuite/cargo_remove/invalid_dep/stdout.log b/tests/testsuite/cargo_remove/invalid_dep/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_package/in b/tests/testsuite/cargo_remove/invalid_package/in new file mode 120000 index 000000000000..e2165e8cb726 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/in @@ -0,0 +1 @@ +../remove-package.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_package/mod.rs b/tests/testsuite/cargo_remove/invalid_package/mod.rs new file mode 100644 index 000000000000..bff09882ed96 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["docopt", "--package", "dep-c"]) + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_package/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_package/out/Cargo.toml new file mode 100644 index 000000000000..733857113321 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/out/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "dep-a", + "dep-b" +] diff --git a/tests/testsuite/cargo_remove/invalid_package/out/dep-a/Cargo.toml b/tests/testsuite/cargo_remove/invalid_package/out/dep-a/Cargo.toml new file mode 100644 index 000000000000..7e87ce314da1 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/out/dep-a/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "dep-a" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_package/out/dep-a/src/lib.rs b/tests/testsuite/cargo_remove/invalid_package/out/dep-a/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/out/dep-a/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/invalid_package/out/dep-b/Cargo.toml b/tests/testsuite/cargo_remove/invalid_package/out/dep-b/Cargo.toml new file mode 100644 index 000000000000..37d2d3ddf0ba --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/out/dep-b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "dep-b" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_package/out/dep-b/src/lib.rs b/tests/testsuite/cargo_remove/invalid_package/out/dep-b/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/out/dep-b/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/invalid_package/stderr.log b/tests/testsuite/cargo_remove/invalid_package/stderr.log new file mode 100644 index 000000000000..683512ca007f --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package/stderr.log @@ -0,0 +1 @@ +error: package(s) `dep-c` not found in workspace `[ROOT]/case` diff --git a/tests/testsuite/cargo_remove/invalid_package/stdout.log b/tests/testsuite/cargo_remove/invalid_package/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/in b/tests/testsuite/cargo_remove/invalid_package_multiple/in new file mode 120000 index 000000000000..e2165e8cb726 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/in @@ -0,0 +1 @@ +../remove-package.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs b/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs new file mode 100644 index 000000000000..5093d5d2dc71 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["docopt"]) + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_package_multiple/out/Cargo.toml new file mode 100644 index 000000000000..733857113321 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/out/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "dep-a", + "dep-b" +] diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/Cargo.toml b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/Cargo.toml new file mode 100644 index 000000000000..7e87ce314da1 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "dep-a" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/src/lib.rs b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-a/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/Cargo.toml b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/Cargo.toml new file mode 100644 index 000000000000..37d2d3ddf0ba --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "dep-b" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/src/lib.rs b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/out/dep-b/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/stderr.log b/tests/testsuite/cargo_remove/invalid_package_multiple/stderr.log new file mode 100644 index 000000000000..b18ca3b8b0eb --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_package_multiple/stderr.log @@ -0,0 +1 @@ +error: 2 packages selected. Please specify one with `-p ` diff --git a/tests/testsuite/cargo_remove/invalid_package_multiple/stdout.log b/tests/testsuite/cargo_remove/invalid_package_multiple/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_section/in b/tests/testsuite/cargo_remove/invalid_section/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_section/mod.rs b/tests/testsuite/cargo_remove/invalid_section/mod.rs new file mode 100644 index 000000000000..80d42be1d6a1 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--build", "docopt"]) + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_section/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_section/out/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section/out/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_section/stderr.log b/tests/testsuite/cargo_remove/invalid_section/stderr.log new file mode 100644 index 000000000000..fff5ff00ae72 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section/stderr.log @@ -0,0 +1,2 @@ + Removing docopt from build-dependencies +error: the dependency `docopt` could not be found in `build-dependencies`. diff --git a/tests/testsuite/cargo_remove/invalid_section/stdout.log b/tests/testsuite/cargo_remove/invalid_section/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_section_dep/in b/tests/testsuite/cargo_remove/invalid_section_dep/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section_dep/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs b/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs new file mode 100644 index 000000000000..7be8fd6284a4 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section_dep/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--dev", "semver", "regex"]) + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_section_dep/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_section_dep/out/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section_dep/out/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_section_dep/stderr.log b/tests/testsuite/cargo_remove/invalid_section_dep/stderr.log new file mode 100644 index 000000000000..1926f9577e4a --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_section_dep/stderr.log @@ -0,0 +1,2 @@ + Removing semver from dev-dependencies +error: the dependency `semver` could not be found in `dev-dependencies`. diff --git a/tests/testsuite/cargo_remove/invalid_section_dep/stdout.log b/tests/testsuite/cargo_remove/invalid_section_dep/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_target/in b/tests/testsuite/cargo_remove/invalid_target/in new file mode 120000 index 000000000000..d5742d038875 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target/in @@ -0,0 +1 @@ +../remove-target.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_target/mod.rs b/tests/testsuite/cargo_remove/invalid_target/mod.rs new file mode 100644 index 000000000000..34deb6cb848f --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--target", "powerpc-unknown-linux-gnu", "dbus"]) + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml new file mode 100644 index 000000000000..14747c70b507 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target/out/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "cargo-remove-target-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[target.x86_64-unknown-freebsd.build-dependencies] +semver = "0.1.0" + +[target.x86_64-unknown-linux-gnu.build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[target.x86_64-unknown-linux-gnu.dependencies] +dbus = "0.6.2" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[target.x86_64-unknown-linux-gnu.dev-dependencies] +ncurses = "20.0" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_target/stderr.log b/tests/testsuite/cargo_remove/invalid_target/stderr.log new file mode 100644 index 000000000000..5075b80b70cc --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target/stderr.log @@ -0,0 +1,2 @@ + Removing dbus from dependencies for target `powerpc-unknown-linux-gnu` +error: the dependency `dbus` could not be found in `target.powerpc-unknown-linux-gnu.dependencies`. diff --git a/tests/testsuite/cargo_remove/invalid_target/stdout.log b/tests/testsuite/cargo_remove/invalid_target/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/in b/tests/testsuite/cargo_remove/invalid_target_dep/in new file mode 120000 index 000000000000..d5742d038875 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target_dep/in @@ -0,0 +1 @@ +../remove-target.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs b/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs new file mode 100644 index 000000000000..e04418fa859d --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target_dep/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--target", "x86_64-unknown-linux-gnu", "toml"]) + .current_dir(cwd) + .assert() + .code(101) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml b/tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml new file mode 100644 index 000000000000..14747c70b507 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target_dep/out/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "cargo-remove-target-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[target.x86_64-unknown-freebsd.build-dependencies] +semver = "0.1.0" + +[target.x86_64-unknown-linux-gnu.build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[target.x86_64-unknown-linux-gnu.dependencies] +dbus = "0.6.2" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[target.x86_64-unknown-linux-gnu.dev-dependencies] +ncurses = "20.0" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/stderr.log b/tests/testsuite/cargo_remove/invalid_target_dep/stderr.log new file mode 100644 index 000000000000..54bfe085f154 --- /dev/null +++ b/tests/testsuite/cargo_remove/invalid_target_dep/stderr.log @@ -0,0 +1,2 @@ + Removing toml from dependencies for target `x86_64-unknown-linux-gnu` +error: the dependency `toml` could not be found in `target.x86_64-unknown-linux-gnu.dependencies`. diff --git a/tests/testsuite/cargo_remove/invalid_target_dep/stdout.log b/tests/testsuite/cargo_remove/invalid_target_dep/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/mod.rs b/tests/testsuite/cargo_remove/mod.rs new file mode 100644 index 000000000000..75178531ee33 --- /dev/null +++ b/tests/testsuite/cargo_remove/mod.rs @@ -0,0 +1,82 @@ +mod avoid_empty_tables; +mod build; +mod dev; +mod dry_run; +mod invalid_arg; +mod invalid_dep; +mod invalid_package; +mod invalid_package_multiple; +mod invalid_section; +mod invalid_section_dep; +mod invalid_target; +mod invalid_target_dep; +mod multiple_deps; +mod multiple_dev; +mod no_arg; +mod offline; +mod optional_dep_feature; +mod optional_feature; +mod package; +mod remove_basic; +mod target; +mod target_build; +mod target_dev; +mod update_lock_file; + +fn init_registry() { + cargo_test_support::registry::init(); + add_registry_packages(false); +} + +fn add_registry_packages(alt: bool) { + for name in [ + "clippy", + "dbus", + "docopt", + "ncurses", + "pad", + "regex", + "rustc-serialize", + "toml", + ] { + cargo_test_support::registry::Package::new(name, "0.1.1+my-package") + .alternative(alt) + .publish(); + cargo_test_support::registry::Package::new(name, "0.2.0+my-package") + .alternative(alt) + .publish(); + cargo_test_support::registry::Package::new(name, "0.2.3+my-package") + .alternative(alt) + .publish(); + cargo_test_support::registry::Package::new(name, "0.4.1+my-package") + .alternative(alt) + .publish(); + cargo_test_support::registry::Package::new(name, "0.6.2+my-package") + .alternative(alt) + .publish(); + cargo_test_support::registry::Package::new(name, "0.9.9+my-package") + .alternative(alt) + .publish(); + cargo_test_support::registry::Package::new(name, "1.0.90+my-package") + .alternative(alt) + .publish(); + cargo_test_support::registry::Package::new(name, "20.0.0+my-package") + .alternative(alt) + .publish(); + } + + for name in ["semver", "serde"] { + cargo_test_support::registry::Package::new(name, "0.1.1") + .alternative(alt) + .feature("std", &[]) + .publish(); + cargo_test_support::registry::Package::new(name, "0.9.0") + .alternative(alt) + .feature("std", &[]) + .publish(); + cargo_test_support::registry::Package::new(name, "1.0.90") + .alternative(alt) + .feature("std", &[]) + .publish(); + } +} diff --git a/tests/testsuite/cargo_remove/multiple_deps/in b/tests/testsuite/cargo_remove/multiple_deps/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_deps/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/multiple_deps/mod.rs b/tests/testsuite/cargo_remove/multiple_deps/mod.rs new file mode 100644 index 000000000000..35922b73894f --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_deps/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["docopt", "semver"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/multiple_deps/out/Cargo.toml b/tests/testsuite/cargo_remove/multiple_deps/out/Cargo.toml new file mode 100644 index 000000000000..53cde0829363 --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_deps/out/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +rustc-serialize = "0.4" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/multiple_deps/stderr.log b/tests/testsuite/cargo_remove/multiple_deps/stderr.log new file mode 100644 index 000000000000..1eb59aca1b70 --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_deps/stderr.log @@ -0,0 +1,3 @@ + Removing docopt from dependencies + Removing semver from dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/multiple_deps/stdout.log b/tests/testsuite/cargo_remove/multiple_deps/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/multiple_dev/in b/tests/testsuite/cargo_remove/multiple_dev/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_dev/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/multiple_dev/mod.rs b/tests/testsuite/cargo_remove/multiple_dev/mod.rs new file mode 100644 index 000000000000..5eac7e2f8f5c --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_dev/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--dev", "regex", "serde"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/multiple_dev/out/Cargo.toml b/tests/testsuite/cargo_remove/multiple_dev/out/Cargo.toml new file mode 100644 index 000000000000..d961b2bb1358 --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_dev/out/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[features] +std = ["semver/std"] diff --git a/tests/testsuite/cargo_remove/multiple_dev/stderr.log b/tests/testsuite/cargo_remove/multiple_dev/stderr.log new file mode 100644 index 000000000000..a3042dcc3cd4 --- /dev/null +++ b/tests/testsuite/cargo_remove/multiple_dev/stderr.log @@ -0,0 +1,3 @@ + Removing regex from dev-dependencies + Removing serde from dev-dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/multiple_dev/stdout.log b/tests/testsuite/cargo_remove/multiple_dev/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/no_arg/in b/tests/testsuite/cargo_remove/no_arg/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/no_arg/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/no_arg/mod.rs b/tests/testsuite/cargo_remove/no_arg/mod.rs new file mode 100644 index 000000000000..d0c66f9b05a5 --- /dev/null +++ b/tests/testsuite/cargo_remove/no_arg/mod.rs @@ -0,0 +1,24 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .current_dir(cwd) + .assert() + .code(1) + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/no_arg/out/Cargo.toml b/tests/testsuite/cargo_remove/no_arg/out/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/no_arg/out/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/no_arg/stderr.log b/tests/testsuite/cargo_remove/no_arg/stderr.log new file mode 100644 index 000000000000..fbb7e3ce24ef --- /dev/null +++ b/tests/testsuite/cargo_remove/no_arg/stderr.log @@ -0,0 +1,6 @@ +error: The following required arguments were not provided: + ... + +Usage: cargo[EXE] remove ... + +For more information try '--help' diff --git a/tests/testsuite/cargo_remove/no_arg/stdout.log b/tests/testsuite/cargo_remove/no_arg/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/offline/in b/tests/testsuite/cargo_remove/offline/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/offline/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/offline/mod.rs b/tests/testsuite/cargo_remove/offline/mod.rs new file mode 100644 index 000000000000..ab86ed555458 --- /dev/null +++ b/tests/testsuite/cargo_remove/offline/mod.rs @@ -0,0 +1,35 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; +use cargo_test_support::TestEnv; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + // run the metadata command to populate the cache + let cargo = std::env::var_os("CARGO").unwrap(); + snapbox::cmd::Command::new(cargo) + .test_env() + .arg("metadata") + .current_dir(cwd) + .assert() + .success(); + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["docopt", "--offline"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/offline/out/Cargo.toml b/tests/testsuite/cargo_remove/offline/out/Cargo.toml new file mode 100644 index 000000000000..b8628eed1c23 --- /dev/null +++ b/tests/testsuite/cargo_remove/offline/out/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/offline/stderr.log b/tests/testsuite/cargo_remove/offline/stderr.log new file mode 100644 index 000000000000..7083976b17de --- /dev/null +++ b/tests/testsuite/cargo_remove/offline/stderr.log @@ -0,0 +1 @@ + Removing docopt from dependencies diff --git a/tests/testsuite/cargo_remove/offline/stdout.log b/tests/testsuite/cargo_remove/offline/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/optional_dep_feature/in b/tests/testsuite/cargo_remove/optional_dep_feature/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_dep_feature/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs b/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs new file mode 100644 index 000000000000..cae736b347da --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_dep_feature/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--dev", "serde"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/optional_dep_feature/out/Cargo.toml b/tests/testsuite/cargo_remove/optional_dep_feature/out/Cargo.toml new file mode 100644 index 000000000000..63112d334242 --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_dep_feature/out/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" + +[features] +std = ["semver/std"] diff --git a/tests/testsuite/cargo_remove/optional_dep_feature/stderr.log b/tests/testsuite/cargo_remove/optional_dep_feature/stderr.log new file mode 100644 index 000000000000..72c9f92172d7 --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_dep_feature/stderr.log @@ -0,0 +1,2 @@ + Removing serde from dev-dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/optional_dep_feature/stdout.log b/tests/testsuite/cargo_remove/optional_dep_feature/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/optional_feature/in b/tests/testsuite/cargo_remove/optional_feature/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_feature/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/optional_feature/mod.rs b/tests/testsuite/cargo_remove/optional_feature/mod.rs new file mode 100644 index 000000000000..af54226bba59 --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_feature/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["semver"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/optional_feature/out/Cargo.toml b/tests/testsuite/cargo_remove/optional_feature/out/Cargo.toml new file mode 100644 index 000000000000..9ac0b1b32522 --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_feature/out/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/optional_feature/stderr.log b/tests/testsuite/cargo_remove/optional_feature/stderr.log new file mode 100644 index 000000000000..2dc546fa718b --- /dev/null +++ b/tests/testsuite/cargo_remove/optional_feature/stderr.log @@ -0,0 +1,2 @@ + Removing semver from dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/optional_feature/stdout.log b/tests/testsuite/cargo_remove/optional_feature/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/package/in b/tests/testsuite/cargo_remove/package/in new file mode 120000 index 000000000000..e2165e8cb726 --- /dev/null +++ b/tests/testsuite/cargo_remove/package/in @@ -0,0 +1 @@ +../remove-package.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/package/mod.rs b/tests/testsuite/cargo_remove/package/mod.rs new file mode 100644 index 000000000000..2714f3197258 --- /dev/null +++ b/tests/testsuite/cargo_remove/package/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["docopt", "--package", "dep-a"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/package/out/Cargo.toml b/tests/testsuite/cargo_remove/package/out/Cargo.toml new file mode 100644 index 000000000000..733857113321 --- /dev/null +++ b/tests/testsuite/cargo_remove/package/out/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "dep-a", + "dep-b" +] diff --git a/tests/testsuite/cargo_remove/package/out/dep-a/Cargo.toml b/tests/testsuite/cargo_remove/package/out/dep-a/Cargo.toml new file mode 100644 index 000000000000..5f2bfe6fb1a8 --- /dev/null +++ b/tests/testsuite/cargo_remove/package/out/dep-a/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "dep-a" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/package/out/dep-a/src/lib.rs b/tests/testsuite/cargo_remove/package/out/dep-a/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/package/out/dep-a/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/package/out/dep-b/Cargo.toml b/tests/testsuite/cargo_remove/package/out/dep-b/Cargo.toml new file mode 100644 index 000000000000..37d2d3ddf0ba --- /dev/null +++ b/tests/testsuite/cargo_remove/package/out/dep-b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "dep-b" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/package/out/dep-b/src/lib.rs b/tests/testsuite/cargo_remove/package/out/dep-b/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/package/out/dep-b/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/package/stderr.log b/tests/testsuite/cargo_remove/package/stderr.log new file mode 100644 index 000000000000..231026f2bf6e --- /dev/null +++ b/tests/testsuite/cargo_remove/package/stderr.log @@ -0,0 +1,2 @@ + Removing docopt from dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/package/stdout.log b/tests/testsuite/cargo_remove/package/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/remove-basic.in/Cargo.toml b/tests/testsuite/cargo_remove/remove-basic.in/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-basic.in/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/remove-basic.in/src/lib.rs b/tests/testsuite/cargo_remove/remove-basic.in/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-basic.in/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/remove-package.in/Cargo.toml b/tests/testsuite/cargo_remove/remove-package.in/Cargo.toml new file mode 100644 index 000000000000..733857113321 --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-package.in/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] +members = [ + "dep-a", + "dep-b" +] diff --git a/tests/testsuite/cargo_remove/remove-package.in/dep-a/Cargo.toml b/tests/testsuite/cargo_remove/remove-package.in/dep-a/Cargo.toml new file mode 100644 index 000000000000..7e87ce314da1 --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-package.in/dep-a/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "dep-a" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/remove-package.in/dep-a/src/lib.rs b/tests/testsuite/cargo_remove/remove-package.in/dep-a/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-package.in/dep-a/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/remove-package.in/dep-b/Cargo.toml b/tests/testsuite/cargo_remove/remove-package.in/dep-b/Cargo.toml new file mode 100644 index 000000000000..37d2d3ddf0ba --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-package.in/dep-b/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "dep-b" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/remove-package.in/dep-b/src/lib.rs b/tests/testsuite/cargo_remove/remove-package.in/dep-b/src/lib.rs new file mode 100644 index 000000000000..8b137891791f --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-package.in/dep-b/src/lib.rs @@ -0,0 +1 @@ + diff --git a/tests/testsuite/cargo_remove/remove-target.in/Cargo.toml b/tests/testsuite/cargo_remove/remove-target.in/Cargo.toml new file mode 100644 index 000000000000..14747c70b507 --- /dev/null +++ b/tests/testsuite/cargo_remove/remove-target.in/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "cargo-remove-target-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[target.x86_64-unknown-freebsd.build-dependencies] +semver = "0.1.0" + +[target.x86_64-unknown-linux-gnu.build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[target.x86_64-unknown-linux-gnu.dependencies] +dbus = "0.6.2" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[target.x86_64-unknown-linux-gnu.dev-dependencies] +ncurses = "20.0" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/remove_basic/in b/tests/testsuite/cargo_remove/remove_basic/in new file mode 120000 index 000000000000..7fd0ba5ebcce --- /dev/null +++ b/tests/testsuite/cargo_remove/remove_basic/in @@ -0,0 +1 @@ +../remove-basic.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/remove_basic/mod.rs b/tests/testsuite/cargo_remove/remove_basic/mod.rs new file mode 100644 index 000000000000..53381e6bc990 --- /dev/null +++ b/tests/testsuite/cargo_remove/remove_basic/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["docopt"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/remove_basic/out/Cargo.toml b/tests/testsuite/cargo_remove/remove_basic/out/Cargo.toml new file mode 100644 index 000000000000..b8628eed1c23 --- /dev/null +++ b/tests/testsuite/cargo_remove/remove_basic/out/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/remove_basic/stderr.log b/tests/testsuite/cargo_remove/remove_basic/stderr.log new file mode 100644 index 000000000000..231026f2bf6e --- /dev/null +++ b/tests/testsuite/cargo_remove/remove_basic/stderr.log @@ -0,0 +1,2 @@ + Removing docopt from dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/remove_basic/stdout.log b/tests/testsuite/cargo_remove/remove_basic/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/target/in b/tests/testsuite/cargo_remove/target/in new file mode 120000 index 000000000000..d5742d038875 --- /dev/null +++ b/tests/testsuite/cargo_remove/target/in @@ -0,0 +1 @@ +../remove-target.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/target/mod.rs b/tests/testsuite/cargo_remove/target/mod.rs new file mode 100644 index 000000000000..1447c753d3ce --- /dev/null +++ b/tests/testsuite/cargo_remove/target/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--target", "x86_64-unknown-linux-gnu", "dbus"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/target/out/Cargo.toml b/tests/testsuite/cargo_remove/target/out/Cargo.toml new file mode 100644 index 000000000000..e29fbbd0030c --- /dev/null +++ b/tests/testsuite/cargo_remove/target/out/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "cargo-remove-target-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[target.x86_64-unknown-freebsd.build-dependencies] +semver = "0.1.0" + +[target.x86_64-unknown-linux-gnu.build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[target.x86_64-unknown-linux-gnu.dev-dependencies] +ncurses = "20.0" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/target/stderr.log b/tests/testsuite/cargo_remove/target/stderr.log new file mode 100644 index 000000000000..810abd994d93 --- /dev/null +++ b/tests/testsuite/cargo_remove/target/stderr.log @@ -0,0 +1,2 @@ + Removing dbus from dependencies for target `x86_64-unknown-linux-gnu` + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/target/stdout.log b/tests/testsuite/cargo_remove/target/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/target_build/in b/tests/testsuite/cargo_remove/target_build/in new file mode 120000 index 000000000000..d5742d038875 --- /dev/null +++ b/tests/testsuite/cargo_remove/target_build/in @@ -0,0 +1 @@ +../remove-target.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/target_build/mod.rs b/tests/testsuite/cargo_remove/target_build/mod.rs new file mode 100644 index 000000000000..11afbbf8f8d0 --- /dev/null +++ b/tests/testsuite/cargo_remove/target_build/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--build", "--target", "x86_64-unknown-linux-gnu", "semver"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/target_build/out/Cargo.toml b/tests/testsuite/cargo_remove/target_build/out/Cargo.toml new file mode 100644 index 000000000000..7353c7a897b1 --- /dev/null +++ b/tests/testsuite/cargo_remove/target_build/out/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "cargo-remove-target-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[target.x86_64-unknown-freebsd.build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[target.x86_64-unknown-linux-gnu.dependencies] +dbus = "0.6.2" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[target.x86_64-unknown-linux-gnu.dev-dependencies] +ncurses = "20.0" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/target_build/stderr.log b/tests/testsuite/cargo_remove/target_build/stderr.log new file mode 100644 index 000000000000..b06f8f319c58 --- /dev/null +++ b/tests/testsuite/cargo_remove/target_build/stderr.log @@ -0,0 +1,2 @@ + Removing semver from build-dependencies for target `x86_64-unknown-linux-gnu` + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/target_build/stdout.log b/tests/testsuite/cargo_remove/target_build/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/target_dev/in b/tests/testsuite/cargo_remove/target_dev/in new file mode 120000 index 000000000000..d5742d038875 --- /dev/null +++ b/tests/testsuite/cargo_remove/target_dev/in @@ -0,0 +1 @@ +../remove-target.in/ \ No newline at end of file diff --git a/tests/testsuite/cargo_remove/target_dev/mod.rs b/tests/testsuite/cargo_remove/target_dev/mod.rs new file mode 100644 index 000000000000..d303c2b857fc --- /dev/null +++ b/tests/testsuite/cargo_remove/target_dev/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["--dev", "--target", "x86_64-unknown-linux-gnu", "ncurses"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/target_dev/out/Cargo.toml b/tests/testsuite/cargo_remove/target_dev/out/Cargo.toml new file mode 100644 index 000000000000..a477b3d55cdb --- /dev/null +++ b/tests/testsuite/cargo_remove/target_dev/out/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "cargo-remove-target-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[target.x86_64-unknown-freebsd.build-dependencies] +semver = "0.1.0" + +[target.x86_64-unknown-linux-gnu.build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[target.x86_64-unknown-linux-gnu.dependencies] +dbus = "0.6.2" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/target_dev/stderr.log b/tests/testsuite/cargo_remove/target_dev/stderr.log new file mode 100644 index 000000000000..68553a3bdce1 --- /dev/null +++ b/tests/testsuite/cargo_remove/target_dev/stderr.log @@ -0,0 +1,2 @@ + Removing ncurses from dev-dependencies for target `x86_64-unknown-linux-gnu` + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/target_dev/stdout.log b/tests/testsuite/cargo_remove/target_dev/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock b/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock new file mode 100644 index 000000000000..06c2052d5265 --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.lock @@ -0,0 +1,58 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cargo-remove-test-fixture" +version = "0.1.0" +dependencies = [ + "clippy", + "docopt", + "regex", + "rustc-serialize", + "semver", + "serde", + "toml", +] + +[[package]] +name = "clippy" +version = "0.4.1+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47ced0eda54e9ddc6063f0e1d0164493cd16c84c6b6a0329a536967c44e205f7" + +[[package]] +name = "docopt" +version = "0.6.2+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b600540c4fafb27bf6e6961f0f1e6f547c9d6126ce581ab3a92f878c8e2c9a2c" + +[[package]] +name = "regex" +version = "0.1.1+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84949cb53285a6c481d0133065a7b669871acfd9e20f273f4ce1283c309775d5" + +[[package]] +name = "rustc-serialize" +version = "0.4.1+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31162e7d23a085553c42dee375787b451a481275473f7779c4a63bcc267a24fd" + +[[package]] +name = "semver" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3031434e07edc922bf1b8262f075fac1522694f17b1ee7ad314c4cabd5d2723f" + +[[package]] +name = "serde" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75d9264696ebbf5315a6b068e9910c4df9274365afac2d88abf66525df660218" + +[[package]] +name = "toml" +version = "0.1.1+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0f6c7804525ce0a968ef270e55a516cf4bdcf1fea0b09d130e0aa34a66745b3" diff --git a/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.toml b/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.toml new file mode 100644 index 000000000000..340f06cda792 --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/in/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +rustc-serialize = "0.4" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/update_lock_file/in/src/main.rs b/tests/testsuite/cargo_remove/update_lock_file/in/src/main.rs new file mode 100644 index 000000000000..f328e4d9d04c --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/in/src/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/testsuite/cargo_remove/update_lock_file/mod.rs b/tests/testsuite/cargo_remove/update_lock_file/mod.rs new file mode 100644 index 000000000000..be5bc87f5812 --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/mod.rs @@ -0,0 +1,25 @@ +use cargo_test_support::compare::assert_ui; +use cargo_test_support::curr_dir; +use cargo_test_support::CargoCommand; +use cargo_test_support::Project; + +use crate::cargo_remove::init_registry; + +#[cargo_test] +fn case() { + init_registry(); + let project = Project::from_template(curr_dir!().join("in")); + let project_root = project.root(); + let cwd = &project_root; + + snapbox::cmd::Command::cargo_ui() + .arg("remove") + .args(["rustc-serialize"]) + .current_dir(cwd) + .assert() + .success() + .stdout_matches_path(curr_dir!().join("stdout.log")) + .stderr_matches_path(curr_dir!().join("stderr.log")); + + assert_ui().subset_matches(curr_dir!().join("out"), &project_root); +} diff --git a/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock b/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock new file mode 100644 index 000000000000..bd8c90f46876 --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.lock @@ -0,0 +1,51 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cargo-remove-test-fixture" +version = "0.1.0" +dependencies = [ + "clippy", + "docopt", + "regex", + "semver", + "serde", + "toml", +] + +[[package]] +name = "clippy" +version = "0.4.1+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47ced0eda54e9ddc6063f0e1d0164493cd16c84c6b6a0329a536967c44e205f7" + +[[package]] +name = "docopt" +version = "0.6.2+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b600540c4fafb27bf6e6961f0f1e6f547c9d6126ce581ab3a92f878c8e2c9a2c" + +[[package]] +name = "regex" +version = "0.1.1+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84949cb53285a6c481d0133065a7b669871acfd9e20f273f4ce1283c309775d5" + +[[package]] +name = "semver" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3031434e07edc922bf1b8262f075fac1522694f17b1ee7ad314c4cabd5d2723f" + +[[package]] +name = "serde" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75d9264696ebbf5315a6b068e9910c4df9274365afac2d88abf66525df660218" + +[[package]] +name = "toml" +version = "0.1.1+my-package" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0f6c7804525ce0a968ef270e55a516cf4bdcf1fea0b09d130e0aa34a66745b3" diff --git a/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.toml b/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.toml new file mode 100644 index 000000000000..5e7d7f0a06eb --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/out/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "cargo-remove-test-fixture" +version = "0.1.0" + +[[bin]] +name = "main" +path = "src/main.rs" + +[build-dependencies] +semver = "0.1.0" + +[dependencies] +docopt = "0.6" +semver = "0.1" +toml = "0.1" +clippy = "0.4" + +[dev-dependencies] +regex = "0.1.1" +serde = "1.0.90" + +[features] +std = ["serde/std", "semver/std"] diff --git a/tests/testsuite/cargo_remove/update_lock_file/out/src/main.rs b/tests/testsuite/cargo_remove/update_lock_file/out/src/main.rs new file mode 100644 index 000000000000..f328e4d9d04c --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/out/src/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/testsuite/cargo_remove/update_lock_file/stderr.log b/tests/testsuite/cargo_remove/update_lock_file/stderr.log new file mode 100644 index 000000000000..164f8f4b979e --- /dev/null +++ b/tests/testsuite/cargo_remove/update_lock_file/stderr.log @@ -0,0 +1,2 @@ + Removing rustc-serialize from dependencies + Updating `dummy-registry` index diff --git a/tests/testsuite/cargo_remove/update_lock_file/stdout.log b/tests/testsuite/cargo_remove/update_lock_file/stdout.log new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index cd817d744d3c..465494cb742d 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -25,6 +25,7 @@ mod cargo_command; mod cargo_config; mod cargo_env_config; mod cargo_features; +mod cargo_remove; mod cargo_targets; mod cfg; mod check;