mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-14 01:11:01 +00:00
tstest/integration/vms: log to t.Logf directly (#2147)
Previously we used t.Logf indirectly via package log. This worked, but it was not ideal for our needs. It could cause the streams of output to get crossed. This change uses a logger.FuncWriter every place log.Output was previously used, which will more correctly write log information to the right test output stream. Signed-off-by: Christine Dodrill <xe@tailscale.com>
This commit is contained in:
parent
f482321f67
commit
e0f0d10672
@ -43,6 +43,7 @@ import (
|
||||
"tailscale.com/tstest"
|
||||
"tailscale.com/tstest/integration"
|
||||
"tailscale.com/tstest/integration/testcontrol"
|
||||
"tailscale.com/types/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -299,8 +300,8 @@ func run(t *testing.T, dir, prog string, args ...string) {
|
||||
tstest.FixLogs(t)
|
||||
|
||||
cmd := exec.Command(prog, args...)
|
||||
cmd.Stdout = log.Writer()
|
||||
cmd.Stderr = log.Writer()
|
||||
cmd.Stdout = logger.FuncWriter(t.Logf)
|
||||
cmd.Stderr = logger.FuncWriter(t.Logf)
|
||||
cmd.Dir = dir
|
||||
if err := cmd.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
@ -444,8 +445,8 @@ func mkVM(t *testing.T, n int, d Distro, sshKey, hostURL, tdir string) func() {
|
||||
t.Logf("running: qemu-system-x86_64 %s", strings.Join(args, " "))
|
||||
|
||||
cmd := exec.Command("qemu-system-x86_64", args...)
|
||||
cmd.Stdout = log.Writer()
|
||||
cmd.Stderr = log.Writer()
|
||||
cmd.Stdout = logger.FuncWriter(t.Logf)
|
||||
cmd.Stderr = logger.FuncWriter(t.Logf)
|
||||
err = cmd.Start()
|
||||
|
||||
if err != nil {
|
||||
@ -557,9 +558,6 @@ func TestVMIntegrationEndToEnd(t *testing.T) {
|
||||
loginServer := fmt.Sprintf("http://%s", ln.Addr())
|
||||
t.Logf("loginServer: %s", loginServer)
|
||||
|
||||
tstest.FixLogs(t)
|
||||
defer tstest.UnfixLogs(t)
|
||||
|
||||
ramsem := semaphore.NewWeighted(int64(*vmRamLimit))
|
||||
bins := integration.BuildTestBinaries(t)
|
||||
|
||||
@ -651,11 +649,11 @@ func testDistro(t *testing.T, loginServer string, d Distro, signer ssh.Signer, i
|
||||
|
||||
e, _, err := expect.SpawnSSH(cli, timeout,
|
||||
expect.Verbose(true),
|
||||
expect.VerboseWriter(log.Writer()),
|
||||
expect.VerboseWriter(logger.FuncWriter(t.Logf)),
|
||||
|
||||
// // NOTE(Xe): if you get a timeout, uncomment this line to have the raw
|
||||
// output be sent to the test log quicker.
|
||||
//expect.Tee(nopWriteCloser{log.Writer()}),
|
||||
//expect.Tee(nopWriteCloser{logger.FuncWriter(t.Logf)}),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("%d: can't register a shell session: %v", port, err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user