Skip to content

Commit

Permalink
gate tests behind the features they use
Browse files Browse the repository at this point in the history
this enables running 'cargo test --no-default-features'
  • Loading branch information
alexanderkjall committed Nov 2, 2024
1 parent 2a0d3e6 commit 896ef02
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion x11rb-protocol/src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*};
Expand Down Expand Up @@ -86,6 +88,7 @@ use core::fmt;
/// let setup = connect.into_setup()?;
/// # Ok(())
/// # }
/// # }
/// ```
///
/// If, instead, `stream` implements `AsyncRead` and `AsyncWrite`, the code
Expand Down Expand Up @@ -262,7 +265,7 @@ impl TryFrom<Connect> for Setup {
}

#[cfg(test)]
#[cfg(feature = "extra-traits")]
#[cfg(all(feature = "extra-traits", feature = "std"))]
mod tests {
use super::Connect;
use crate::errors::ConnectError;
Expand Down
2 changes: 1 addition & 1 deletion x11rb-protocol/src/packet_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion x11rb-protocol/src/parse_display/connect_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub(super) fn connect_addresses(p: &ParsedDisplay) -> impl Iterator<Item = Conne
targets.into_iter()
}

#[cfg(test)]
#[cfg(all(test, feature = "std"))]
mod tests {
// make sure iterator properties are clean
use super::{super::parse_display, ConnectAddress};
Expand Down
2 changes: 1 addition & 1 deletion x11rb-protocol/src/parse_display/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ fn parse_display_direct_path(
))
}

#[cfg(test)]
#[cfg(all(test, feature = "std"))]
mod test {
use super::{
parse_display, parse_display_with_file_exists_callback, DisplayParsingError, ParsedDisplay,
Expand Down
1 change: 1 addition & 0 deletions x11rb-protocol/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "std")]
use std::borrow::Cow;

use crate::protocol::{get_request_name, request_name};
Expand Down
2 changes: 1 addition & 1 deletion x11rb-protocol/src/x11_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ implement_serialize!(i64: 8);
forward_float!(f32: u32);
forward_float!(f64: u64);

#[cfg(test)]
#[cfg(all(test, feature = "std"))]
mod float_tests {
use super::{Serialize, TryParse};

Expand Down

0 comments on commit 896ef02

Please sign in to comment.