internal/plugintest: fix CopyDir paths on Windows - #674
Open
massimomazzariol wants to merge 1 commit into
Open
Conversation
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.
Related Issue
Fixes #672
Description
CopyDircurrently builds filesystem paths usingpath.Join, which always uses forward slashes.When
copyWorkingDirpasses abaseDirNamederived from native Windows paths, the subsequent substring check can compare paths containing different separators. This causes matching entries to be skipped without returning an error, leaving persistedstep_Ndirectories without the expected working directory contents.This change uses
filepath.Joinfor filesystem paths so that the generated paths use the native platform separator.A regression test was added using a non-empty
baseDirNameto verify that the expected nested file is copied successfully.Testing
The affected package and the existing persisted working directory tests pass with both Go versions used by the repository CI matrix:
GOTOOLCHAIN=go1.25.12 go test ./internal/plugintest -count=1GOTOOLCHAIN=go1.25.12 go test ./helper/resource -run PersistWorkingDir -count=1GOTOOLCHAIN=go1.26.5 go test ./internal/plugintest -count=1GOTOOLCHAIN=go1.26.5 go test ./helper/resource -run PersistWorkingDir -count=1The new regression test was also verified to fail before the production change and pass afterward.
Tested with:
Other unrelated Windows-specific unit test portability failures are tracked separately in #673.
Rollback Plan
Changes to Security Controls
No changes to security controls.