Skip to content

Conversation

jebrosen
Copy link
Contributor

@jebrosen jebrosen commented May 7, 2020

tokio::test and related macros now use the absolute path ::core::prelude::v1::test to refer to the built-in test macro.

This absolute path was introduced in rust-lang/rust#62086.

Motivation

The following example currently fails due to shadowing of the test macro (playground):

use tokio::test;

#[test]
async fn mytest() { }
 Compiling playground v0.0.1 (/playground)
error: the async keyword is missing from the function declaration
 --> src/lib.rs:4:7
  |
4 | async fn mytest() { }
  |       ^^

error: the async keyword is missing from the function declaration
 --> src/lib.rs:4:7
  |
4 | async fn mytest() { }
  |       ^^

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels May 8, 2020
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is not a breaking change?

@jebrosen
Copy link
Contributor Author

jebrosen commented May 9, 2020

I assume this is not a breaking change?

I guess that depends on whether or not this is supposed to be supported today:

use some_other_lib::test;

#[tokio::test]
async fn some_test() { }

Currently, the #[some_other_lib::test] attribute would be used instead of #[test] from core - this PR would break that, by always using #[test] from core.

@LucioFranco
Copy link
Member

seems fine to me

@Darksonn
Copy link
Contributor

CI appears to be stuck, and I can't restart it.

`tokio::test` and related macros now use the absolute path
`::core::prelude::v1::test` to refer to the built-in `test` macro.

This absolute path was introduced in rust-lang/rust#62086.
@jebrosen jebrosen force-pushed the test-unambiguous branch from 2077109 to a7e6771 Compare May 11, 2020 20:16
@jebrosen
Copy link
Contributor Author

The CI failures (on Windows) appear to be unrelated to this change:

test threaded_scheduler_1_thread::runtime_in_thread_local ... test threaded_scheduler_1_thread::runtime_in_thread_local has been running for over 60 seconds
test threaded_scheduler_1_thread::shutdown_timeout ... test threaded_scheduler_1_thread::shutdown_timeout has been running for over 60 seconds

They look familiar, but I don't know off the top of my head which other PR did this.

@Darksonn Darksonn merged commit 1cc0168 into tokio-rs:master May 12, 2020
jensim pushed a commit to jensim/tokio that referenced this pull request Jun 7, 2020
tokio-rs#2503)

`tokio::test` and related macros now use the absolute path
`::core::prelude::v1::test` to refer to the built-in `test` macro.

This absolute path was introduced in rust-lang/rust#62086.
@jebrosen jebrosen deleted the test-unambiguous branch June 17, 2020 20:30
@IThawk
Copy link

IThawk commented Jun 24, 2020

I want to know how to test async function.

@Darksonn
Copy link
Contributor

Please open a new discussion if you have a question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tokio Area: The main tokio crate C-bug Category: This is a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants