Rollup merge of #141019 - ehuss:android-doctest-xcompile, r=Mark-Simulacrum
Update std doctests for android This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests. In summary: - Android re-exports some traits from linux under a different path. - Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
This commit is contained in:
@@ -23,7 +23,10 @@ pub trait SocketAddrExt: Sealed {
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::os::unix::net::{UnixListener, SocketAddr};
|
||||
/// #[cfg(target_os = "linux")]
|
||||
/// use std::os::linux::net::SocketAddrExt;
|
||||
/// #[cfg(target_os = "android")]
|
||||
/// use std::os::android::net::SocketAddrExt;
|
||||
///
|
||||
/// fn main() -> std::io::Result<()> {
|
||||
/// let addr = SocketAddr::from_abstract_name(b"hidden")?;
|
||||
@@ -48,7 +51,10 @@ pub trait SocketAddrExt: Sealed {
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::os::unix::net::{UnixListener, SocketAddr};
|
||||
/// #[cfg(target_os = "linux")]
|
||||
/// use std::os::linux::net::SocketAddrExt;
|
||||
/// #[cfg(target_os = "android")]
|
||||
/// use std::os::android::net::SocketAddrExt;
|
||||
///
|
||||
/// fn main() -> std::io::Result<()> {
|
||||
/// let name = b"hidden";
|
||||
|
||||
@@ -27,7 +27,10 @@ pub trait UnixSocketExt: Sealed {
|
||||
///
|
||||
/// ```no_run
|
||||
/// #![feature(unix_socket_ancillary_data)]
|
||||
/// #[cfg(target_os = "linux")]
|
||||
/// use std::os::linux::net::UnixSocketExt;
|
||||
/// #[cfg(target_os = "android")]
|
||||
/// use std::os::android::net::UnixSocketExt;
|
||||
/// use std::os::unix::net::UnixDatagram;
|
||||
///
|
||||
/// fn main() -> std::io::Result<()> {
|
||||
|
||||
@@ -25,7 +25,10 @@ pub trait TcpStreamExt: Sealed {
|
||||
/// ```no_run
|
||||
/// #![feature(tcp_quickack)]
|
||||
/// use std::net::TcpStream;
|
||||
/// #[cfg(target_os = "linux")]
|
||||
/// use std::os::linux::net::TcpStreamExt;
|
||||
/// #[cfg(target_os = "android")]
|
||||
/// use std::os::android::net::TcpStreamExt;
|
||||
///
|
||||
/// let stream = TcpStream::connect("127.0.0.1:8080")
|
||||
/// .expect("Couldn't connect to the server...");
|
||||
@@ -43,7 +46,10 @@ pub trait TcpStreamExt: Sealed {
|
||||
/// ```no_run
|
||||
/// #![feature(tcp_quickack)]
|
||||
/// use std::net::TcpStream;
|
||||
/// #[cfg(target_os = "linux")]
|
||||
/// use std::os::linux::net::TcpStreamExt;
|
||||
/// #[cfg(target_os = "android")]
|
||||
/// use std::os::android::net::TcpStreamExt;
|
||||
///
|
||||
/// let stream = TcpStream::connect("127.0.0.1:8080")
|
||||
/// .expect("Couldn't connect to the server...");
|
||||
|
||||
@@ -1348,7 +1348,7 @@ impl Output {
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(exit_status_error)]
|
||||
/// # #[cfg(unix)] {
|
||||
/// # #[cfg(all(unix, not(target_os = "android")))] {
|
||||
/// use std::process::Command;
|
||||
/// assert!(Command::new("false").output().unwrap().exit_ok().is_err());
|
||||
/// # }
|
||||
@@ -1695,7 +1695,7 @@ impl From<io::Stdout> for Stdio {
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// #
|
||||
/// # if cfg!(unix) {
|
||||
/// # if cfg!(all(unix, not(target_os = "android"))) {
|
||||
/// # test().unwrap();
|
||||
/// # }
|
||||
/// ```
|
||||
@@ -1724,7 +1724,7 @@ impl From<io::Stderr> for Stdio {
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// #
|
||||
/// # if cfg!(unix) {
|
||||
/// # if cfg!(all(unix, not(target_os = "android"))) {
|
||||
/// # test().unwrap();
|
||||
/// # }
|
||||
/// ```
|
||||
@@ -1907,7 +1907,7 @@ impl crate::sealed::Sealed for ExitStatusError {}
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(exit_status_error)]
|
||||
/// # if cfg!(unix) {
|
||||
/// # if cfg!(all(unix, not(target_os = "android"))) {
|
||||
/// use std::process::{Command, ExitStatusError};
|
||||
///
|
||||
/// fn run(cmd: &str) -> Result<(), ExitStatusError> {
|
||||
@@ -1950,7 +1950,7 @@ impl ExitStatusError {
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(exit_status_error)]
|
||||
/// # #[cfg(unix)] {
|
||||
/// # #[cfg(all(unix, not(target_os = "android")))] {
|
||||
/// use std::process::Command;
|
||||
///
|
||||
/// let bad = Command::new("false").status().unwrap().exit_ok().unwrap_err();
|
||||
@@ -1975,7 +1975,7 @@ impl ExitStatusError {
|
||||
/// ```
|
||||
/// #![feature(exit_status_error)]
|
||||
///
|
||||
/// # if cfg!(unix) {
|
||||
/// # if cfg!(all(unix, not(target_os = "android"))) {
|
||||
/// use std::num::NonZero;
|
||||
/// use std::process::Command;
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user