Skip to content

Serialize test env var mutations to fix flaky provider tests#1

Open
xeb wants to merge 1 commit into
masterfrom
codex/find-bugs-in-source-code
Open

Serialize test env var mutations to fix flaky provider tests#1
xeb wants to merge 1 commit into
masterfrom
codex/find-bugs-in-source-code

Conversation

@xeb
Copy link
Copy Markdown
Owner

@xeb xeb commented Mar 7, 2026

Motivation

  • Provider unit tests mutate process environment variables and were racing when run in parallel, causing intermittent test failures (e.g. Azure/Gemini provider tests).

Description

  • Add a test-only static ENV_LOCK (LazyLock<Mutex<()>>) in src/provider.rs and acquire the lock at the start of each env-mutating provider test to serialize environment variable changes without touching production code.

Testing

  • Ran cargo test provider::tests::test_azure_openai_requires_env_vars, cargo test provider::tests::test_gemini_3_flash_preview_uses_native_api, and the full cargo test, and observed the targeted tests and the full suite succeed (previously two provider tests were flaky; after the change the suite passed: all tests passed).

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant