Skip to content

Opening a window from a test prevents libtest from outputting the test result #84137

New issue

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

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

Already on GitHub? # to your account

Closed
dzfranklin opened this issue Apr 10, 2021 · 4 comments
Closed
Labels
A-libtest Area: `#[test]` / the `test` library

Comments

@dzfranklin
Copy link

Problem
If I spawn a window in a test I don't see the line test tests::foo ... ok. I know the test runs because it is included in the number of passed tests.

Steps

  • Spawn a window in a test
  • Run cargo test

Actual result:

running 2 tests
test tests::without_winit ... ok
   Doc-tests cargo_test_winit_repro

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Expected result:

running 2 tests
test tests::with_winit ... ok
test tests::without_winit ... ok
   Doc-tests cargo_test_winit_repro

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

I've created a minimal crate that reproduces this issue.

Notes

Output of cargo version: cargo 1.52.0-nightly (90691f2bf 2021-03-16)
I've seen this result on Linux & Windows.

@ehuss ehuss transferred this issue from rust-lang/cargo Apr 12, 2021
@ehuss ehuss changed the title Opening a window from a test prevents cargo from outputting the test result Opening a window from a test prevents libtest from outputting the test result Apr 12, 2021
@ehuss
Copy link
Contributor

ehuss commented Apr 12, 2021

Transferred to rust-lang/rust as this is an issue with libtest. libtest is the test harness which is responsible for running and reporting tests.

I don't have any specific ideas what could cause this. I imagine winit may be interfering somehow with stdout, though it is hard to say.

@ghost
Copy link

ghost commented Apr 12, 2021

I think this is because EventLoop::run exits the process directly.

@dzfranklin
Copy link
Author

That makes sense. I had assumed the same thread printed all the output lines. I suppose this is a wontfix then?

@Enselic
Copy link
Member

Enselic commented Dec 19, 2023

Triage: let's close as duplicate to #67650 which is a about running each test in its own process, which in practice fixes this issue.

@Enselic Enselic closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-libtest Area: `#[test]` / the `test` library
Projects
Development

No branches or pull requests

4 participants