Skip to content

CRITICAL: Work directory collisions under parallel test execution #29

@siphonite

Description

@siphonite

Problem

The orchestrator uses a fixed base directory (/tmp/first) and deterministic subdirectories (run_N).
Code reference:
https://github.com/siphonite/first/blob/main/src/orchestrator.rs#L13

const FIRST_BASE_DIR: &str = "/tmp/first";

https://github.com/siphonite/first/blob/main/src/orchestrator.rs#L46

let work_dir = PathBuf::from(FIRST_BASE_DIR).join(format!("run_{}", target));

When cargo test runs tests in parallel (the default behavior), multiple FIRST tests will attempt to read/write to /tmp/first/run_N concurrently.

Impact

  • Cross-test filesystem corruption: One test's cleanup might delete another test's active directory.
  • Nondeterministic failures: Tests might fail sporadically depending on thread scheduling.
  • False positives/negatives: A test might pass because another test set up the state it expected, or fail because another test clobbered it.
  • Unsafe for default cargo test usage: Users must run with --test-threads=1 to avoid this, which is not obvious.

Acceptance Criteria

  • Each FIRST test invocation uses a globally unique base directory.
  • Examples of unique identifiers: UUID, PID + timestamp, or hash(test_name + PID).
  • Use std::env::temp_dir() instead of hardcoding /tmp to respect OS conventions.
  • No shared filesystem paths across concurrent tests.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions