@@ -21,9 +21,8 @@ import (
2121 "os"
2222 "os/exec"
2323 "path/filepath"
24- "runtime"
25- "strings"
2624 "testing"
25+ "time"
2726
2827 "github.com/docker/machine/libmachine"
2928 "github.com/google/go-cmp/cmp"
@@ -226,9 +225,6 @@ func TestDeleteAllProfiles(t *testing.T) {
226225// then tries to execute the tryKillOne function on it;
227226// if after tryKillOne the process still exists, we consider it a failure
228227func TestTryKillOne (t * testing.T ) {
229- if runtime .GOOS == "windows" {
230- t .Skip ("skipping on windows" )
231- }
232228
233229 var waitForSig = []byte (`
234230package main
@@ -246,7 +242,7 @@ func main() {
246242 done := make(chan struct{})
247243 defer close(ch)
248244
249- signal.Notify(ch, syscall.SIGHUP )
245+ signal.Notify(ch, syscall.SIGTERM )
250246 defer signal.Stop(ch)
251247
252248 go func() {
@@ -267,7 +263,7 @@ func main() {
267263 processToKill := exec .Command ("go" , "run" , tmpfile )
268264 err := processToKill .Start ()
269265 if err != nil {
270- t .Fatalf ("while execing child process: %v\n " , err )
266+ t .Fatalf ("while executing child process: %v\n " , err )
271267 }
272268 pid := processToKill .Process .Pid
273269
@@ -280,8 +276,15 @@ func main() {
280276 t .Fatalf ("while trying to kill child proc %d: %v\n " , pid , err )
281277 }
282278
283- // waiting for process to exit
284- if err := processToKill .Wait (); ! strings .Contains (err .Error (), "killed" ) {
285- t .Fatalf ("unable to kill process: %v\n " , err )
279+ done := make (chan error , 1 )
280+ go func () { done <- processToKill .Wait () }()
281+
282+ var waitErr error
283+ select {
284+ case waitErr = <- done :
285+ t .Logf ("child process wait result: %v" , waitErr )
286+ case <- time .After (1 * time .Second ):
287+ t .Fatalf ("timed out waiting for process %d to exit" , pid )
286288 }
289+
287290}
0 commit comments