test: narrow subst pattern in non-existent-branch.t to avoid matching paths#14314
Merged
ElectreAAS merged 2 commits intoApr 30, 2026
Merged
Conversation
The test's output post-processing used `dune_cmd subst '-\d+' '-eol'` to normalise the variable end-column in the "characters 6-N:" part of dune's error location. The pattern was too broad: any `-<digits>` substring in the output would match, including path components in the sandbox root (e.g. when the repo is checked out at a worktree whose directory contains `-<digits>`, such as `dune-pr-14116/`, the substitution rewrites the path and BUILD_PATH_PREFIX_MAP stripping no longer matches, producing a raw-path diff in the test output). Anchor the pattern to `characters 6-\d+` so it only matches the column range it was meant to normalise. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a flaky blackbox test by narrowing an overly broad output normalization substitution so it no longer rewrites unrelated -<digits> substrings (notably in sandbox/worktree paths), which could prevent BUILD_PATH_PREFIX_MAP path stripping and cause assertion failures.
Changes:
- Tighten the
dune_cmd substregex from-\d+tocharacters 6-\d+in the test output post-processing. - Update the replacement string accordingly to normalize the end-column range without affecting paths.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ElectreAAS
requested changes
Apr 29, 2026
Replaces [subst 'characters 6-\d+' 'characters 6-eol'] with [subst 'characters \d+-\d+:' 'characters start-eol:'], so a future shift in either column doesn't break the assertion. Mirrors the substitution shape used in ocaml#13568 for an analogously-named test. Co-authored-by: Ambre Austen Suhamy <ambre.suhamy@pm.me> Signed-off-by: Robin Bate Boerop <me@robinbb.com>
e3bdf64 to
50a924a
Compare
ElectreAAS
approved these changes
Apr 30, 2026
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.
Summary
The output post-processing in
test/blackbox-tests/test-cases/pkg/pin-stanza/non-existent-branch.tuses
dune_cmd subst '-\d+' '-eol'to normalise the variableend-column in the
characters 6-<N>:part of dune's errorlocation. The pattern is too broad: any
-<digits>substring inthe output matches, including path components in the sandbox root.
When the repo is checked out at a worktree whose directory contains
-<digits>(e.g.dune-pr-14116/), the substitution rewritesthat path component and
BUILD_PATH_PREFIX_MAPstripping nolonger matches, so the test output contains a raw sandbox path and
the assertion fails.
Anchor the pattern to
characters 6-\d+so it only matches thecolumn range it was meant to normalise.
Test plan
containing
-<digits>(e.g.dune-pr-14116/) on upstream/main.worktree path.
does not match
-<digits>.