6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-04 15:39:46 +00:00

Fix failing windows tests

Fix incorrect filepath.join usage in building filepaths from URL
This commit is contained in:
Grzegorz Dlugoszewski
2025-08-11 23:03:09 +02:00
parent 0612421afc
commit 31fa76afb8
8 changed files with 57 additions and 39 deletions

View File

@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"testing"
)
@@ -17,17 +18,14 @@ func TempDir(t *testing.T, parent string) string {
// Automatically remove temp dir when the test is over.
t.Cleanup(func() {
err := os.RemoveAll(dir)
if err != nil {
t.Errorf("failed removing test repo %s", dir)
}
removeTestDir(t, dir)
})
return dir
}
func (r *Repo) init() {
err := run.Git("init", "--quiet", r.path).AndShutUp()
err := run.Git("init", "--quiet", "--initial-branch=main", r.path).AndShutUp()
checkFatal(r.t, err)
}
@@ -92,3 +90,17 @@ func checkFatal(t *testing.T, err error) {
t.Fatalf("failed making test repo: %+v", err)
}
}
// removeTestDir removes a test directory
func removeTestDir(t *testing.T, dir string) {
// Skip cleanup on Windows to avoid file locking issues in CI
// The CI runner environment is destroyed after tests anyway
if runtime.GOOS == "windows" {
return
}
err := os.RemoveAll(dir)
if err != nil {
t.Logf("warning: failed removing test repo %s: %v", dir, err)
}
}