Skip to content

fix(test): serialize env-mutating tests to prevent flaky failures#718

Merged
NikolayS merged 2 commits intomainfrom
fix/flaky-env-tests
Mar 24, 2026
Merged

fix(test): serialize env-mutating tests to prevent flaky failures#718
NikolayS merged 2 commits intomainfrom
fix/flaky-env-tests

Conversation

@NikolayS
Copy link
Copy Markdown
Owner

Closes #717

Adds ENV_MUTEX static to serialize all tests that call set_var/remove_var.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 24, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.79%. Comparing base (4ebf0dc) to head (da5b37e).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #718      +/-   ##
==========================================
+ Coverage   68.79%   68.79%   +0.01%     
==========================================
  Files          46       46              
  Lines       30992    30998       +6     
==========================================
+ Hits        21318    21324       +6     
  Misses       9674     9674              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Tests that call std::env::set_var/remove_var race when run in parallel,
causing intermittent failures. Add a static LazyLock<Mutex<()>> and
acquire it in every env-mutating test so they execute serially.

Affected tests:
- startup_file_returns_psqlrc_env_when_set
- startup_file_returns_none_when_no_rc_exists_and_no_env
- resolve_api_key_env_var
- resolve_api_key_missing_env_var
- resolve_api_key_empty_env_var

Closes #717
@NikolayS NikolayS force-pushed the fix/flaky-env-tests branch from de8fe0d to 97c9400 Compare March 24, 2026 03:07
@NikolayS NikolayS merged commit 894cdde into main Mar 24, 2026
16 checks passed
@NikolayS NikolayS deleted the fix/flaky-env-tests branch March 27, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(test): startup_file_returns_psqlrc_env_when_set is flaky due to shared env var mutation

2 participants