Skip to content

[nextest-runner] be build directory-aware#3169

Merged
sunshowers merged 1 commit into
mainfrom
build-dir-aware
Mar 17, 2026
Merged

[nextest-runner] be build directory-aware#3169
sunshowers merged 1 commit into
mainfrom
build-dir-aware

Conversation

@sunshowers

Copy link
Copy Markdown
Member

Upcoming versions of Cargo are going to incorporate a split between the build and target directories. The build directory is for intermediate artifacts, while final build outputs are uplifted to the target directory.

Also add --build-dir-remap to PathMapper and split map_binary() into map_target_path() and map_build_path(), so the --binaries-metadata + --target-dir-remap workflow works when build_directory != target_directory.

The remapping behavior is:

build_dir in metadata --target-dir-remap --build-dir-remap target_dir maps to build_dir maps to
== target_dir (none) (none) unchanged unchanged
== target_dir /new/tgt (none) /new/tgt /new/tgt (fallback)
== target_dir /new/tgt /new/bld /new/tgt /new/bld
!= target_dir (none) (none) unchanged unchanged
!= target_dir /new/tgt (none) /new/tgt /new/tgt (fallback)
!= target_dir (none) /new/bld unchanged /new/bld
!= target_dir /new/tgt /new/bld /new/tgt /new/bld

Also add an integration test with the new build directory support.

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.48529% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.22%. Comparing base (d9c9241) to head (f3965c5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cargo-nextest/src/reuse_build.rs 70.00% 6 Missing ⚠️
nextest-runner/src/redact.rs 58.33% 5 Missing ⚠️
nextest-runner/src/list/binary_list.rs 94.33% 3 Missing ⚠️
nextest-runner/src/errors.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3169      +/-   ##
==========================================
+ Coverage   85.19%   85.22%   +0.03%     
==========================================
  Files         158      158              
  Lines       46399    46610     +211     
==========================================
+ Hits        39529    39723     +194     
- Misses       6870     6887      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates nextest’s build artifact handling to support Cargo’s upcoming split between build and target directories, ensuring reuse-build, archiving, and path remapping continue to work correctly when build_directory != target_directory.

Changes:

  • Add build_directory throughout Rust build metadata and update path joining/mapping for test binaries, build script outputs, and linked paths.
  • Extend reuse-build remapping with --build-dir-remap, and split path mapping into map_target_path() vs map_build_path().
  • Update archive metadata emission to normalize/omit build_directory, and add CI coverage for Cargo build-dir mode.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
nextest-runner/src/test_command.rs Sets OUT_DIR based on build_directory rather than target_directory.
nextest-runner/src/reuse_build/mod.rs Adds build-dir remap plumbing and splits path mapping into target vs build mappings.
nextest-runner/src/reuse_build/archiver.rs Writes archive metadata via archive-specific summaries; treats test binaries/build script outputs/linked paths as build-dir relative.
nextest-runner/src/redact.rs Updates redactions to treat linked paths as build-dir relative; adds build-dir redaction.
nextest-runner/src/list/test_list.rs Maps test binary paths via build-dir mapping.
nextest-runner/src/list/test_helpers.rs Updates helper construction for new RustBuildMeta::new(target, build, ...) signature.
nextest-runner/src/list/rust_build_meta.rs Introduces build_directory and updates dylib path resolution + summary/archive summary behavior.
nextest-runner/src/list/binary_list.rs Detects Cargo build dir when available; produces archive-specific summaries that remap test binary paths under target/.
nextest-runner/src/errors.rs Adds BuildDir kind for PathMapper construction errors.
nextest-metadata/src/test_list.rs Adds optional build_directory to serialized metadata with backwards-compatible defaults.
fixtures/nextest-tests/cdylib/cdylib-link/build.rs Avoids recursive build-dir locking and supports old/new dylib output locations.
cargo-nextest/src/reuse_build.rs Adds --build-dir-remap and applies fallback behavior when constructing PathMapper.
cargo-nextest/src/dispatch/core/tests.rs Extends CLI argument parsing tests for --build-dir-remap constraints.
cargo-nextest/src/dispatch/core/filter.rs Passes build_directory into path-mapper creation for reuse-build workflows.
.github/workflows/ci.yml Adds a CI job that runs/archives fixtures with Cargo build-dir enabled and validates archive portability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread nextest-runner/src/reuse_build/mod.rs
Comment thread nextest-runner/src/redact.rs
Upcoming versions of Cargo are going to incorporate a split between the build
and target directories. The build directory is for intermediate artifacts, while
final build outputs are uplifted to the target directory.

Also add `--build-dir-remap` to `PathMapper` and split `map_binary()` into
`map_target_path()` and `map_build_path()`, so the `--binaries-metadata` +
`--target-dir-remap` workflow works when `build_directory != target_directory`.

The remapping behavior is:

| `build_dir` in metadata | `--target-dir-remap` | `--build-dir-remap` | target_dir maps to | build_dir maps to |
|---|---|---|---|---|
| == target_dir | (none) | (none) | unchanged | unchanged |
| == target_dir | /new/tgt | (none) | /new/tgt | /new/tgt (fallback) |
| == target_dir | /new/tgt | /new/bld | /new/tgt | /new/bld |
| != target_dir | (none) | (none) | unchanged | unchanged |
| != target_dir | /new/tgt | (none) | /new/tgt | /new/tgt (fallback) |
| != target_dir | (none) | /new/bld | unchanged | /new/bld |
| != target_dir | /new/tgt | /new/bld | /new/tgt | /new/bld |

Also add an integration test with the new build directory support.
@sunshowers sunshowers merged commit 36d5c73 into main Mar 17, 2026
24 checks passed
@sunshowers sunshowers deleted the build-dir-aware branch March 17, 2026 00:44
@trunk-io

trunk-io Bot commented Mar 17, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

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.

2 participants