Skip to content

Commit 2b5721a

Browse files
committed
fix(CI): ignore incompatible tests with miri
removing the `runtime` feature flag enables code that was previously ignored by miri running without the `runtime` flag, in places that had flags like `#[cfg(all(feature = "runtime", feature = "http2"))]`
1 parent 2146d06 commit 2b5721a

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

src/common/io/rewind.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ mod tests {
113113
use bytes::Bytes;
114114
use tokio::io::AsyncReadExt;
115115

116+
#[cfg(not(miri))]
116117
#[tokio::test]
117118
async fn partial_rewind() {
118119
let underlying = [104, 101, 108, 108, 111];
@@ -135,6 +136,7 @@ mod tests {
135136
assert_eq!(&buf, &underlying);
136137
}
137138

139+
#[cfg(not(miri))]
138140
#[tokio::test]
139141
async fn full_rewind() {
140142
let underlying = [104, 101, 108, 108, 111];

src/proto/h1/conn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ impl State {
10381038

10391039
#[cfg(test)]
10401040
mod tests {
1041-
#[cfg(feature = "nightly")]
1041+
#[cfg(all(feature = "nightly", not(miri)))]
10421042
#[bench]
10431043
fn bench_read_head_short(b: &mut ::test::Bencher) {
10441044
use super::*;

src/proto/h1/decode.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ impl Decoder {
9595
// methods
9696

9797
pub(crate) fn is_eof(&self) -> bool {
98-
matches!(self.kind, Length(0) | Chunked(ChunkedState::End, _) | Eof(true))
98+
matches!(
99+
self.kind,
100+
Length(0) | Chunked(ChunkedState::End, _) | Eof(true)
101+
)
99102
}
100103

101104
pub(crate) fn decode<R: MemRead>(
@@ -471,6 +474,7 @@ mod tests {
471474
use crate::mock::AsyncIo;
472475
*/
473476

477+
#[cfg(not(miri))]
474478
#[tokio::test]
475479
async fn test_read_chunk_size() {
476480
use std::io::ErrorKind::{InvalidData, InvalidInput, UnexpectedEof};
@@ -553,6 +557,7 @@ mod tests {
553557
read_err("f0000000000000003\r\n", InvalidData).await;
554558
}
555559

560+
#[cfg(not(miri))]
556561
#[tokio::test]
557562
async fn test_read_sized_early_eof() {
558563
let mut bytes = &b"foo bar"[..];
@@ -562,6 +567,7 @@ mod tests {
562567
assert_eq!(e.kind(), io::ErrorKind::UnexpectedEof);
563568
}
564569

570+
#[cfg(not(miri))]
565571
#[tokio::test]
566572
async fn test_read_chunked_early_eof() {
567573
let mut bytes = &b"\
@@ -574,6 +580,7 @@ mod tests {
574580
assert_eq!(e.kind(), io::ErrorKind::UnexpectedEof);
575581
}
576582

583+
#[cfg(not(miri))]
577584
#[tokio::test]
578585
async fn test_read_chunked_single_read() {
579586
let mut mock_buf = &b"10\r\n1234567890abcdef\r\n0\r\n"[..];
@@ -586,6 +593,7 @@ mod tests {
586593
assert_eq!("1234567890abcdef", &result);
587594
}
588595

596+
#[cfg(not(miri))]
589597
#[tokio::test]
590598
async fn test_read_chunked_trailer_with_missing_lf() {
591599
let mut mock_buf = &b"10\r\n1234567890abcdef\r\n0\r\nbad\r\r\n"[..];
@@ -595,6 +603,7 @@ mod tests {
595603
assert_eq!(e.kind(), io::ErrorKind::InvalidInput);
596604
}
597605

606+
#[cfg(not(miri))]
598607
#[tokio::test]
599608
async fn test_read_chunked_after_eof() {
600609
let mut mock_buf = &b"10\r\n1234567890abcdef\r\n0\r\n\r\n"[..];
@@ -659,26 +668,29 @@ mod tests {
659668
}
660669
}
661670

671+
#[cfg(not(miri))]
662672
#[tokio::test]
663673
async fn test_read_length_async() {
664674
let content = "foobar";
665675
all_async_cases(content, content, Decoder::length(content.len() as u64)).await;
666676
}
667677

678+
#[cfg(not(miri))]
668679
#[tokio::test]
669680
async fn test_read_chunked_async() {
670681
let content = "3\r\nfoo\r\n3\r\nbar\r\n0\r\n\r\n";
671682
let expected = "foobar";
672683
all_async_cases(content, expected, Decoder::chunked()).await;
673684
}
674685

686+
#[cfg(not(miri))]
675687
#[tokio::test]
676688
async fn test_read_eof_async() {
677689
let content = "foobar";
678690
all_async_cases(content, content, Decoder::eof()).await;
679691
}
680692

681-
#[cfg(feature = "nightly")]
693+
#[cfg(all(feature = "nightly", not(miri)))]
682694
#[bench]
683695
fn bench_decode_chunked_1kb(b: &mut test::Bencher) {
684696
let rt = new_runtime();
@@ -702,7 +714,7 @@ mod tests {
702714
});
703715
}
704716

705-
#[cfg(feature = "nightly")]
717+
#[cfg(all(feature = "nightly", not(miri)))]
706718
#[bench]
707719
fn bench_decode_length_1kb(b: &mut test::Bencher) {
708720
let rt = new_runtime();

src/proto/h1/dispatch.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use tokio::io::{AsyncRead, AsyncWrite};
66
use tracing::{debug, trace};
77

88
use super::{Http1Transaction, Wants};
9-
use crate::body::{Recv, DecodedLength, Body};
9+
use crate::body::{Body, DecodedLength, Recv};
1010
use crate::common::{task, Future, Pin, Poll, Unpin};
1111
use crate::proto::{BodyLength, Conn, Dispatched, MessageHead, RequestHead};
1212
use crate::upgrade::OnUpgrade;
@@ -683,6 +683,7 @@ mod tests {
683683
});
684684
}
685685

686+
#[cfg(not(miri))]
686687
#[tokio::test]
687688
async fn client_flushing_is_not_ready_for_next_request() {
688689
let _ = pretty_env_logger::try_init();
@@ -706,17 +707,15 @@ mod tests {
706707
body
707708
};
708709

709-
let req = crate::Request::builder()
710-
.method("POST")
711-
.body(body)
712-
.unwrap();
710+
let req = crate::Request::builder().method("POST").body(body).unwrap();
713711

714712
let res = tx.try_send(req).unwrap().await.expect("response");
715713
drop(res);
716714

717715
assert!(!tx.is_ready());
718716
}
719717

718+
#[cfg(not(miri))]
720719
#[tokio::test]
721720
async fn body_empty_chunks_ignored() {
722721
let _ = pretty_env_logger::try_init();

src/proto/h1/io.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ mod tests {
705705
// io_buf.flush().await.expect("should short-circuit flush");
706706
}
707707

708+
#[cfg(not(miri))]
708709
#[tokio::test]
709710
async fn parse_reads_until_blocked() {
710711
use crate::proto::h1::ClientTransaction;
@@ -893,6 +894,7 @@ mod tests {
893894
}
894895
*/
895896

897+
#[cfg(not(miri))]
896898
#[tokio::test]
897899
async fn write_buf_flatten() {
898900
let _ = pretty_env_logger::try_init();
@@ -946,6 +948,7 @@ mod tests {
946948
assert_eq!(write_buf.headers.pos, 0);
947949
}
948950

951+
#[cfg(not(miri))]
949952
#[tokio::test]
950953
async fn write_buf_queue_disable_auto() {
951954
let _ = pretty_env_logger::try_init();

0 commit comments

Comments
 (0)