fuchsia_async

Attribute Macro run_singlethreaded

#[run_singlethreaded]
Expand description

Define an async function that should run to completion on a single thread.

Takes an optional test argument.

Tests written using this macro can be run repeatedly. The environment variable FASYNC_TEST_REPEAT_COUNT sets the number of repetitions each test will be run for, while the environment variable FASYNC_TEST_MAX_CONCURRENCY bounds the maximum concurrent invocations of each test. If FASYNC_TEST_MAX_CONCURRENCY is set to 0 (the default) no bounds to concurrency are applied. If FASYNC_TEST_TIMEOUT_SECONDS is set, it specifies the maximum duration for one repetition of a test. Multiple threads will be spawned to execute the tests concurrently (to save wall time), up to a maximum of FASYNC_TEST_MAX_THREADS.

#[fuchsia_async::run_singlethreaded(test)]
async fn test_foo() {}

The test can optionally take a usize argument which specifies which repetition of the test is being performed:

#[fuchsia_async::run_singlethreaded(test)]
async fn test_foo(test_run: usize) {
  println!("Test repetition #{}", test_run);
}