[3.0][Testing] Stop the canonical path tests naming a drive letter - #9605
Merged
live627 merged 1 commit intoSep 1, 2026
Merged
Conversation
Resolving dot segments has nothing to do with the root, so that test uses a relative path and asserts the whole result exactly on either platform. What the root is remains worth covering, since a path that starts at the root names no drive and on Windows picks up the one the process is on. That is now its own test, and it reads the drive from the working directory rather than assuming the checkout is on C. Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
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
Follow-up to #9600, which fixed the Windows failure by naming
C:in the path under test. That works — the drive comes from the input rather than the machine, so it passes on a runner whose checkout is onD:— but @live627 is right that a hardcoded drive letter is not the thing to leave in a test. It reads as an assumption even where it is not one, and it means nothing covers the branch that actually broke: on Windows a path that starts at the root but names no drive is rooted on the current one, and it was that step which turned/a/cintoC:\a\c.Splitting the two behaviours apart removes the need to name a drive at all.
Dot segments have nothing to do with the root, so the test named for them uses a relative path. There is no root to differ over and the whole result can be asserted exactly on either platform:
What the root is is worth covering on its own, so it gets its own test, and the drive is read from the working directory rather than assumed:
The review suggested a regex, which would also have removed the hardcoded letter. I went with an exact assertion instead because the expected value here is not "some drive" but a specific one — the drive the process is on — and
assertSamesays that, gives a real diff when it fails, and would still catch the original bug on POSIX, where a regex with an optional drive group would accept a stray letter. Happy to switch it if you would rather have the pattern.Verified on both platforms. The suite is green on Linux, and I checked the Windows path by extracting
canonicalPath(), substituting\forDIRECTORY_SEPARATORand running it with the working directory onD:, where all four assertions hold:composer lintis clean.Issues References (Fixes|Related|Closes)
SapiTestfails on Windows #9595