LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
620 stars 70 forks source link

Error logs in actix_rt tests from bastion #29

Closed crash-g closed 3 years ago

crash-g commented 3 years ago

Not sure exactly in which crate the issue is. Anyway, when I run tests with logs on I always get error logs on shutdown, but only if actix_web is one of the dependencies.

Short example to reproduce the issue:

#[actix_rt::test]
pub async fn test_logs() {
    std::env::set_var("RUST_LOG", "info");
    env_logger::init();
    wiremock::MockServer::start().await;
    log::info!("Test finished");
}

Cargo.toml:

[dependencies]
actix-rt = "1.1.1"
actix-web = "3.3.2"    # This is not necessary to compile but if removed the error logs disappear
log = "0.4.11"
env_logger = "0.8.2"

[dev-dependencies]
wiremock = "0.3.0"

Output:

......
[2020-12-18T19:45:02Z INFO  test] Test finished
[2020-12-18T19:45:02Z ERROR bastion::child] Child(2de2e378-b935-4d46-adcc-8c08289088cc): Couldn't handle message 
[2020-12-18T19:45:02Z ERROR bastion::child] Child(01c0099e-8f0f-47b5-a1f8-4841bd79717d): Couldn't handle message

However, if using tokio there are no error logs.

Same test as before but with the #[tokio::test] annotation and Cargo.toml:

[dependencies]
log = "0.4.11"
env_logger = "0.8.2"
tokio = { version = "0.3", features = ["rt-multi-thread", "macros"] }

[dev-dependencies]
wiremock = "0.3.0"

Thanks!

LukeMathWalker commented 3 years ago

Can you test again using the latest wiremock version - 0.4.0-alpha.2?

crash-g commented 3 years ago

Latest version solves the issue, I see that bastion is not a dependency anymore so it would have been surprising to still get error logs from it. Thanks!