Discard fx's own log in tests that build an fx app (closes #230)
check / check (push) Waiting to run
check / check (push) Waiting to run
fxtest.New sends fx's event log to t.Logf. When a start or stop runs past fx's time limit, Start or Stop returns while the hook keeps running in a goroutine, and that goroutine logs to the test after the test has returned, which the race detector reports. Every fxtest.New now passes fx.NopLogger, so nothing fx runs can reach the test. The fxtest.Lifecycle sites are unchanged: they run hooks on the goroutine that calls Start or Stop, which is always the test or its cleanup. Model: opus-5-5
This commit is contained in:
@@ -104,6 +104,10 @@ func newTestEnvWithConfig(
|
||||
|
||||
app := fxtest.New(
|
||||
t,
|
||||
// fx's own log is discarded, not sent to t.Logf: a hook still
|
||||
// running after a start or stop timeout would write there after
|
||||
// the test has returned.
|
||||
fx.NopLogger,
|
||||
fx.Provide(
|
||||
globals.New,
|
||||
logger.New,
|
||||
|
||||
Reference in New Issue
Block a user