mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
Check test server availability before using it (#522)
This commit is contained in:
parent
ab5fb624b7
commit
9a8a2b3216
9 changed files with 29 additions and 2 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [0.1.4] - 2025-03-14
|
||||||
|
|
||||||
|
* Enable env_logger for test macro
|
||||||
|
|
||||||
## [0.1.2] - 2021-02-25
|
## [0.1.2] - 2021-02-25
|
||||||
|
|
||||||
* Export runtime from ntex crate
|
* Export runtime from ntex crate
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ntex-macros"
|
name = "ntex-macros"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
description = "ntex proc macros"
|
description = "ntex proc macros"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
authors = ["ntex contributors <team@ntex.rs>"]
|
authors = ["ntex contributors <team@ntex.rs>"]
|
||||||
|
|
|
@ -262,6 +262,7 @@ pub fn rt_test(_: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
quote! {
|
quote! {
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
fn #name() #ret {
|
fn #name() #ret {
|
||||||
|
ntex::util::enable_test_logging();
|
||||||
ntex::rt::System::new("test")
|
ntex::rt::System::new("test")
|
||||||
.block_on(async { #body })
|
.block_on(async { #body })
|
||||||
}
|
}
|
||||||
|
@ -271,6 +272,7 @@ pub fn rt_test(_: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
#[test]
|
#[test]
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
fn #name() #ret {
|
fn #name() #ret {
|
||||||
|
ntex::util::enable_test_logging();
|
||||||
ntex::rt::System::new("test")
|
ntex::rt::System::new("test")
|
||||||
.block_on(async { #body })
|
.block_on(async { #body })
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,9 @@ where
|
||||||
|
|
||||||
let (system, addr, server) = rx.recv().unwrap();
|
let (system, addr, server) = rx.recv().unwrap();
|
||||||
|
|
||||||
|
// wait for server
|
||||||
|
thread::sleep(std::time::Duration::from_millis(50));
|
||||||
|
|
||||||
TestServer {
|
TestServer {
|
||||||
addr,
|
addr,
|
||||||
server,
|
server,
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
* Add neon runtime support
|
* Add neon runtime support
|
||||||
|
|
||||||
|
* Check test server availability before using it
|
||||||
|
|
||||||
* Drop glommio support
|
* Drop glommio support
|
||||||
|
|
||||||
* Drop async-std support
|
* Drop async-std support
|
||||||
|
|
|
@ -83,6 +83,7 @@ pin-project-lite = "0.2"
|
||||||
regex = { version = "1.11", default-features = false, features = ["std"] }
|
regex = { version = "1.11", default-features = false, features = ["std"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
sha-1 = { version = "0.10", optional = true }
|
sha-1 = { version = "0.10", optional = true }
|
||||||
|
env_logger = { version = "0.11", default-features = false }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
nanorand = { version = "0.7", default-features = false, features = [
|
nanorand = { version = "0.7", default-features = false, features = [
|
||||||
"std",
|
"std",
|
||||||
|
@ -112,7 +113,6 @@ brotli2 = { version = "0.3.2", optional = true }
|
||||||
flate2 = { version = "1.0", optional = true }
|
flate2 = { version = "1.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.11"
|
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
time = "0.3"
|
time = "0.3"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
|
|
|
@ -251,6 +251,9 @@ where
|
||||||
|
|
||||||
let (system, server, addr) = rx.recv().unwrap();
|
let (system, server, addr) = rx.recv().unwrap();
|
||||||
|
|
||||||
|
// wait for server
|
||||||
|
thread::sleep(std::time::Duration::from_millis(50));
|
||||||
|
|
||||||
TestServer {
|
TestServer {
|
||||||
addr,
|
addr,
|
||||||
system,
|
system,
|
||||||
|
|
|
@ -123,4 +123,14 @@ pub mod util {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[deprecated]
|
#[deprecated]
|
||||||
pub use std::task::ready;
|
pub use std::task::ready;
|
||||||
|
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub fn enable_test_logging() {
|
||||||
|
if std::env::var("NTEX_NO_TEST_LOG").is_err() {
|
||||||
|
if std::env::var("RUST_LOG").is_err() {
|
||||||
|
std::env::set_var("RUST_LOG", "trace");
|
||||||
|
}
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -704,6 +704,9 @@ where
|
||||||
|
|
||||||
let (system, server, addr) = rx.recv().unwrap();
|
let (system, server, addr) = rx.recv().unwrap();
|
||||||
|
|
||||||
|
// wait for server
|
||||||
|
thread::sleep(std::time::Duration::from_millis(50));
|
||||||
|
|
||||||
let client = {
|
let client = {
|
||||||
let connector = {
|
let connector = {
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue