Skip to content

Fixes: #3828 Init Logger for unit tests #3829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2019

Conversation

the10thWiz
Copy link
Contributor

Add init_log() function which attempts to init logger, and
ignores failure. The function is called at the beginning of
every test and will fail if the logger is already initialized.
The logger must be initialized in every test because cargo runs
the tests in parallel, with no guarantees about the order and time
each starts.

Fixes: #3828

Add `init_log()` function which attempts to init logger, and
ignores failure. The function is called at the beginning of
every test, and will fail if the logger is already initialized.
The logger must be initialized in every test, becuase cargo runs
the tests in parallel, with no garentees about the order and time
each starts.
@topecongiro
Copy link
Contributor

@the10thWiz Thank you for the PR! I was surprised to learn that Rust does not have a way to run the initialization code before each test (there is an RFC for this but there seems to be no progress for so long time: rust-lang/rfcs#1664). Anyhow, the code looks good to me.

@topecongiro topecongiro merged commit e28ae8b into rust-lang:master Oct 4, 2019
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.

Logger not initialized for tests
2 participants