about summary refs log tree commit diff
path: root/pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch')
-rw-r--r--pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch123
1 files changed, 123 insertions, 0 deletions
diff --git a/pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch b/pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch
new file mode 100644
index 000000000000..56b216e7baa7
--- /dev/null
+++ b/pkgs/tools/package-management/cargo-edit/no_upgrade_index_in_tests.patch
@@ -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();
+ 
\ No newline at end of file