Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ var (
// Also disables parallelism in tests.
var InprocessMode bool

// lines with this prefix are not recorded in output.txt but logged instead
const TestLogPrefix = "TESTLOG: "

func init() {
flag.BoolVar(&InprocessMode, "inprocess", false, "Run CLI in the same process as test (for debugging)")
flag.BoolVar(&KeepTmp, "keeptmp", false, "Do not delete TMP directory after run")
Expand Down Expand Up @@ -1265,14 +1268,20 @@ func runWithLog(t *testing.T, cmd *exec.Cmd, out *os.File, tail bool) (string, e
if tail {
msg := strings.TrimRight(line, "\n")
if len(msg) > 0 {
d := time.Since(start)
t.Logf("%2d.%03d %s", d/time.Second, (d%time.Second)/time.Millisecond, msg)
logWithDurationSince(t, start, msg)
}
}
if len(line) > 0 {
mostRecentLine = line
_, err = out.WriteString(line)
require.NoError(t, err)
if strings.HasPrefix(line, TestLogPrefix) {
// if tail is true, we already logged it above
if !tail {
logWithDurationSince(t, start, strings.TrimRight(line, "\n"))
}
} else {
_, err = out.WriteString(line)
require.NoError(t, err)
}
}
if err == io.EOF {
break
Expand All @@ -1289,6 +1298,11 @@ func runWithLog(t *testing.T, cmd *exec.Cmd, out *os.File, tail bool) (string, e
return skipReason, <-processErrCh
}

func logWithDurationSince(t *testing.T, start time.Time, msg string) {
d := time.Since(start)
t.Logf("%2d.%03d %s", d/time.Second, (d%time.Second)/time.Millisecond, msg)
}

func getCloudEnvBase(cloudEnv string) string {
switch cloudEnv {
// no idea why, but
Expand Down
5 changes: 5 additions & 0 deletions acceptance/selftest/testlog/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
1 change: 1 addition & 0 deletions acceptance/selftest/testlog/script
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
echo "TESTLOG: this is logged, not saved to output.txt"