-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Description
When running ddtest from a monorepo subdirectory (e.g., cd core && ../bin/ddtest run ...), all workers fail with LoadError if ITR/Test Impact Analysis is enabled. Without ITR (default settings), the same command works correctly.
Root Cause
ddtest normalizes test file paths to git-root-relative when ITR is enabled, but passes these normalized paths to rspec workers that run from the subdirectory CWD. This causes a double-prefix path issue.
Step by step:
- Command:
cd core && ../bin/ddtest run --framework rspec --platform ruby ... - ddtest discovers test files using glob
spec/**/*_spec.rbfrom CWD (core/) — findsspec/models/spree/order_spec.rb - ddtest normalizes these to git-root-relative paths — becomes
core/spec/models/spree/order_spec.rb - Normalized paths are written to
.testoptimization/tests-split/runner-* - Workers run rspec from the same CWD (
core/) — rspec tries to loadcore/spec/models/spree/order_spec.rbrelative to CWD - This resolves to
core/core/spec/models/spree/order_spec.rb— file does not exist
Reproduction
Repository: Any Ruby monorepo where tests are run from a subdirectory (e.g., Spree Commerce with core/ and api/ sub-projects).
Steps:
# Clone a monorepo with test suites in subdirectories
git clone <monorepo-with-subdirs>
cd monorepo
# This works (ITR disabled by default):
cd core && ddtest run --framework rspec --platform ruby --min-parallelism 1 --max-parallelism 4
# This fails (ITR enabled via backend settings):
# When the backend returns itr_enabled: true, tests_skipping: true
cd core && ddtest run --framework rspec --platform ruby --min-parallelism 1 --max-parallelism 4Backend settings that trigger the bug:
{
"itr_enabled": true,
"tests_skipping": true,
"code_coverage": true
}Error Output
All workers produce:
Finished in 0.00004 seconds (files took 10.42 seconds to load)
0 examples, 0 failures, 104 errors occurred outside of examples
Each error is:
LoadError:
cannot load such file -- /path/to/monorepo/core/core/spec/models/spree/payment_spec.rb
Note the doubled core/core/ in the path.
Evidence
Contents of .testoptimization/test-files.txt (git-root-relative, with core/ prefix):
core/spec/finders/spree/addresses/find_spec.rb
core/spec/finders/spree/option_values/find_available_spec.rb
core/spec/helpers/base_helper_spec.rb
...
Contents of .testoptimization/tests-split/runner-0 (same prefix, passed to rspec in core/ CWD):
core/spec/models/spree/order_spec.rb
core/spec/models/spree/return_item_spec.rb
...
Expected Behavior
When ddtest passes file paths to rspec workers, it should use paths relative to the worker's CWD (i.e., strip the subdirectory prefix). The tests-split/runner-* files should contain:
spec/models/spree/order_spec.rb
spec/models/spree/return_item_spec.rb
...
Environment
- ddtest: latest
mainbranch - Ruby: 4.0.1
- datadog-ci gem: latest
mainbranch - OS: macOS (Darwin 24.6.0, arm64)
- Framework: RSpec