-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean profile, patch, and replace in cargo remove
After a successful removal of a dependency, clean up the profile, patch, and replace sections to remove all references to the dependency.
- Loading branch information
1 parent
882c5dd
commit e82c234
Showing
19 changed files
with
275 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use cargo_test_support::basic_manifest; | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::curr_dir; | ||
use cargo_test_support::git; | ||
use cargo_test_support::project; | ||
use cargo_test_support::CargoCommand; | ||
|
||
use crate::cargo_remove::init_registry; | ||
|
||
#[cargo_test] | ||
fn case() { | ||
init_registry(); | ||
|
||
let git_project1 = git::new("bar1", |project| { | ||
project | ||
.file("Cargo.toml", &basic_manifest("bar", "0.1.0")) | ||
.file("src/lib.rs", "") | ||
}) | ||
.url(); | ||
|
||
let git_project2 = git::new("bar2", |project| { | ||
project | ||
.file("Cargo.toml", &basic_manifest("bar", "0.1.0")) | ||
.file("src/lib.rs", "") | ||
}) | ||
.url(); | ||
|
||
let in_project = project() | ||
.file( | ||
"Cargo.toml", | ||
&format!( | ||
"[package]\n\ | ||
name = \"my-project\"\n\ | ||
version = \"0.1.0\"\n\ | ||
\n\ | ||
[dependencies]\n\ | ||
bar = {{ git = \"{git_project1}\" }}\n\ | ||
\n\ | ||
[patch.\"{git_project1}\"]\n\ | ||
bar = {{ git = \"{git_project2}\" }}\n", | ||
), | ||
) | ||
.file("src/lib.rs", "") | ||
.build(); | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("remove") | ||
.args(["bar"]) | ||
.current_dir(&in_project.root()) | ||
.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"), &in_project.root()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[package] | ||
name = "my-project" | ||
version = "0.1.0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Removing bar from dependencies |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[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" | ||
docopt = "0.6" | ||
|
||
[features] | ||
std = ["serde/std", "semver/std"] | ||
|
||
[profile.dev.package.docopt] | ||
opt-level = 3 | ||
|
||
[profile.dev.package.toml] | ||
opt-level = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(["toml"]) | ||
.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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[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" | ||
clippy = "0.4" | ||
|
||
[dev-dependencies] | ||
regex = "0.1.1" | ||
serde = "1.0.90" | ||
docopt = "0.6" | ||
|
||
[features] | ||
std = ["serde/std", "semver/std"] | ||
|
||
[profile.dev.package.docopt] | ||
opt-level = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Removing toml from dependencies | ||
Updating `dummy-registry` index |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[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" | ||
docopt = "0.6" | ||
|
||
[features] | ||
std = ["serde/std", "semver/std"] | ||
|
||
[replace] | ||
"toml:0.1.0" = { path = "../toml" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(["toml"]) | ||
.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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
clippy = "0.4" | ||
|
||
[dev-dependencies] | ||
regex = "0.1.1" | ||
serde = "1.0.90" | ||
docopt = "0.6" | ||
|
||
[features] | ||
std = ["serde/std", "semver/std"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Removing toml from dependencies | ||
Updating `dummy-registry` index |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters