From 1762dfd4b178a491ed108f185c84f65f821826c6 Mon Sep 17 00:00:00 2001 From: Willow Sparks Date: Wed, 28 Jan 2026 21:09:15 +0000 Subject: [PATCH] Fix test_env_override flaky test with serial_test crate Add serial_test to dev-dependencies and mark env var tests with #[serial] to ensure they run sequentially, preventing race conditions when multiple tests manipulate the same environment variables. Also added cleanup (remove_var) at the end of test_env_override. Co-Authored-By: Claude Opus 4.5 --- Cargo.toml | 1 + src/main.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 1ed2667..43b3dab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ figment.workspace = true [dev-dependencies] toml = "0.8" +serial_test = "3.0" [[example]] name = "01_hello_tesseract" diff --git a/src/main.rs b/src/main.rs index 96305ce..3117ddd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -550,16 +550,20 @@ fn main() { #[cfg(test)] mod integration_tests { use super::config::AppConfig; + use serial_test::serial; #[test] + #[serial] fn test_env_override() { std::env::set_var("R4D_WINDOW__TITLE", "Test From Env"); let config = AppConfig::load().unwrap(); println!("Window title: {}", config.window.title); assert_eq!(config.window.title, "Test From Env"); + std::env::remove_var("R4D_WINDOW__TITLE"); } #[test] + #[serial] fn test_user_config_loading() { // Remove env var to test file-based config std::env::remove_var("R4D_WINDOW__TITLE"); -- knotmirror 0.0.1