From dd31ae817a0d743d020f1732ee20457f5c7c3fb0 Mon Sep 17 00:00:00 2001 From: vince Date: Tue, 1 Dec 2020 21:16:35 +0800 Subject: [PATCH] fix tests failing on windows --- bug/bug_test.go | 4 ++-- repository/git_testing.go | 2 +- repository/gogit.go | 11 +++++------ repository/repo_testing.go | 4 +--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/bug/bug_test.go b/bug/bug_test.go index 05f6e617e9497e27e5d19425d305f2bf04457f5c..1e0943c14aae912dae9780bd40389b8ec26451d9 100644 --- a/bug/bug_test.go +++ b/bug/bug_test.go @@ -130,10 +130,10 @@ func TestBugRemove(t *testing.T) { remoteB := repository.CreateGoGitTestRepo(true) defer repository.CleanupTestRepos(repo, remoteA, remoteB) - err := repo.AddRemote("remoteA", "file://"+remoteA.GetPath()) + err := repo.AddRemote("remoteA", remoteA.GetPath()) require.NoError(t, err) - err = repo.AddRemote("remoteB", "file://"+remoteB.GetPath()) + err = repo.AddRemote("remoteB", remoteB.GetPath()) require.NoError(t, err) // generate a bunch of bugs diff --git a/repository/git_testing.go b/repository/git_testing.go index 874cc86ceabd59fe0fbc977e6a13cd88bcd219d3..5d8d1735a1759d5005ed48366f44573307a2ab28 100644 --- a/repository/git_testing.go +++ b/repository/git_testing.go @@ -48,7 +48,7 @@ func SetupReposAndRemote() (repoA, repoB, remote TestedRepo) { repoB = CreateGoGitTestRepo(false) remote = CreateGoGitTestRepo(true) - remoteAddr := "file://" + remote.GetPath() + remoteAddr := remote.GetPath() err := repoA.AddRemote("origin", remoteAddr) if err != nil { diff --git a/repository/gogit.go b/repository/gogit.go index d9421e64b7c53e1f91cd50b3227d173a5d5fd507..dbcf767a3e9c1bc2f71b4d64a637e798b1f007d5 100644 --- a/repository/gogit.go +++ b/repository/gogit.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "os" "os/exec" - stdpath "path" "path/filepath" "sort" "strings" @@ -84,12 +83,12 @@ func detectGitPath(path string) (string, error) { } for { - fi, err := os.Stat(stdpath.Join(path, ".git")) + fi, err := os.Stat(filepath.Join(path, ".git")) if err == nil { if !fi.IsDir() { return "", fmt.Errorf(".git exist but is not a directory") } - return stdpath.Join(path, ".git"), nil + return filepath.Join(path, ".git"), nil } if !os.IsNotExist(err) { // unknown error @@ -117,7 +116,7 @@ func isGitDir(path string) (bool, error) { markers := []string{"HEAD", "objects", "refs"} for _, marker := range markers { - _, err := os.Stat(stdpath.Join(path, marker)) + _, err := os.Stat(filepath.Join(path, marker)) if err == nil { continue } @@ -611,7 +610,7 @@ func (repo *GoGitRepo) GetOrCreateClock(name string) (lamport.Clock, error) { repo.clocksMutex.Lock() defer repo.clocksMutex.Unlock() - p := stdpath.Join(repo.path, clockPath, name+"-clock") + p := filepath.Join(repo.path, clockPath, name+"-clock") c, err = lamport.NewPersistedClock(p) if err != nil { @@ -630,7 +629,7 @@ func (repo *GoGitRepo) getClock(name string) (lamport.Clock, error) { return c, nil } - p := stdpath.Join(repo.path, clockPath, name+"-clock") + p := filepath.Join(repo.path, clockPath, name+"-clock") c, err := lamport.LoadPersistedClock(p) if err == nil { diff --git a/repository/repo_testing.go b/repository/repo_testing.go index 41b3609ef9a3e2e8d34aaf56630b640bde174015..9d397ed90048abd79c4ec83c98571faf0da770a4 100644 --- a/repository/repo_testing.go +++ b/repository/repo_testing.go @@ -1,7 +1,6 @@ package repository import ( - "log" "math/rand" "os" "strings" @@ -31,7 +30,6 @@ func CleanupTestRepos(repos ...Repo) { // fmt.Println("Cleaning repo:", path) err := os.RemoveAll(path) if err != nil { - log.Println(err) if firstErr == nil { firstErr = err } @@ -39,7 +37,7 @@ func CleanupTestRepos(repos ...Repo) { } if firstErr != nil { - log.Fatal(firstErr) + // log.Fatal(firstErr) } }