fix(test): locate CLI binary by target-dir depth, not fixed deps/ pop - #508
Merged
newhoggy merged 1 commit intoJul 31, 2026
Merged
Conversation
…s/ pop Nightly Cargo defaulted to build-dir-layout-v2 (rust-lang/cargo#17258), nesting test binaries under target/<profile>/build/<pkg>/<hash>/out/ instead of the flat target/<profile>/deps/. The succinctly_bin() helper in dsv_cli_tests.rs, text_cli_tests.rs, json_validate_tests.rs, and yaml_validate_tests.rs assumed the old layout and computed a bogus path, failing all 4 suites on the nightly CI leg. Derive target/<profile>/ by finding the `target` path component instead, which holds under both layouts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes test suite failures on nightly Cargo builds caused by Cargo's new
build-dir-layout-v2directory structure. Nightly Cargo (from ~2026-07 onwards) changed the default build directory layout, nesting test binaries undertarget/<profile>/build/<pkg>/<hash>/out/instead of the flattarget/<profile>/deps/structure. The CLI binary locator helper in four test suites was hardcoded to pop thedeps/directory component, resulting in incorrect paths and test failures.The fix introduces a layout-agnostic path resolution strategy that locates the
targetdirectory component and derives<target>/<profile>/from there, working correctly with both the legacy flat layout and the new nested build-dir-layout-v2.Type of Change
Related Issue
Fixes #507 - CI nightly Cargo build-dir-layout-v2 breaks CLI binary tests
Changes Made
Test Binary Path Resolution:
deps/path popping logic with a newtarget_profile_dir_from_test_exe()helper function in all four test suitestargetpath component and derives<target>/<profile>/by collecting path components up to and including the profile directorytarget/<profile>/deps/) and the new build-dir-layout-v2 nested layout (target/<profile>/build/<pkg>/<hash>/out/)Files Modified:
tests/dsv_cli_tests.rs- Addedtarget_profile_dir_from_test_exe()helper, refactoredsuccinctly_bin()to use ittests/json_validate_tests.rs- Addedtarget_profile_dir_from_test_exe()helper, refactoredsuccinctly_bin()to use ittests/text_cli_tests.rs- Addedtarget_profile_dir_from_test_exe()helper, refactoredsuccinctly_bin()to use ittests/yaml_validate_tests.rs- Addedtarget_profile_dir_from_test_exe()helper, refactoredsuccinctly_bin()to use itTesting
Automated Testing:
Manual Testing:
Test Commands
Performance Impact
Checklist
Additional Notes
Root Cause Analysis:
Cargo's new build-dir-layout-v2 (rust-lang/cargo#17258) changes directory nesting but preserves the property that the profile directory immediately follows the
targetcomponent in all paths. The original code assumed a fixed depth (always popping two levels to reach the profile directory), which broke under the new layout. By searching for thetargetcomponent dynamically, we make the code resilient to both current and future Cargo layout changes.Why This Solution:
This approach is layout-agnostic and doesn't rely on assumptions about directory depth. It will continue working if Cargo changes the layout again, as long as the
target/<profile>/ancestor relationship is maintained.CI Impact:
This fix enables the full test suite to pass on nightly CI runs without requiring layout-specific workarounds or conditional compilation.