Skip to content

Commit 5f3ef95

Browse files
committed
itest: separate tapd logs from itest
1 parent c2b0a37 commit 5f3ef95

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

itest/tapd_harness.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
190190
}
191191

192192
tapCfg := tapcfg.DefaultConfig()
193-
tapCfg.LogDir = "."
193+
tapCfg.LogDir = *logDir
194194
tapCfg.MaxLogFiles = 99
195195
tapCfg.MaxLogFileSize = 999
196196

itest/test_harness.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"flag"
66
"fmt"
7+
"path/filepath"
78
"testing"
89
"time"
910

@@ -47,6 +48,10 @@ var (
4748
// integration test output.
4849
logLevel = flag.String("loglevel", "info", "Set the log level of the "+
4950
"integration test output")
51+
52+
// logDir is the directory for tapd and test logs.
53+
// We hardcode this to match the Makefile's -logdir=regtest flag.
54+
logDir = &[]string{"regtest"}[0]
5055
)
5156

5257
const (
@@ -201,12 +206,18 @@ func (h *harnessTest) shutdown(_ *testing.T) error {
201206
func (h *harnessTest) setupLogging() {
202207
h.logWriter = build.NewRotatingLogWriter()
203208

209+
// Initialize the log rotator with a file in the log directory.
204210
logConfig := build.DefaultLogConfig()
211+
// Disable console logging to avoid mixing with test output
212+
logConfig.Console.Disable = true
213+
logFile := filepath.Join(*logDir, "tapd.log")
214+
err := h.logWriter.InitLogRotator(logConfig.File, logFile)
215+
require.NoError(h.t, err)
216+
205217
h.logMgr = build.NewSubLoggerManager(
206218
build.NewDefaultLogHandlers(logConfig, h.logWriter)...,
207219
)
208220

209-
var err error
210221
h.interceptor, err = signal.Intercept()
211222
require.NoError(h.t, err)
212223

0 commit comments

Comments
 (0)