feat: fix flaky generate test and format tunnel.rs
- Fix race condition in generate test temp_dir() by using PID + atomic counter instead of nanosecond timestamps that collide under parallel test execution - Apply cargo fmt to tunnel.rs for consistent formatting Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent
10b8b24dce
commit
32a29c89f2
+6
-5
@@ -200,12 +200,13 @@ mod tests {
|
||||
use crate::redact;
|
||||
|
||||
fn temp_dir() -> std::path::PathBuf {
|
||||
// Use process ID + monotonic counter to avoid collisions when tests run in parallel
|
||||
static COUNTER: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0);
|
||||
let unique = COUNTER.fetch_add(1, std::sync::atomic::Ordering::Relaxed);
|
||||
std::env::temp_dir().join(format!(
|
||||
"rustunnel_generate_test_{}",
|
||||
std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos()
|
||||
"rustunnel_generate_test_{}_{}",
|
||||
std::process::id(),
|
||||
unique
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user