ntest icon indicating copy to clipboard operation
ntest copied to clipboard

#[ntest::timeout()] takes control of main thread away from the test

Open StevenLove opened this issue 10 months ago • 1 comments

I'm running some unharnessed integration tests on a GUI that look like this

#[ntest::timeout(1000)]
fn main(){

  launch_gui(); // panics if not run on the main thread 

}

Right now, the way that timeout is implemented, my test always panics because the body of my test is run inside a spawned thread and not the main thread.

I understand that it may be impossible to satisfy my requirements because if the timer is on a spawned thread and panics it won't impact the main thread, so we can't merely reverse the roles here.

A potential workaround is to call std::process::exit(1) from the spawned thread, but killing the process prevents any remaining tests from running.

Additional context

  • I'm using Dioxus as the GUI that requires the main thread

StevenLove avatar Mar 01 '25 18:03 StevenLove

Even if my problem cannot be solved, it may be useful to leave this post here as documentation for others.

StevenLove avatar Mar 01 '25 18:03 StevenLove