-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74981 from oxalica/cargo-edit-upgrade
cargo-edit: 0.3.3 -> 0.4.1
- Loading branch information
Showing
2 changed files
with
136 additions
and
3 deletions.
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
123 changes: 123 additions & 0 deletions
123
pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch
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,123 @@ | ||
diff --git a/src/bin/add/main.rs b/src/bin/add/main.rs | ||
index 41cde585..848612b3 100644 | ||
--- a/src/bin/add/main.rs | ||
+++ b/src/bin/add/main.rs | ||
@@ -87,7 +87,7 @@ fn handle_add(args: &Args) -> Result<()> { | ||
let mut manifest = Manifest::open(manifest_path)?; | ||
let deps = &args.parse_dependencies()?; | ||
|
||
- if !args.offline { | ||
+ if !args.offline && std::env::var("CARGO_IS_TEST").is_err() { | ||
let url = registry_url( | ||
&find(&manifest_path)?, | ||
args.registry.as_ref().map(String::as_ref), | ||
diff --git a/src/bin/upgrade/main.rs b/src/bin/upgrade/main.rs | ||
index cf2414da..c066e6f4 100644 | ||
--- a/src/bin/upgrade/main.rs | ||
+++ b/src/bin/upgrade/main.rs | ||
@@ -409,7 +409,7 @@ fn process(args: Args) -> Result<()> { | ||
.. | ||
} = args; | ||
|
||
- if !args.offline && !to_lockfile { | ||
+ if !args.offline && !to_lockfile && std::env::var("CARGO_IS_TEST").is_err() { | ||
let url = registry_url(&find(&manifest_path)?, None)?; | ||
update_registry_index(&url)?; | ||
} | ||
@@ -427,7 +427,7 @@ fn process(args: Args) -> Result<()> { | ||
|
||
// Update indices for any alternative registries, unless | ||
// we're offline. | ||
- if !args.offline { | ||
+ if !args.offline && std::env::var("CARGO_IS_TEST").is_err() { | ||
for registry_url in existing_dependencies | ||
.0 | ||
.values() | ||
diff --git a/tests/cargo-add.rs b/tests/cargo-add.rs | ||
index fbdbf4e2..612ffa78 100644 | ||
--- a/tests/cargo-add.rs | ||
+++ b/tests/cargo-add.rs | ||
@@ -1184,6 +1184,7 @@ fn add_prints_message() { | ||
"--vers=0.6.0", | ||
&format!("--manifest-path={}", manifest), | ||
]) | ||
+ .with_env(&[("CARGO_IS_TEST", "1")]) | ||
.succeeds() | ||
.and() | ||
.stdout() | ||
@@ -1204,6 +1205,7 @@ fn add_prints_message_with_section() { | ||
"--vers=0.1.0", | ||
&format!("--manifest-path={}", manifest), | ||
]) | ||
+ .with_env(&[("CARGO_IS_TEST", "1")]) | ||
.succeeds() | ||
.and() | ||
.stdout() | ||
@@ -1224,6 +1226,7 @@ fn add_prints_message_for_dev_deps() { | ||
"0.8.0", | ||
&format!("--manifest-path={}", manifest), | ||
]) | ||
+ .with_env(&[("CARGO_IS_TEST", "1")]) | ||
.succeeds() | ||
.and() | ||
.stdout() | ||
@@ -1244,6 +1247,7 @@ fn add_prints_message_for_build_deps() { | ||
"0.1.0", | ||
&format!("--manifest-path={}", manifest), | ||
]) | ||
+ .with_env(&[("CARGO_IS_TEST", "1")]) | ||
.succeeds() | ||
.and() | ||
.stdout() | ||
diff --git a/tests/cargo-upgrade.rs b/tests/cargo-upgrade.rs | ||
index b11a88dc..cf117940 100644 | ||
--- a/tests/cargo-upgrade.rs | ||
+++ b/tests/cargo-upgrade.rs | ||
@@ -385,6 +385,7 @@ fn upgrade_workspace() { | ||
|
||
/// Detect if attempting to run against a workspace root and give a helpful warning. | ||
#[test] | ||
+#[cfg(feature = "test-external-apis")] | ||
fn detect_workspace() { | ||
let (_tmpdir, root_manifest, _workspace_manifests) = copy_workspace_test(); | ||
|
||
@@ -414,6 +415,7 @@ fn invalid_manifest() { | ||
"--manifest-path", | ||
&manifest, | ||
]) | ||
+ .with_env(&[("CARGO_IS_TEST", "1")]) | ||
.fails_with(1) | ||
.and() | ||
.stderr() | ||
@@ -442,6 +444,7 @@ fn invalid_root_manifest() { | ||
"--manifest-path", | ||
&manifest, | ||
]) | ||
+ .with_env(&[("CARGO_IS_TEST", "1")]) | ||
.fails_with(1) | ||
.and() | ||
.stderr() | ||
@@ -457,6 +460,7 @@ fn unknown_flags() { | ||
"foo", | ||
"--flag", | ||
]) | ||
+ .with_env(&[("CARGO_IS_TEST", "1")]) | ||
.fails_with(1) | ||
.and() | ||
.stderr() | ||
@@ -473,6 +477,7 @@ For more information try --help ", | ||
|
||
// Verify that an upgraded Cargo.toml matches what we expect. | ||
#[test] | ||
+#[cfg(feature = "test-external-apis")] | ||
fn upgrade_to_lockfile() { | ||
let (tmpdir, manifest) = clone_out_test("tests/fixtures/upgrade/Cargo.toml.lockfile_source"); | ||
fs::copy( | ||
@@ -489,6 +494,7 @@ fn upgrade_to_lockfile() { | ||
} | ||
|
||
#[test] | ||
+#[cfg(feature = "test-external-apis")] | ||
fn upgrade_workspace_to_lockfile() { | ||
let (tmpdir, root_manifest, _workspace_manifests) = copy_workspace_test(); | ||
|