1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #22925 from jstarks/fix_integration_test

pkg/integration: Port tests to Windows
This commit is contained in:
Brian Goff 2016-05-24 17:31:43 -04:00
commit 29dbcbad87

View file

@ -14,30 +14,32 @@ import (
) )
func TestIsKilledFalseWithNonKilledProcess(t *testing.T) { func TestIsKilledFalseWithNonKilledProcess(t *testing.T) {
// TODO Windows: Port this test var lsCmd *exec.Cmd
if runtime.GOOS == "windows" { if runtime.GOOS != "windows" {
t.Skip("Needs porting to Windows") lsCmd = exec.Command("ls")
} else {
lsCmd = exec.Command("cmd", "/c", "dir")
} }
lsCmd := exec.Command("ls") err := lsCmd.Run()
lsCmd.Start()
// Wait for it to finish
err := lsCmd.Wait()
if IsKilled(err) { if IsKilled(err) {
t.Fatalf("Expected the ls command to not be killed, was.") t.Fatalf("Expected the ls command to not be killed, was.")
} }
} }
func TestIsKilledTrueWithKilledProcess(t *testing.T) { func TestIsKilledTrueWithKilledProcess(t *testing.T) {
// TODO Windows: Using golang 1.5.3, this seems to hit var longCmd *exec.Cmd
// a bug in go where Process.Kill() causes a panic. if runtime.GOOS != "windows" {
// Needs further investigation @jhowardmsft longCmd = exec.Command("top")
if runtime.GOOS == "windows" { } else {
t.SkipNow() longCmd = exec.Command("powershell", "while ($true) { sleep 1 }")
} }
longCmd := exec.Command("top")
// Start a command // Start a command
longCmd.Start() err := longCmd.Start()
if err != nil {
t.Fatal(err)
}
// Capture the error when *dying* // Capture the error when *dying*
done := make(chan error, 1) done := make(chan error, 1)
go func() { go func() {
@ -46,7 +48,7 @@ func TestIsKilledTrueWithKilledProcess(t *testing.T) {
// Then kill it // Then kill it
longCmd.Process.Kill() longCmd.Process.Kill()
// Get the error // Get the error
err := <-done err = <-done
if !IsKilled(err) { if !IsKilled(err) {
t.Fatalf("Expected the command to be killed, was not.") t.Fatalf("Expected the command to be killed, was not.")
} }