macros: allow selecting runtime in tokio::test attr (#1620)

In the past, it was not possible to choose to use the multi-threaded
tokio `Runtime` in tests, which meant that any test that transitively
used `executor::threadpool::blocking` would fail with

```
'blocking' annotation used from outside the context of a thread pool
```

This patch adds a runtime annotation attribute to `#[tokio::test]` just
like `#[tokio::main]` has, which lets users opt in to the threadpool
runtime over `current_thread` (the default).
This commit is contained in:
Jon Gjengset
2019-10-02 10:58:34 -07:00
committed by Carl Lerche
parent 9e1eef829a
commit c78c9168d7
2 changed files with 60 additions and 18 deletions
@@ -4,7 +4,7 @@ error: the async keyword is missing from the function declaration
4 | fn main_is_not_async() {}
| ^^
error: Unknown attribute foo is specified
error: Unknown attribute foo is specified; expected `single_thread` or `multi_thread`
--> $DIR/macros_invalid_input.rs:6:15
|
6 | #[tokio::main(foo)]
@@ -28,7 +28,7 @@ error: the test function cannot accept arguments
16 | async fn test_fn_has_args(_x: u8) {}
| ^^^^^^
error: unexpected token
error: Unknown attribute foo is specified; expected `single_thread` or `multi_thread`
--> $DIR/macros_invalid_input.rs:18:15
|
18 | #[tokio::test(foo)]