Skip to content

Commit

Permalink
Add tests for cargo remove
Browse files Browse the repository at this point in the history
  • Loading branch information
cassaundra committed Sep 22, 2022
1 parent 8ae2170 commit 9a92169
Show file tree
Hide file tree
Showing 146 changed files with 1,701 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/avoid_empty_tables/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/avoid_empty_tables/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
23 changes: 23 additions & 0 deletions tests/testsuite/cargo_remove/avoid_empty_tables/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_remove/avoid_empty_tables/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removing clippy from dependencies
Updating `dummy-registry` index
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/build/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/build/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
21 changes: 21 additions & 0 deletions tests/testsuite/cargo_remove/build/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_remove/build/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removing semver from build-dependencies
Updating `dummy-registry` index
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/dev/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/dev/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
23 changes: 23 additions & 0 deletions tests/testsuite/cargo_remove/dev/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_remove/dev/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removing regex from dev-dependencies
Updating `dummy-registry` index
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/dry_run/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/dry_run/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
24 changes: 24 additions & 0 deletions tests/testsuite/cargo_remove/dry_run/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/dry_run/out/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions tests/testsuite/cargo_remove/dry_run/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removing semver from dependencies
warning: aborting remove due to dry run
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/invalid_arg/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/invalid_arg/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
24 changes: 24 additions & 0 deletions tests/testsuite/cargo_remove/invalid_arg/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
8 changes: 8 additions & 0 deletions tests/testsuite/cargo_remove/invalid_arg/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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 <DEP_ID>...

For more information try --help
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/invalid_dep/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/invalid_dep/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
24 changes: 24 additions & 0 deletions tests/testsuite/cargo_remove/invalid_dep/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_remove/invalid_dep/stderr.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removing invalid_dependency_name from dependencies
error: the dependency `invalid_dependency_name` could not be found in `dependencies`.
Empty file.
1 change: 1 addition & 0 deletions tests/testsuite/cargo_remove/invalid_package/in
25 changes: 25 additions & 0 deletions tests/testsuite/cargo_remove/invalid_package/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 5 additions & 0 deletions tests/testsuite/cargo_remove/invalid_package/out/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[workspace]
members = [
"dep-a",
"dep-b"
]
Loading

0 comments on commit 9a92169

Please sign in to comment.