Skip to content

internal/plugintest: fix CopyDir paths on Windows - #674

Open
massimomazzariol wants to merge 1 commit into
hashicorp:mainfrom
massimomazzariol:fix-copydir-windows
Open

internal/plugintest: fix CopyDir paths on Windows#674
massimomazzariol wants to merge 1 commit into
hashicorp:mainfrom
massimomazzariol:fix-copydir-windows

Conversation

@massimomazzariol

Copy link
Copy Markdown

Related Issue

Fixes #672

Description

CopyDir currently builds filesystem paths using path.Join, which always uses forward slashes.

When copyWorkingDir passes a baseDirName derived 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 persisted step_N directories without the expected working directory contents.

This change uses filepath.Join for filesystem paths so that the generated paths use the native platform separator.

A regression test was added using a non-empty baseDirName to 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=1
  • GOTOOLCHAIN=go1.25.12 go test ./helper/resource -run PersistWorkingDir -count=1
  • GOTOOLCHAIN=go1.26.5 go test ./internal/plugintest -count=1
  • GOTOOLCHAIN=go1.26.5 go test ./helper/resource -run PersistWorkingDir -count=1

The new regression test was also verified to fail before the production change and pass afterward.

Tested with:

  • Windows 11 Pro 10.0.26200
  • Terraform 1.15.8
  • Go 1.25.12 and 1.26.5
  • Git 2.54.0.windows.1

Other unrelated Windows-specific unit test portability failures are tracked separately in #673.

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

No changes to security controls.

@massimomazzariol
massimomazzariol requested a review from a team as a code owner July 24, 2026 12:51
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.

CopyDir may skip persisted working directory contents on Windows

1 participant