Skip to content

Commit da703be

Browse files
Max Lvclaude
authored andcommitted
Fix flaky env var tests by serializing with serial_test
Tests that mutate environment variables (set_var/remove_var) can race when run in parallel, causing intermittent failures. Add serial_test dev-dependency and mark all env-mutating tests with #[serial]. Co-Authored-By: Claude (claude-opus-4-6) <noreply@anthropic.com>
1 parent de1a4a0 commit da703be

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

Cargo.lock

Lines changed: 42 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ log = "0.4"
3333
env_logger = "0.11"
3434
dirs = "6"
3535
rustls-native-certs = "0.8"
36+
37+
[dev-dependencies]
38+
serial_test = "3"

src/args/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ fn parse_plugin_options(options: &str) -> HashMap<String, String> {
5353
#[cfg(test)]
5454
mod tests {
5555
use super::*;
56+
use serial_test::serial;
5657
use std::env;
5758

5859
#[test]
@@ -84,6 +85,7 @@ mod tests {
8485
}
8586

8687
#[test]
88+
#[serial]
8789
fn test_parse_env_addr_valid() {
8890
// Set environment variables for the test
8991
env::set_var("SS_LOCAL_HOST", "127.0.0.1");
@@ -106,6 +108,7 @@ mod tests {
106108
}
107109

108110
#[test]
111+
#[serial]
109112
fn test_parse_env_addr_missing_vars() {
110113
env::remove_var("SS_REMOTE_HOST");
111114
env::remove_var("SS_REMOTE_PORT");
@@ -117,6 +120,7 @@ mod tests {
117120
}
118121

119122
#[test]
123+
#[serial]
120124
fn test_parse_env_opts_valid() {
121125
env::set_var("SS_PLUGIN_OPTIONS", "host=example.com;cert=/tmp/cert.pem");
122126

@@ -131,6 +135,7 @@ mod tests {
131135
}
132136

133137
#[test]
138+
#[serial]
134139
fn test_parse_env_opts_missing_var() {
135140
env::remove_var("SS_PLUGIN_OPTIONS");
136141

0 commit comments

Comments
 (0)