From 896ef02a52500b18edcef3d415956572149fb585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Kj=C3=A4ll?= Date: Sat, 2 Nov 2024 10:57:38 +0100 Subject: [PATCH] gate tests behind the features they use this enables running 'cargo test --no-default-features' --- x11rb-protocol/src/connect.rs | 5 ++++- x11rb-protocol/src/packet_reader.rs | 2 +- x11rb-protocol/src/parse_display/connect_instruction.rs | 2 +- x11rb-protocol/src/parse_display/mod.rs | 2 +- x11rb-protocol/src/test.rs | 1 + x11rb-protocol/src/x11_utils.rs | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/x11rb-protocol/src/connect.rs b/x11rb-protocol/src/connect.rs index 67e319e8..82399c7a 100644 --- a/x11rb-protocol/src/connect.rs +++ b/x11rb-protocol/src/connect.rs @@ -44,6 +44,8 @@ use core::fmt; /// to establish an X11 connection like so: /// /// ```rust,no_run +/// # #[cfg(feature = "std")] +/// # { /// # use x11rb_protocol::connect::Connect; /// # use x11rb_protocol::xauth::Family; /// # use std::{error::Error, io::prelude::*}; @@ -86,6 +88,7 @@ use core::fmt; /// let setup = connect.into_setup()?; /// # Ok(()) /// # } +/// # } /// ``` /// /// If, instead, `stream` implements `AsyncRead` and `AsyncWrite`, the code @@ -262,7 +265,7 @@ impl TryFrom for Setup { } #[cfg(test)] -#[cfg(feature = "extra-traits")] +#[cfg(all(feature = "extra-traits", feature = "std"))] mod tests { use super::Connect; use crate::errors::ConnectError; diff --git a/x11rb-protocol/src/packet_reader.rs b/x11rb-protocol/src/packet_reader.rs index 1a3950e7..a6ba0901 100644 --- a/x11rb-protocol/src/packet_reader.rs +++ b/x11rb-protocol/src/packet_reader.rs @@ -124,7 +124,7 @@ fn extra_length(buffer: &[u8]) -> usize { } } -#[cfg(test)] +#[cfg(all(test, feature = "std"))] mod tests { use super::PacketReader; use alloc::{vec, vec::Vec}; diff --git a/x11rb-protocol/src/parse_display/connect_instruction.rs b/x11rb-protocol/src/parse_display/connect_instruction.rs index cd3f6a83..5c9026ca 100644 --- a/x11rb-protocol/src/parse_display/connect_instruction.rs +++ b/x11rb-protocol/src/parse_display/connect_instruction.rs @@ -54,7 +54,7 @@ pub(super) fn connect_addresses(p: &ParsedDisplay) -> impl Iterator