Skip to content

Commit 74bee54

Browse files
mikolalysenkoclaude
andcommitted
fix: merge telemetry env-var tests to prevent parallel race condition
The two tests (test_is_telemetry_disabled_default and test_is_telemetry_disabled_when_set) mutated shared env vars and raced when run in parallel on Windows CI. Merge them into a single test that saves/restores the original values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ff6d7cf commit 74bee54

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

crates/socket-patch-core/src/utils/telemetry.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,20 +470,35 @@ pub async fn track_patch_rollback_failed(
470470
mod tests {
471471
use super::*;
472472

473+
/// Combined into a single test to avoid env-var races across parallel tests.
473474
#[test]
474-
fn test_is_telemetry_disabled_default() {
475+
fn test_is_telemetry_disabled() {
476+
// Save originals
477+
let orig_disabled = std::env::var("SOCKET_PATCH_TELEMETRY_DISABLED").ok();
478+
let orig_vitest = std::env::var("VITEST").ok();
479+
480+
// Default: not disabled
475481
std::env::remove_var("SOCKET_PATCH_TELEMETRY_DISABLED");
476482
std::env::remove_var("VITEST");
477483
assert!(!is_telemetry_disabled());
478-
}
479484

480-
#[test]
481-
fn test_is_telemetry_disabled_when_set() {
485+
// Disabled via "1"
482486
std::env::set_var("SOCKET_PATCH_TELEMETRY_DISABLED", "1");
483487
assert!(is_telemetry_disabled());
488+
489+
// Disabled via "true"
484490
std::env::set_var("SOCKET_PATCH_TELEMETRY_DISABLED", "true");
485491
assert!(is_telemetry_disabled());
486-
std::env::remove_var("SOCKET_PATCH_TELEMETRY_DISABLED");
492+
493+
// Restore originals
494+
match orig_disabled {
495+
Some(v) => std::env::set_var("SOCKET_PATCH_TELEMETRY_DISABLED", v),
496+
None => std::env::remove_var("SOCKET_PATCH_TELEMETRY_DISABLED"),
497+
}
498+
match orig_vitest {
499+
Some(v) => std::env::set_var("VITEST", v),
500+
None => std::env::remove_var("VITEST"),
501+
}
487502
}
488503

489504
#[test]

0 commit comments

Comments
 (0)