Skip to content

Commit a1ca230

Browse files
committed
Start using serial_test for test serialisation
1 parent caac61b commit a1ca230

File tree

4 files changed

+77
-10
lines changed

4 files changed

+77
-10
lines changed

Cargo.lock

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ opentelemetry-otlp = "0.14.0"
169169
opentelemetry_sdk = { version = "0.21.0", features = ["rt-tokio"] }
170170
proptest = "1.1.0"
171171
rustup-macros = { path = "rustup-macros" }
172+
serial_test = "3"
172173
tempfile = "3.8"
173174
termcolor = "1.2"
174175
thiserror = "1.0"

download/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ hyper = { version = "1.0", default-features = false, features = [
3535
"server",
3636
] }
3737
hyper-util = { version = "0.1.1", features = ["tokio"] }
38+
serial_test.workspace = true
3839
tempfile.workspace = true

download/tests/read-proxy-env.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ use std::env::{remove_var, set_var};
44
use std::error::Error;
55
use std::net::TcpListener;
66
use std::sync::atomic::{AtomicUsize, Ordering};
7-
use std::sync::Mutex;
87
use std::thread;
98
use std::time::Duration;
109

1110
use env_proxy::for_url;
1211
use reqwest::{Client, Proxy};
12+
use serial_test::serial;
1313
use url::Url;
1414

15-
static SERIALISE_TESTS: Mutex<()> = Mutex::new(());
16-
1715
fn scrub_env() {
1816
remove_var("http_proxy");
1917
remove_var("https_proxy");
@@ -28,10 +26,8 @@ fn scrub_env() {
2826

2927
// Tests for correctly retrieving the proxy (host, port) tuple from $https_proxy
3028
#[tokio::test]
29+
#[serial]
3130
async fn read_basic_proxy_params() {
32-
let _guard = SERIALISE_TESTS
33-
.lock()
34-
.expect("Unable to lock the test guard");
3531
scrub_env();
3632
set_var("https_proxy", "http://proxy.example.com:8080");
3733
let u = Url::parse("https://www.example.org").ok().unwrap();
@@ -43,12 +39,9 @@ async fn read_basic_proxy_params() {
4339

4440
// Tests to verify if socks feature is available and being used
4541
#[tokio::test]
42+
#[serial]
4643
async fn socks_proxy_request() {
4744
static CALL_COUNT: AtomicUsize = AtomicUsize::new(0);
48-
let _guard = SERIALISE_TESTS
49-
.lock()
50-
.expect("Unable to lock the test guard");
51-
5245
scrub_env();
5346
set_var("all_proxy", "socks5://127.0.0.1:1080");
5447

0 commit comments

Comments
 (0)