Skip to content

Commit 47f278b

Browse files
authored
fix test macro in presence of other imports named test (#399)
1 parent ca77d8d commit 47f278b

File tree

8 files changed

+31
-5
lines changed

8 files changed

+31
-5
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ ci-test-rt-linux = " hack --feature-powerset test --package=actix-rt --li
2222
ci-test-server-linux = "hack --feature-powerset test --package=actix-server --lib --tests --no-fail-fast -- --nocapture"
2323

2424
# test lower msrv
25-
ci-test-lower-msrv = "hack --workspace --feature-powerset test --lib --tests --no-fail-fast -- --nocapture"
25+
ci-test-lower-msrv = "hack --workspace --exclude=actix-server --exclude=actix-tls --feature-powerset test --lib --tests --no-fail-fast -- --nocapture"

actix-macros/CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
## Unreleased - 2021-xx-xx
44

55

6+
## 0.2.3 - 2021-10-19
7+
* Fix test macro in presence of other imports named "test". [#399]
8+
9+
[#399]: https://github.com/actix/actix-net/pull/399
10+
11+
612
## 0.2.2 - 2021-10-14
713
* Improve error recovery potential when macro input is invalid. [#391]
814
* Allow custom `System`s on test macro. [#391]

actix-macros/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[package]
22
name = "actix-macros"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
authors = [
55
"Nikolay Kim <fafhrd91@gmail.com>",
66
"Ibraheem Ahmed <ibrah1440@gmail.com>",
7+
"Rob Ede <robjtede@icloud.com>",
78
]
89
description = "Macros for Actix system and runtime"
910
repository = "https://github.com/actix/actix-net.git"

actix-macros/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ pub fn test(args: TokenStream, item: TokenStream) -> TokenStream {
139139
sig.asyncness = None;
140140

141141
let missing_test_attr = if has_test_attr {
142-
quote!()
142+
quote! {}
143143
} else {
144-
quote!(#[test])
144+
quote! { #[::core::prelude::v1::test] }
145145
};
146146

147147
let mut system = syn::parse_str::<syn::Path>("::actix_rt::System").unwrap();

actix-rt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ macros = ["actix-macros"]
2323
io-uring = ["tokio-uring"]
2424

2525
[dependencies]
26-
actix-macros = { version = "0.2.0", optional = true }
26+
actix-macros = { version = "0.2.3", optional = true }
2727

2828
futures-core = { version = "0.3", default-features = false }
2929
tokio = { version = "1.5.1", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//! Checks that test macro does not cause problems in the presence of imports named "test" that
2+
//! could be either a module with test items or the "test with runtime" macro itself.
3+
//!
4+
//! Before actix/actix-net#399 was implemented, this macro was running twice. The first run output
5+
//! `#[test]` and it got run again and since it was in scope.
6+
//!
7+
//! Prevented by using the fully-qualified test marker (`#[::core::prelude::v1::test]`).
8+
9+
#![cfg(feature = "macros")]
10+
11+
use actix_rt::time as test;
12+
13+
#[actix_rt::test]
14+
async fn test_naming_conflict() {
15+
use test as time;
16+
time::sleep(std::time::Duration::from_millis(2)).await;
17+
}

actix-server/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changes
22

33
## Unreleased - 2021-xx-xx
4+
* Minimum supported Rust version (MSRV) is now 1.52.
45

56

67
## 2.0.0-beta.6 - 2021-10-11

actix-tls/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changes
22

33
## Unreleased - 2021-xx-xx
4+
* Minimum supported Rust version (MSRV) is now 1.52.
45

56

67
## 3.0.0-beta.5 - 2021-03-29

0 commit comments

Comments
 (0)