Skip to content

Commit cabf116

Browse files
committed
fix(test): prevent flaky test_caching test with serial execution
The test_caching test uses a static cache shared across all tests. When tests run in parallel, other tests can modify the cache between clear_cache() and the cache_size() assertions, causing spurious failures. Fix by adding #[serial] attribute from serial_test crate to ensure this test runs in isolation from other tests that use the cache.
1 parent 0e62a3a commit cabf116

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Cargo.lock

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

src/cortex-engine/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ tempfile = { workspace = true }
132132
tokio-test = { workspace = true }
133133
wiremock = { workspace = true }
134134
insta = { workspace = true }
135+
serial_test = { workspace = true }

src/cortex-engine/src/config/config_discovery.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ pub fn git_root(path: &Path) -> Option<PathBuf> {
247247
#[cfg(test)]
248248
mod tests {
249249
use super::*;
250+
use serial_test::serial;
250251
use tempfile::TempDir;
251252

252253
fn setup_test_dir() -> TempDir {
@@ -344,8 +345,9 @@ mod tests {
344345
}
345346

346347
#[test]
348+
#[serial]
347349
fn test_caching() {
348-
// Clear cache first since tests run in parallel and share static cache
350+
// Clear cache first - must use #[serial] since tests share static cache
349351
clear_cache();
350352
assert_eq!(cache_size(), 0);
351353

0 commit comments

Comments
 (0)