Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/unreleased/BUG FIXES-20260724-142353.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: 'helper/resource: Fix persisted working directory copying on Windows.'
time: 2026-07-24T14:23:53.759+02:00
custom:
Issue: "672"
5 changes: 2 additions & 3 deletions internal/plugintest/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io"
"io/fs"
"os"
"path"
"path/filepath"
"strings"
"testing"
Expand Down Expand Up @@ -119,8 +118,8 @@ func CopyDir(src, dest, baseDirName string) error {
}

for _, dirEntry := range dirEntries {
srcFilepath := path.Join(src, dirEntry.Name())
destFilepath := path.Join(dest, dirEntry.Name())
srcFilepath := filepath.Join(src, dirEntry.Name())
destFilepath := filepath.Join(dest, dirEntry.Name())

if !strings.Contains(srcFilepath, baseDirName) {
continue
Expand Down
26 changes: 26 additions & 0 deletions internal/plugintest/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,29 @@ func dirEntryComparer(t *testing.T) cmp.Option {
return true
})
}

func TestCopyDirWithBaseDirName(t *testing.T) {
t.Parallel()

srcDir := t.TempDir()
baseDir := filepath.Join(srcDir, "work")

if err := os.MkdirAll(baseDir, 0o755); err != nil {
t.Fatalf("cannot create base directory: %s", err)
}

if err := os.WriteFile(filepath.Join(baseDir, "src.txt"), []byte("test"), 0o600); err != nil {
t.Fatalf("cannot create source file: %s", err)
}

destDir := filepath.Join(t.TempDir(), "dest")
baseDirName := baseDir[len(srcDir):]

if err := CopyDir(srcDir, destDir, baseDirName); err != nil {
t.Fatalf("cannot copy directory: %s", err)
}

if _, err := os.Stat(filepath.Join(destDir, "work", "src.txt")); err != nil {
t.Fatalf("cannot stat copied source file: %s", err)
}
}