mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Enable test-integration-cli for Windows platform
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
This commit is contained in:
parent
0874f9ab77
commit
f3ed42286e
10 changed files with 281 additions and 232 deletions
59
integration-cli/docker_cli_events_test_unix.go
Normal file
59
integration-cli/docker_cli_events_test_unix.go
Normal file
|
@ -0,0 +1,59 @@
|
|||
// +build !windows
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/kr/pty"
|
||||
)
|
||||
|
||||
// #5979
|
||||
func TestEventsRedirectStdout(t *testing.T) {
|
||||
|
||||
since := time.Now().Unix()
|
||||
|
||||
dockerCmd(t, "run", "busybox", "true")
|
||||
|
||||
defer deleteAllContainers()
|
||||
|
||||
file, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create temp file: %v", err)
|
||||
}
|
||||
defer os.Remove(file.Name())
|
||||
|
||||
command := fmt.Sprintf("%s events --since=%d --until=%d > %s", dockerBinary, since, time.Now().Unix(), file.Name())
|
||||
_, tty, err := pty.Open()
|
||||
if err != nil {
|
||||
t.Fatalf("Could not open pty: %v", err)
|
||||
}
|
||||
cmd := exec.Command("sh", "-c", command)
|
||||
cmd.Stdin = tty
|
||||
cmd.Stdout = tty
|
||||
cmd.Stderr = tty
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatalf("run err for command %q: %v", command, err)
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
for _, c := range scanner.Text() {
|
||||
if unicode.IsControl(c) {
|
||||
t.Fatalf("found control character %v", []byte(string(c)))
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
t.Fatalf("Scan err for command %q: %v", command, err)
|
||||
}
|
||||
|
||||
logDone("events - redirect stdout")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue