Attribute Macro run
#[run]
Expand description
Define an async
function that should run to completion on N
threads.
Number of threads is configured by #[fuchsia_async::run(N)]
, and can also
take 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.
When running tests concurrently the thread pool size will be scaled up by the expected maximum concurrent
test executions (to save wall time) - this pool size can be capped with FASYNC_TEST_MAX_THREADS.
#[fuchsia_async::run(4, 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(4, test)]
async fn test_foo(test_run: usize) {
println!("Test repetition #{}", test_run);
}