1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
diff --git a/src/server/conn/auto/mod.rs b/src/server/conn/auto/mod.rs
index 7b887ce..1c43643 100644
--- a/src/server/conn/auto/mod.rs
+++ b/src/server/conn/auto/mod.rs
@@ -80,7 +80,7 @@ impl<E> Builder<E> {
///
/// # Example
///
- /// ```
+ /// ```ignore
/// use hyper_util::{
/// rt::TokioExecutor,
/// server::conn::auto,
@@ -1125,7 +1125,7 @@ impl<E> Http2Builder<'_, E> {
}
}
-#[cfg(test)]
+#[cfg(all(test, feature = "tokio"))]
mod tests {
use crate::{
rt::{TokioExecutor, TokioIo},
diff --git a/tests/legacy_client.rs b/tests/legacy_client.rs
index f0ff90c..e153e23 100644
--- a/tests/legacy_client.rs
+++ b/tests/legacy_client.rs
@@ -1,3 +1,9 @@
+#![cfg(all(
+ // eponymous of this test module
+ feature = "client-legacy",
+ // $crate::client::legacy::Client
+ any(feature = "http1", feature = "http2"),
+))]
mod test_utils;
use std::io::{Read, Write};
@@ -20,8 +26,8 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
use hyper::body::Bytes;
use hyper::body::Frame;
use hyper::Request;
-use hyper_util::client::legacy::connect::{capture_connection, HttpConnector};
-use hyper_util::client::legacy::Client;
+use hyper_util::client::legacy::{connect::{capture_connection, HttpConnector}, Client };
+#[cfg(feature = "tokio")]
use hyper_util::rt::{TokioExecutor, TokioIo};
use test_utils::{DebugConnector, DebugStream};
@@ -39,6 +45,7 @@ fn s(buf: &[u8]) -> &str {
#[cfg(not(miri))]
#[test]
+#[cfg(feature = "tokio")]
fn drop_body_before_eof_closes_connection() {
// https://github.com/hyperium/hyper/issues/1353
let _ = pretty_env_logger::try_init();
@@ -87,6 +94,7 @@ fn drop_body_before_eof_closes_connection() {
#[cfg(not(miri))]
#[tokio::test]
+#[cfg(feature = "tokio")]
async fn drop_client_closes_idle_connections() {
let _ = pretty_env_logger::try_init();
@@ -883,6 +891,7 @@ fn client_http2_upgrade() {
#[cfg(not(miri))]
#[test]
+#[cfg(feature = "tokio")]
fn alpn_h2() {
use http::Response;
use hyper::service::service_fn;
diff --git a/tests/proxy.rs b/tests/proxy.rs
index 95f4bc2..5135d47 100644
--- a/tests/proxy.rs
+++ b/tests/proxy.rs
@@ -1,3 +1,4 @@
+#![cfg(all(feature = "client-legacy",))]
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{TcpListener, TcpStream};
use tower_service::Service;
diff --git a/tests/test_utils/mod.rs b/tests/test_utils/mod.rs
index df3a65d..0f434f6 100644
--- a/tests/test_utils/mod.rs
+++ b/tests/test_utils/mod.rs
@@ -2,20 +2,26 @@ use std::pin::Pin;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
+#[cfg(feature = "client")]
use futures_channel::mpsc;
use futures_util::task::{Context, Poll};
use futures_util::Future;
use futures_util::TryFutureExt;
use hyper::Uri;
use tokio::io::{self, AsyncRead, AsyncWrite, ReadBuf};
+#[cfg(feature = "tokio")]
use tokio::net::TcpStream;
use hyper::rt::ReadBufCursor;
-use hyper_util::client::legacy::connect::HttpConnector;
-use hyper_util::client::legacy::connect::{Connected, Connection};
+#[cfg(feature = "client-legacy")]
+use hyper_util::client::legacy::connect::{HttpConnector, Connected, Connection};
+#[cfg(feature = "tokio")]
use hyper_util::rt::TokioIo;
+#[cfg(feature = "client-legacy")]
+mod debug_connector {
+use super::*;
#[derive(Clone)]
pub struct DebugConnector {
pub http: HttpConnector,
@@ -71,12 +77,18 @@ impl tower_service::Service<Uri> for DebugConnector {
}))
}
}
+}
+#[cfg(feature = "client-legacy")]
+pub use debug_connector::*;
+#[cfg(all(feature = "client", feature = "tokio"))]
+mod debug_stream {
+use super::*;
pub struct DebugStream {
- tcp: TokioIo<TcpStream>,
- on_drop: mpsc::Sender<()>,
- is_alpn_h2: bool,
- is_proxy: bool,
+ pub(super) tcp: TokioIo<TcpStream>,
+ pub(super) on_drop: mpsc::Sender<()>,
+ pub(super) is_alpn_h2: bool,
+ pub(super) is_proxy: bool,
}
impl Drop for DebugStream {
@@ -173,3 +185,7 @@ impl AsyncRead for DebugStream {
Pin::new(self.tcp.inner_mut()).poll_read(cx, buf)
}
}
+}
+#[cfg(all(feature = "client", feature = "tokio"))]
+pub use debug_stream::*;
+
|