Pārlūkot izejas kodu

[unit tests] Cleanly kill all containers before nuking a temporary runtime

Solomon Hykes 12 gadi atpakaļ
vecāks
revīzija
8f9e454241
1 mainītis faili ar 10 papildinājumiem un 0 dzēšanām
  1. 10 0
      runtime_test.go

+ 10 - 0
runtime_test.go

@@ -6,6 +6,7 @@ import (
 	"os"
 	"os"
 	"os/exec"
 	"os/exec"
 	"os/user"
 	"os/user"
+	"sync"
 	"testing"
 	"testing"
 )
 )
 
 
@@ -17,6 +18,15 @@ var unitTestStoreBase string
 var srv *Server
 var srv *Server
 
 
 func nuke(runtime *Runtime) error {
 func nuke(runtime *Runtime) error {
+	var wg sync.WaitGroup
+	for _, container := range runtime.List() {
+		wg.Add(1)
+		go func() {
+			container.Kill()
+			wg.Add(-1)
+		}()
+	}
+	wg.Wait()
 	return os.RemoveAll(runtime.root)
 	return os.RemoveAll(runtime.root)
 }
 }