Skip to content

Commit

Permalink
ci: run doc tests with miri (#7060)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiif authored Jan 2, 2025
1 parent b3ff911 commit 2052938
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,25 @@ jobs:
env:
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields

miri-doc-test:
name: miri-doc-test
needs: basics
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust ${{ env.rust_miri_nightly }}
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.rust_miri_nightly }}
components: miri
- uses: Swatinem/rust-cache@v2
- name: miri-doc-test
run: |
cargo miri test --doc --all-features --no-fail-fast
working-directory: tokio
env:
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance -Zmiri-retag-fields

asan:
name: asan
needs: basics
Expand Down
1 change: 1 addition & 0 deletions tokio/src/net/tcp/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl TcpListener {
/// # Examples
///
/// ```no_run
/// # if cfg!(miri) { return } // No `socket` in miri.
/// use tokio::net::TcpListener;
///
/// use std::io;
Expand Down
1 change: 1 addition & 0 deletions tokio/src/net/tcp/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ impl TcpSocket {
/// # Examples
///
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// use tokio::net::TcpSocket;
/// use socket2::{Domain, Socket, Type};
///
Expand Down
1 change: 1 addition & 0 deletions tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ impl TcpStream {
/// # Examples
///
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// use std::error::Error;
/// use std::io::Read;
/// use tokio::net::TcpListener;
Expand Down
3 changes: 3 additions & 0 deletions tokio/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ impl UdpSocket {
/// # Example
///
/// ```no_run
/// # if cfg!(miri) { return } // No `socket` in miri.
/// use tokio::net::UdpSocket;
/// use std::io;
///
Expand Down Expand Up @@ -295,6 +296,7 @@ impl UdpSocket {
/// # Example
///
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// use tokio::net::UdpSocket;
///
/// # use std::{io, net::SocketAddr};
Expand Down Expand Up @@ -1979,6 +1981,7 @@ impl UdpSocket {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// use tokio::net::UdpSocket;
/// use std::io;
///
Expand Down
19 changes: 19 additions & 0 deletions tokio/src/net/unix/datagram/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ cfg_net_unix! {
/// # Examples
/// Using named sockets, associated with a filesystem path:
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -67,6 +68,7 @@ cfg_net_unix! {
///
/// Using unnamed sockets, created as a pair
/// ```
/// # if cfg!(miri) { return } // No `socketpair` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -371,6 +373,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -403,6 +406,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No SOCK_DGRAM for socketpair in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -457,6 +461,7 @@ impl UnixDatagram {
/// explicitly with [`Runtime::enter`](crate::runtime::Runtime::enter) function.
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -521,6 +526,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -560,6 +566,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -604,6 +611,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socketpair` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -734,6 +742,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socketpair` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -884,6 +893,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -1000,6 +1010,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socketpair` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -1050,6 +1061,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -1100,6 +1112,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -1416,6 +1429,7 @@ impl UnixDatagram {
/// # Examples
/// For a socket bound to a local path
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand All @@ -1438,6 +1452,7 @@ impl UnixDatagram {
///
/// For an unbound socket
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand All @@ -1462,6 +1477,7 @@ impl UnixDatagram {
/// # Examples
/// For a peer with a local path
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand All @@ -1487,6 +1503,7 @@ impl UnixDatagram {
///
/// For an unbound peer
/// ```
/// # if cfg!(miri) { return } // No `socketpair` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand All @@ -1508,6 +1525,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down Expand Up @@ -1535,6 +1553,7 @@ impl UnixDatagram {
///
/// # Examples
/// ```
/// # if cfg!(miri) { return } // No `socketpair` in miri.
/// # use std::error::Error;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn Error>> {
Expand Down
1 change: 1 addition & 0 deletions tokio/src/net/unix/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ impl UnixStream {
/// # Examples
///
/// ```
/// # if cfg!(miri) { return } // No `socket` in miri.
/// use std::error::Error;
/// use std::io::Read;
/// use tokio::net::UnixListener;
Expand Down
2 changes: 2 additions & 0 deletions tokio/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ impl Command {
/// Basic usage:
///
/// ```no_run
/// # if cfg!(miri) { return } // No `pidfd_spawnp` in miri.
/// use tokio::process::Command;
///
/// async fn run_ls() -> std::process::ExitStatus {
Expand Down Expand Up @@ -1192,6 +1193,7 @@ impl Child {
/// This function is cancel safe.
///
/// ```
/// # if cfg!(miri) { return } // No `pidfd_spawnp` in miri.
/// # #[cfg(not(unix))]fn main(){}
/// # #[cfg(unix)]
/// use tokio::io::AsyncWriteExt;
Expand Down
1 change: 1 addition & 0 deletions tokio/src/runtime/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ impl Runtime {
/// # Examples
///
/// ```
/// # if cfg!(miri) { return } // Miri reports error when main thread terminated without waiting all remaining threads.
/// use tokio::runtime::Runtime;
/// use tokio::task;
///
Expand Down

0 comments on commit 2052938

Please sign in to comment.