diff --git a/Cargo.toml b/Cargo.toml index 592aba73f..f4edf3203 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,9 +60,6 @@ webpki-roots = ["dep:webpki-root-certs"] # Use the system's proxy configuration. system-proxy = ["dep:system-configuration", "dep:windows-registry"] -# Deprecated, switch to system-proxy. -macos-system-configuration = ["system-proxy"] - # Optional enable tracing tracing = ["http2/tracing", "dep:tracing"] @@ -163,12 +160,10 @@ hyper-util = { version = "0.1.13", features = [ "server-graceful", "tokio", ] } -log = "0.4" serde = { version = "1.0", features = ["derive"] } flate2 = "1.1.1" zstd = "0.13" brotli = "8.0.0" -doc-comment = "0.3" tokio = { version = "1.0", default-features = false, features = [ "macros", "rt-multi-thread", diff --git a/examples/connect_via_lower_priority_tokio_runtime.rs b/examples/connect_via_lower_priority_tokio_runtime.rs index 3a9e87704..319e4df87 100644 --- a/examples/connect_via_lower_priority_tokio_runtime.rs +++ b/examples/connect_via_lower_priority_tokio_runtime.rs @@ -17,6 +17,9 @@ #[tokio::main] async fn main() -> wreq::Result<()> { + tracing_subscriber::fmt() + .with_max_level(tracing::Level::TRACE) + .init(); background_threadpool::init_background_runtime(); tokio::time::sleep(std::time::Duration::from_millis(10)).await; @@ -83,7 +86,7 @@ mod background_threadpool { *libc::__errno_location() = 0; if libc::nice(10) == -1 && *libc::__errno_location() != 0 { let error = std::io::Error::last_os_error(); - log::error!("failed to set threadpool niceness: {error}"); + tracing::error!("failed to set threadpool niceness: {error}"); } } } @@ -92,7 +95,7 @@ mod background_threadpool { .build() .unwrap_or_else(|e| panic!("cpu heavy runtime failed_to_initialize: {e}")); rt.block_on(async { - log::debug!("starting background cpu-heavy work"); + tracing::debug!("starting background cpu-heavy work"); process_cpu_work().await; }); }) @@ -122,7 +125,7 @@ mod background_threadpool { panic!("background cpu heavy runtime channel is closed") } Err(TrySendError::Full(msg)) => { - log::warn!( + tracing::warn!( "background cpu heavy runtime channel is full, task spawning loop delayed" ); let tx = tx.clone(); diff --git a/src/core/client/conn/http2.rs b/src/core/client/conn/http2.rs index 46e7755f0..24db5d557 100644 --- a/src/core/client/conn/http2.rs +++ b/src/core/client/conn/http2.rs @@ -254,236 +254,3 @@ where } } } - -#[cfg(test)] -mod tests { - use http_body::Body; - - use super::{Builder, Connection, SendRequest}; - use crate::core::{ - error::BoxError, - rt::{Read, Write, bounds::Http2ClientConnExec}, - }; - - pub async fn handshake( - exec: E, - io: T, - ) -> crate::core::Result<(SendRequest, Connection)> - where - T: Read + Write + Unpin, - B: Body + 'static, - B::Data: Send, - B::Error: Into, - E: Http2ClientConnExec + Unpin + Clone, - { - Builder::new(exec).handshake(io).await - } - - #[tokio::test] - #[ignore] // only compilation is checked - async fn send_sync_executor_of_non_send_futures() { - #[derive(Clone)] - struct LocalTokioExecutor; - - impl crate::core::rt::Executor for LocalTokioExecutor - where - F: std::future::Future + 'static, // not requiring `Send` - { - fn execute(&self, fut: F) { - // This will spawn into the currently running `LocalSet`. - tokio::task::spawn_local(fut); - } - } - - #[allow(unused)] - async fn run(io: impl crate::core::rt::Read + crate::core::rt::Write + Unpin + 'static) { - let (_sender, conn) = - handshake::<_, _, http_body_util::Empty>(LocalTokioExecutor, io) - .await - .unwrap(); - - tokio::task::spawn_local(async move { - conn.await.unwrap(); - }); - } - } - - #[tokio::test] - #[ignore] // only compilation is checked - async fn not_send_not_sync_executor_of_not_send_futures() { - #[derive(Clone)] - struct LocalTokioExecutor { - _x: std::marker::PhantomData>, - } - - impl crate::core::rt::Executor for LocalTokioExecutor - where - F: std::future::Future + 'static, // not requiring `Send` - { - fn execute(&self, fut: F) { - // This will spawn into the currently running `LocalSet`. - tokio::task::spawn_local(fut); - } - } - - #[allow(unused)] - async fn run(io: impl crate::core::rt::Read + crate::core::rt::Write + Unpin + 'static) { - let (_sender, conn) = handshake::<_, _, http_body_util::Empty>( - LocalTokioExecutor { - _x: Default::default(), - }, - io, - ) - .await - .unwrap(); - - tokio::task::spawn_local(async move { - conn.await.unwrap(); - }); - } - } - - #[tokio::test] - #[ignore] // only compilation is checked - async fn send_not_sync_executor_of_not_send_futures() { - #[derive(Clone)] - struct LocalTokioExecutor { - _x: std::marker::PhantomData>, - } - - impl crate::core::rt::Executor for LocalTokioExecutor - where - F: std::future::Future + 'static, // not requiring `Send` - { - fn execute(&self, fut: F) { - // This will spawn into the currently running `LocalSet`. - tokio::task::spawn_local(fut); - } - } - - #[allow(unused)] - async fn run(io: impl crate::core::rt::Read + crate::core::rt::Write + Unpin + 'static) { - let (_sender, conn) = handshake::<_, _, http_body_util::Empty>( - LocalTokioExecutor { - _x: Default::default(), - }, - io, - ) - .await - .unwrap(); - - tokio::task::spawn_local(async move { - conn.await.unwrap(); - }); - } - } - - #[tokio::test] - #[ignore] // only compilation is checked - async fn send_sync_executor_of_send_futures() { - #[derive(Clone)] - struct TokioExecutor; - - impl crate::core::rt::Executor for TokioExecutor - where - F: std::future::Future + 'static + Send, - F::Output: Send + 'static, - { - fn execute(&self, fut: F) { - tokio::task::spawn(fut); - } - } - - #[allow(unused)] - async fn run( - io: impl crate::core::rt::Read + crate::core::rt::Write + Send + Unpin + 'static, - ) { - let (_sender, conn) = - handshake::<_, _, http_body_util::Empty>(TokioExecutor, io) - .await - .unwrap(); - - tokio::task::spawn(async move { - conn.await.unwrap(); - }); - } - } - - #[tokio::test] - #[ignore] // only compilation is checked - async fn not_send_not_sync_executor_of_send_futures() { - #[derive(Clone)] - struct TokioExecutor { - // !Send, !Sync - _x: std::marker::PhantomData>, - } - - impl crate::core::rt::Executor for TokioExecutor - where - F: std::future::Future + 'static + Send, - F::Output: Send + 'static, - { - fn execute(&self, fut: F) { - tokio::task::spawn(fut); - } - } - - #[allow(unused)] - async fn run( - io: impl crate::core::rt::Read + crate::core::rt::Write + Send + Unpin + 'static, - ) { - let (_sender, conn) = handshake::<_, _, http_body_util::Empty>( - TokioExecutor { - _x: Default::default(), - }, - io, - ) - .await - .unwrap(); - - tokio::task::spawn_local(async move { - // can't use spawn here because when executor is !Send - conn.await.unwrap(); - }); - } - } - - #[tokio::test] - #[ignore] // only compilation is checked - async fn send_not_sync_executor_of_send_futures() { - #[derive(Clone)] - struct TokioExecutor { - // !Sync - _x: std::marker::PhantomData>, - } - - impl crate::core::rt::Executor for TokioExecutor - where - F: std::future::Future + 'static + Send, - F::Output: Send + 'static, - { - fn execute(&self, fut: F) { - tokio::task::spawn(fut); - } - } - - #[allow(unused)] - async fn run( - io: impl crate::core::rt::Read + crate::core::rt::Write + Send + Unpin + 'static, - ) { - let (_sender, conn) = handshake::<_, _, http_body_util::Empty>( - TokioExecutor { - _x: Default::default(), - }, - io, - ) - .await - .unwrap(); - - tokio::task::spawn_local(async move { - // can't use spawn here because when executor is !Send - conn.await.unwrap(); - }); - } - } -} diff --git a/src/core/proto/h1/io.rs b/src/core/proto/h1/io.rs index ebdbf7dfc..014c5b19d 100644 --- a/src/core/proto/h1/io.rs +++ b/src/core/proto/h1/io.rs @@ -625,40 +625,6 @@ mod tests { use super::*; use crate::core::common::io::Compat; - // #[cfg(feature = "nightly")] - // use test::Bencher; - - /* - impl MemRead for AsyncIo { - fn read_mem(&mut self, len: usize) -> Poll { - let mut v = vec![0; len]; - let n = try_nb!(self.read(v.as_mut_slice())); - Ok(Async::Ready(BytesMut::from(&v[..n]).freeze())) - } - } - */ - - #[tokio::test] - #[ignore] - async fn iobuf_write_empty_slice() { - // TODO(eliza): can i have writev back pls T_T - // // First, let's just check that the Mock would normally return an - // // error on an unexpected write, even if the buffer is empty... - // let mut mock = Mock::new().build(); - // std::future::poll_fn(|cx| { - // Pin::new(&mut mock).poll_write_buf(cx, &mut Cursor::new(&[])) - // }) - // .await - // .expect_err("should be a broken pipe"); - - // // underlying io will return the logic error upon write, - // // so we are testing that the io_buf does not trigger a write - // // when there is nothing to flush - // let mock = Mock::new().build(); - // let mut io_buf = Buffered::<_, Cursor>>::new(mock); - // io_buf.flush().await.expect("should short-circuit flush"); - } - #[cfg(not(miri))] #[tokio::test] async fn parse_reads_until_blocked() { diff --git a/src/lib.rs b/src/lib.rs index e1930472b..b4aa952eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -316,9 +316,6 @@ fn _assert_impls() { assert_sync::(); } -#[cfg(test)] -doc_comment::doctest!("../README.md"); - #[cfg(feature = "multipart")] pub use self::client::multipart; #[cfg(feature = "websocket")]