[SDTEST-2713] Fix monorepo subdirectory path handling when ITR is enabled#34
Conversation
When running ddtest from a monorepo subdirectory (e.g., `cd core && ddtest run`), full test discovery returns repo-root-relative paths like `core/spec/models/order_spec.rb`. These paths were passed unchanged to workers running from the `core/` CWD, causing them to resolve `core/core/spec/...` which does not exist. Add conservative path normalization that detects the CWD's position relative to the git root and strips the matching prefix from repo-root-relative paths before storing them. The normalization is fail-safe: paths are returned unchanged if git root is unavailable, the prefix doesn't match, or CWD is already the repo root. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49256468eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ks correctly when test suites are returned from the backend with same names as they were traced by the library
E2E Test Report: SUCCESS ✅Tested by: Shepherd Agent (autonomous QA for Datadog Test Optimization) Test Environment
Results
DetailsBoth runs used a mockdog scenario that marks 2 tests in
Key difference between runs:
The path normalization fix correctly handles both cases for test discovery and split distribution. Test Methodology
This E2E test was performed by Shepherd — autonomous QA agent for Datadog Test Optimization |
Summary
Fixes #33
ddtestfrom a monorepo subdirectory (cd core && ddtest run), full test discovery (ITR enabled) returns repo-root-relative paths likecore/spec/models/order_spec.rb. Workers run from the subdirectory CWD, so they resolvecore/core/spec/...which does not exist.PrepareTestOptimizationthat detects the CWD's position relative to the git root and strips the matching prefix from repo-root-relative paths. Fail-safe: no-op if git root is unavailable, prefix doesn't match, or CWD is already repo root.E2E verification
Made with Cursor