Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run doc tests with miri in ci #7060

Merged
merged 5 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The miri job is starting to take a rather long time. Could you add a new job for this, instead of adding additional work to the existing job? This will allow for parallelism.

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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, but we do have socketpair in Miri?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops should be only the SOCK_DGRAM flag

fixed in #7063

/// # 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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically we report a leak; this can be ignored -- but maybe you want to detect memory leaks in the other tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely want the leak detection for lots of other tests.

/// use tokio::runtime::Runtime;
/// use tokio::task;
///
Expand Down
Loading