Skip to content

test(config): serialize test_from_figment_cli_args_override - #760

Draft
wagenet wants to merge 1 commit into
Eyevinn:mainfrom
wagenet:wagenet/config-test-serial
Draft

test(config): serialize test_from_figment_cli_args_override#760
wagenet wants to merge 1 commit into
Eyevinn:mainfrom
wagenet:wagenet/config-test-serial

Conversation

@wagenet

@wagenet wagenet commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

config::tests::test_from_figment_cli_args_override was the only test in the
config module without #[serial]. It fails intermittently in a full parallel
cargo test run with:

called `Result::unwrap()` on an `Err` value: Invalid argument (os error 22)

Cause

Every neighbouring test_from_figment_* test moves the process working
directory into a TempDir with std::env::set_current_dir, then lets the
TempDir drop. #[serial] serializes those against each other but not against
this one, so it can run inside that window.

Config::from_figment looks for .strom.toml in the process working directory.
When it runs while test_config_file_with_data_dir is chdir'd into its
TempDir, it reads that test's config file, picks up its
storage.data_dir — which points inside the same TempDir — and
DataPaths::resolve calls create_dir_all on a directory the other test is
deleting. On macOS that mkdir mostly fails with EINVAL, which is the
reported os error 22; occasionally ENOENT.

Note this is not the working directory read failing. from_figment calls
std::env::current_dir().ok(), so an unlinked working directory is swallowed
(and would give ENOENT, not EINVAL). The failure comes from the config file
the borrowed working directory exposes.

Confirmation

Forced the race with a throwaway probe (not committed): a background thread
looping chdir-into-TempDir / write .strom.toml / delete, while the main thread
ran this test's from_figment call 4000 times. Three runs:

run failures / 4000 EINVAL ENOENT
1 214 204 10
2 219 210 9
3 210 201 9

That reproduces the exact reported message.

Fix

Add #[serial], matching every other test in the module.

The two remaining unserialized tests in the module are not exposed:
test_ice_servers_normalization is a pure string test, and
test_legacy_config_new calls Config::new with data_dir: None and no
config-file or environment read, so its base directory is always the platform
data directory.

Testing

  • cargo test --features efp --lib, 12 runs before the change and 12 after — all
    544 tests green in every run. A green run is weak evidence: the flake is
    reported at roughly 1 in 8 full runs, so 12 clean runs before the change is a
    ~20% likely outcome on its own, and I did not observe the flake in the baseline.
    The argument for this fix is the serialization reasoning plus the forced-race
    reproduction above, not the run count.
  • No deterministic regression guard is included. A committed version of the probe
    would prove from_figment is working-directory-sensitive, but it would not fail
    if the #[serial] were reverted, so per the repo's test rules it would be a
    demonstration rather than a guard. Forcing the real race would require a thread
    mutating the process working directory outside the serial lock, which is the
    disease, not a test.

🤖 Generated with Claude Code

It was the only test in the config module without `#[serial]`, so it could
run while a neighbouring test had moved the process working directory into
a TempDir. `from_figment` looks for `.strom.toml` in the working directory,
so it would then read that test's config file, pick up its `storage.data_dir`
pointing inside the same TempDir, and call `create_dir_all` on a directory the
other test was deleting. On macOS that mkdir usually fails with EINVAL,
surfacing as `Invalid argument (os error 22)` from the `unwrap()`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant