public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Josh Stone <jistone@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/rustup] epel10: Fix race conditions in proxy tests
Date: Wed, 18 Nov 2026 21:43:59 GMT [thread overview]
Message-ID: <179503823956.1.14302305100544326989.rpms-rustup-936333484196@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/rustup
Branch : epel10
Commit : 936333484196d8f7f495e47dc196034aa346384d
Author : Josh Stone <jistone@redhat.com>
Date : 2025-06-05T15:28:36-07:00
Stats : +155/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/rustup/c/936333484196d8f7f495e47dc196034aa346384d?branch=epel10
Log:
Fix race conditions in proxy tests
---
diff --git a/0001-Serialize-all-tests-with-proxy-sensitive-URLs.patch b/0001-Serialize-all-tests-with-proxy-sensitive-URLs.patch
new file mode 100644
index 0000000..5bd68da
--- /dev/null
+++ b/0001-Serialize-all-tests-with-proxy-sensitive-URLs.patch
@@ -0,0 +1,152 @@
+From 87f027646f1588ea3af8b940fed43c5534a9be94 Mon Sep 17 00:00:00 2001
+From: Josh Stone <cuviper@gmail.com>
+Date: Thu, 5 Jun 2025 14:04:19 -0700
+Subject: [PATCH] Serialize all tests with proxy-sensitive URLs
+
+There was already a guard for tests that *set* a proxy variable in the
+environment, but this is also relevant for tests that would implicitly
+read those variables while downloading a local `serve_file` URL.
+---
+ src/download/tests.rs | 63 ++++++++++++++++++++++++++-----------------
+ 1 file changed, 38 insertions(+), 25 deletions(-)
+
+diff --git a/src/download/tests.rs b/src/download/tests.rs
+index 248bd92eafe4..8865b5ea4f12 100644
+--- a/src/download/tests.rs
++++ b/src/download/tests.rs
+@@ -1,8 +1,10 @@
+ use std::convert::Infallible;
++use std::env::remove_var;
+ use std::fs;
+ use std::io;
+ use std::net::SocketAddr;
+ use std::path::Path;
++use std::sync::LazyLock;
+ use std::sync::mpsc::{Sender, channel};
+ use std::thread;
+
+@@ -20,7 +22,7 @@ mod curl {
+
+ use url::Url;
+
+- use super::{serve_file, tmp_dir, write_file};
++ use super::{scrub_env, serve_file, tmp_dir, write_file};
+ use crate::download::{Backend, Event};
+
+ #[tokio::test]
+@@ -43,6 +45,7 @@ mod curl {
+
+ #[tokio::test]
+ async fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
++ let _guard = scrub_env().await;
+ let tmpdir = tmp_dir();
+ let target_path = tmpdir.path().join("downloaded");
+ write_file(&target_path, "123");
+@@ -94,11 +97,11 @@ mod curl {
+
+ #[cfg(any(feature = "reqwest-rustls-tls", feature = "reqwest-native-tls"))]
+ mod reqwest {
+- use std::env::{remove_var, set_var};
++ use std::env::set_var;
+ use std::error::Error;
+ use std::net::TcpListener;
++ use std::sync::Mutex;
+ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
+- use std::sync::{LazyLock, Mutex};
+ use std::thread;
+ use std::time::Duration;
+
+@@ -106,34 +109,16 @@ mod reqwest {
+ use reqwest::{Client, Proxy};
+ use url::Url;
+
+- use super::{serve_file, tmp_dir, write_file};
++ use super::{scrub_env, serve_file, tmp_dir, write_file};
+ use crate::download::{Backend, Event, TlsBackend};
+
+- static SERIALISE_TESTS: LazyLock<tokio::sync::Mutex<()>> =
+- LazyLock::new(|| tokio::sync::Mutex::new(()));
+-
+- unsafe fn scrub_env() {
+- unsafe {
+- remove_var("http_proxy");
+- remove_var("https_proxy");
+- remove_var("HTTPS_PROXY");
+- remove_var("ftp_proxy");
+- remove_var("FTP_PROXY");
+- remove_var("all_proxy");
+- remove_var("ALL_PROXY");
+- remove_var("no_proxy");
+- remove_var("NO_PROXY");
+- }
+- }
+-
+ // Tests for correctly retrieving the proxy (host, port) tuple from $https_proxy
+ #[tokio::test]
+ async fn read_basic_proxy_params() {
+- let _guard = SERIALISE_TESTS.lock().await;
++ let _guard = scrub_env().await;
+ // SAFETY: We are setting environment variables when `SERIALISE_TESTS` is locked,
+ // and those environment variables in question are not relevant elsewhere in the test suite.
+ unsafe {
+- scrub_env();
+ set_var("https_proxy", "http://proxy.example.com:8080");
+ }
+ let u = Url::parse("https://www.example.org").ok().unwrap();
+@@ -147,12 +132,11 @@ mod reqwest {
+ #[tokio::test]
+ async fn socks_proxy_request() {
+ static CALL_COUNT: AtomicUsize = AtomicUsize::new(0);
+- let _guard = SERIALISE_TESTS.lock().await;
++ let _guard = scrub_env().await;
+
+ // SAFETY: We are setting environment variables when `SERIALISE_TESTS` is locked,
+ // and those environment variables in question are not relevant elsewhere in the test suite.
+ unsafe {
+- scrub_env();
+ set_var("all_proxy", "socks5://127.0.0.1:1080");
+ }
+
+@@ -210,6 +194,7 @@ mod reqwest {
+
+ #[tokio::test]
+ async fn callback_gets_all_data_as_if_the_download_happened_all_at_once() {
++ let _guard = scrub_env().await;
+ let tmpdir = tmp_dir();
+ let target_path = tmpdir.path().join("downloaded");
+ write_file(&target_path, "123");
+@@ -363,3 +348,31 @@ fn serve_contents(
+ }
+ res
+ }
++
++/// Clear proxy-related environment variables
++///
++/// Every test using a proxy-sensitive URL should call this and hold the returned guard,
++/// regardless of whether the test is going to set its own proxy environment variables.
++async fn scrub_env() -> tokio::sync::MutexGuard<'static, ()> {
++ static SERIALISE_TESTS: LazyLock<tokio::sync::Mutex<()>> =
++ LazyLock::new(|| tokio::sync::Mutex::new(()));
++
++ let guard = SERIALISE_TESTS.lock().await;
++
++ // SAFETY: We are clearing environment variables when `SERIALISE_TESTS` is locked, and those
++ // environment variables in question are only relevant in tests that continue to hold this
++ // mutex guard.
++ unsafe {
++ remove_var("http_proxy");
++ remove_var("https_proxy");
++ remove_var("HTTPS_PROXY");
++ remove_var("ftp_proxy");
++ remove_var("FTP_PROXY");
++ remove_var("all_proxy");
++ remove_var("ALL_PROXY");
++ remove_var("no_proxy");
++ remove_var("NO_PROXY");
++ }
++
++ guard
++}
+--
+2.49.0
+
diff --git a/rustup.spec b/rustup.spec
index 5c5fa72..8e78f5e 100644
--- a/rustup.spec
+++ b/rustup.spec
@@ -46,6 +46,9 @@ Patch: 0004-Remove-unused-git-based-versioning.patch
Patch: 0005-Revert-back-to-rustls-ring-instead-of-aws_lc_rs.patch
# * temporarily downgrade opener dependency from 0.7 to 0.6 to match cargo
Patch: 0006-temporarily-downgrade-opener-dependency-from-0.7-to-.patch
+# * Serialize all tests with proxy-sensitive URLs
+# https://github.com/rust-lang/rustup/pull/4372
+Patch: 0001-Serialize-all-tests-with-proxy-sensitive-URLs.patch
ExcludeArch: %{ix86}
reply other threads:[~2026-11-18 21:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179503823956.1.14302305100544326989.rpms-rustup-936333484196@fedoraproject.org \
--to=jistone@redhat.com \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox