pkg/integration: Port tests to Windows

Signed-off-by: John Starks <jostarks@microsoft.com>
This commit is contained in:
John Starks 2016-05-23 11:15:29 -07:00
parent 52debcd58a
commit 8fc825364a

View file

@ -14,30 +14,32 @@ import (
)
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) {
t.Fatalf("Expected the ls command to not be killed, was.")
}
}
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
longCmd.Start()
err := longCmd.Start()
if err != nil {
t.Fatal(err)
}
// Capture the error when *dying*
done := make(chan error, 1)
go func() {
@ -46,7 +48,7 @@ func TestIsKilledTrueWithKilledProcess(t *testing.T) {
// Then kill it
longCmd.Process.Kill()
// Get the error
err := <-done
err = <-done
if !IsKilled(err) {
t.Fatalf("Expected the command to be killed, was not.")
}