Browse Source

pkg/integration: Port tests to Windows

Signed-off-by: John Starks <jostarks@microsoft.com>
John Starks 9 years ago
parent
commit
8fc825364a
1 changed files with 17 additions and 15 deletions
  1. 17 15
      pkg/integration/utils_test.go

+ 17 - 15
pkg/integration/utils_test.go

@@ -14,30 +14,32 @@ import (
 )
 )
 
 
 func TestIsKilledFalseWithNonKilledProcess(t *testing.T) {
 func TestIsKilledFalseWithNonKilledProcess(t *testing.T) {
-	// TODO Windows: Port this test
-	if runtime.GOOS == "windows" {
-		t.Skip("Needs porting to Windows")
+	var lsCmd *exec.Cmd
+	if runtime.GOOS != "windows" {
+		lsCmd = exec.Command("ls")
+	} else {
+		lsCmd = exec.Command("cmd", "/c", "dir")
 	}
 	}
 
 
-	lsCmd := exec.Command("ls")
-	lsCmd.Start()
-	// Wait for it to finish
-	err := lsCmd.Wait()
+	err := lsCmd.Run()
 	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
-	// a bug in go where Process.Kill() causes a panic.
-	// Needs further investigation @jhowardmsft
-	if runtime.GOOS == "windows" {
-		t.SkipNow()
+	var longCmd *exec.Cmd
+	if runtime.GOOS != "windows" {
+		longCmd = exec.Command("top")
+	} else {
+		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.")
 	}
 	}