Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
fix error on AppVeyor
Browse files Browse the repository at this point in the history
terminate all git.exe
  • Loading branch information
mattn committed Jan 26, 2017
1 parent 1b193f4 commit 2d13b91
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions dep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import (
"regexp"
"runtime"
"strings"
"sync"
"testing"
)

var (
exeSuffix string // ".exe" on Windows
mu sync.Mutex
)

func init() {
Expand Down Expand Up @@ -197,6 +199,10 @@ func (tg *testgoData) doRun(args []string) error {

// run runs the test go command, and expects it to succeed.
func (tg *testgoData) run(args ...string) {
if runtime.GOOS == "windows" {
mu.Lock()
defer mu.Unlock()
}
if status := tg.doRun(args); status != nil {
tg.t.Logf("go %v failed unexpectedly: %v", args, status)
tg.t.FailNow()
Expand Down Expand Up @@ -472,6 +478,13 @@ func (tg *testgoData) mustNotExist(path string) {

// cleanup cleans up a test that runs testgo.
func (tg *testgoData) cleanup() {
// NOTE(mattn): It seems that sometimes git.exe is not dead
// when cleanup() is called. But we do not know any way to wait for it.
if runtime.GOOS == "windows" {
mu.Lock()
exec.Command(`taskkill`, `/F`, `/IM`, `git.exe`).Run()
mu.Unlock()
}
if tg.wd != "" {
if err := os.Chdir(tg.wd); err != nil {
// We are unlikely to be able to continue.
Expand Down

0 comments on commit 2d13b91

Please sign in to comment.