Skip to content

Fix tests error log by enabling LogPlugin only once#713

Merged
dyc3 merged 1 commit into
valence-rs:mainfrom
Bowen951209:fix-test-log
Jun 15, 2026
Merged

Fix tests error log by enabling LogPlugin only once#713
dyc3 merged 1 commit into
valence-rs:mainfrom
Bowen951209:fix-test-log

Conversation

@Bowen951209

@Bowen951209 Bowen951209 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Objective

Fixes #712.
When running tests, there are many:

ERROR bevy_log: Could not set global logger and tracing subscriber as they are already set. Consider disabling LogPlugin.

Because tests usually run in the same context, but
each test tries to set logger and tracing subscriber,
which should be only set once in a context.

Solution

This commit takes the approach of only setting up
[LogPlugin] once in the whole test run, rather than
removing [LogPlugin] entirely for all test apps.

Although there are no logs in Valence's existing tests
currently, keeping the logger available is useful for
debugging single tests in the future.

Also note by calling testing::add_plugins,
example_test_server_tick_increment() and
idle_update now disables [NetworkPlugin],
which should be okay in these tests.

@dyc3

dyc3 commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

CI is broken

@Bowen951209

Copy link
Copy Markdown
Contributor Author

CI is broken

Yeah. But it doesn't look like it's due to this change.
Should I fix it?

@dyc3

dyc3 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Unfortunately I dont have permissions to merge anything if CI isn't passing. So either this PR or a new PR to fix it is fine.

@Bowen951209

Copy link
Copy Markdown
Contributor Author

Unfortunately I dont have permissions to merge anything if CI isn't passing. So either this PR or a new PR to fix it is fine.

I have opened a CI fix PR in #714.

@dyc3

dyc3 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Merged, go ahead and rebase :)

@Bowen951209

Copy link
Copy Markdown
Contributor Author

I'll deal with the test failure tomorrow.

@dyc3

dyc3 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Could just be a flaky test

@Bowen951209

Copy link
Copy Markdown
Contributor Author

Hmm... Testing directly on my environment passes, but running on CI environment with act locally fails on tests::inventory::dragging_items, too.

Also, I noticed that benches have the same issue on Could not set global logger and tracing subscriber.

@Bowen951209

Copy link
Copy Markdown
Contributor Author

Could just be a flaky test

Job succeed on another local act run.
It should be indeed a flaky test.

When running tests, there are many:

```
ERROR bevy_log: Could not set global logger and tracing subscriber as they are already set. Consider disabling LogPlugin.
```

Because tests usually run in the same context, but
each test tries to set logger and tracing subscriber,
which should be only set once in a context.

This commit takes the approach of only setting up
[LogPlugin] once in the whole test run, rather than
removing [LogPlugin] entirely for all test apps.

Although there are no logs in Valence's existing tests
currently, keeping the logger available is useful for
debugging single tests in the future.

Also note by calling `testing::add_plugins`,
`example_test_server_tick_increment()` and
`idle_update` now disables [NetworkPlugin],
which should be okay in these tests.

Ref <valence-rs#712>
@dyc3 dyc3 merged commit c4177ca into valence-rs:main Jun 15, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global logger and tracing subscribers are set multiple times in tests

2 participants