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

Commit 2d13b91

Browse files
committed
fix error on AppVeyor
terminate all git.exe
1 parent 1b193f4 commit 2d13b91

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

dep_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ import (
1515
"regexp"
1616
"runtime"
1717
"strings"
18+
"sync"
1819
"testing"
1920
)
2021

2122
var (
2223
exeSuffix string // ".exe" on Windows
24+
mu sync.Mutex
2325
)
2426

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

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

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

0 commit comments

Comments
 (0)