1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-24 00:01:11 +01:00

fix test macro in presence of other imports named test (#399)

This commit is contained in:
Rob Ede 2021-10-19 16:13:13 +01:00 committed by GitHub
parent ca77d8d835
commit 47f278b17a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 5 deletions

View File

@ -22,4 +22,4 @@ ci-test-rt-linux = " hack --feature-powerset test --package=actix-rt --li
ci-test-server-linux = "hack --feature-powerset test --package=actix-server --lib --tests --no-fail-fast -- --nocapture" ci-test-server-linux = "hack --feature-powerset test --package=actix-server --lib --tests --no-fail-fast -- --nocapture"
# test lower msrv # test lower msrv
ci-test-lower-msrv = "hack --workspace --feature-powerset test --lib --tests --no-fail-fast -- --nocapture" ci-test-lower-msrv = "hack --workspace --exclude=actix-server --exclude=actix-tls --feature-powerset test --lib --tests --no-fail-fast -- --nocapture"

View File

@ -3,6 +3,12 @@
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
## 0.2.3 - 2021-10-19
* Fix test macro in presence of other imports named "test". [#399]
[#399]: https://github.com/actix/actix-net/pull/399
## 0.2.2 - 2021-10-14 ## 0.2.2 - 2021-10-14
* Improve error recovery potential when macro input is invalid. [#391] * Improve error recovery potential when macro input is invalid. [#391]
* Allow custom `System`s on test macro. [#391] * Allow custom `System`s on test macro. [#391]

View File

@ -1,9 +1,10 @@
[package] [package]
name = "actix-macros" name = "actix-macros"
version = "0.2.2" version = "0.2.3"
authors = [ authors = [
"Nikolay Kim <fafhrd91@gmail.com>", "Nikolay Kim <fafhrd91@gmail.com>",
"Ibraheem Ahmed <ibrah1440@gmail.com>", "Ibraheem Ahmed <ibrah1440@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
] ]
description = "Macros for Actix system and runtime" description = "Macros for Actix system and runtime"
repository = "https://github.com/actix/actix-net.git" repository = "https://github.com/actix/actix-net.git"

View File

@ -139,9 +139,9 @@ pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
sig.asyncness = None; sig.asyncness = None;
let missing_test_attr = if has_test_attr { let missing_test_attr = if has_test_attr {
quote!() quote! {}
} else { } else {
quote!(#[test]) quote! { #[::core::prelude::v1::test] }
}; };
let mut system = syn::parse_str::<syn::Path>("::actix_rt::System").unwrap(); let mut system = syn::parse_str::<syn::Path>("::actix_rt::System").unwrap();

View File

@ -23,7 +23,7 @@ macros = ["actix-macros"]
io-uring = ["tokio-uring"] io-uring = ["tokio-uring"]
[dependencies] [dependencies]
actix-macros = { version = "0.2.0", optional = true } actix-macros = { version = "0.2.3", optional = true }
futures-core = { version = "0.3", default-features = false } futures-core = { version = "0.3", default-features = false }
tokio = { version = "1.5.1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] } tokio = { version = "1.5.1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }

View File

@ -0,0 +1,17 @@
//! Checks that test macro does not cause problems in the presence of imports named "test" that
//! could be either a module with test items or the "test with runtime" macro itself.
//!
//! Before actix/actix-net#399 was implemented, this macro was running twice. The first run output
//! `#[test]` and it got run again and since it was in scope.
//!
//! Prevented by using the fully-qualified test marker (`#[::core::prelude::v1::test]`).
#![cfg(feature = "macros")]
use actix_rt::time as test;
#[actix_rt::test]
async fn test_naming_conflict() {
use test as time;
time::sleep(std::time::Duration::from_millis(2)).await;
}

View File

@ -1,6 +1,7 @@
# Changes # Changes
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
* Minimum supported Rust version (MSRV) is now 1.52.
## 2.0.0-beta.6 - 2021-10-11 ## 2.0.0-beta.6 - 2021-10-11

View File

@ -1,6 +1,7 @@
# Changes # Changes
## Unreleased - 2021-xx-xx ## Unreleased - 2021-xx-xx
* Minimum supported Rust version (MSRV) is now 1.52.
## 3.0.0-beta.5 - 2021-03-29 ## 3.0.0-beta.5 - 2021-03-29