From 1196ba1dccebfb0953d0e4d5244f81612600fdb0 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Thu, 17 Jun 2021 12:14:53 +0100 Subject: [PATCH] Fix doctest and run them during CI Signed-off-by: Sean Young --- .github/workflows/build-test.yml | 2 +- aya/src/maps/perf/async_perf_event_array.rs | 1 + aya/src/programs/lirc_mode2.rs | 22 ++++++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 88fd5e12..fc4deec4 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -34,4 +34,4 @@ jobs: run: cargo build --verbose - name: Run tests - run: RUST_BACKTRACE=full cargo test --verbose --tests + run: RUST_BACKTRACE=full cargo test --verbose diff --git a/aya/src/maps/perf/async_perf_event_array.rs b/aya/src/maps/perf/async_perf_event_array.rs index ebf341c3..0e74f99f 100644 --- a/aya/src/maps/perf/async_perf_event_array.rs +++ b/aya/src/maps/perf/async_perf_event_array.rs @@ -40,6 +40,7 @@ use crate::maps::{ /// # #[error(transparent)] /// # PerfBuf(#[from] aya::maps::perf::PerfBufferError), /// # } +/// # #[cfg(feature = "async_tokio")] /// # async fn try_main() -> Result<(), Error> { /// # let bpf = aya::Bpf::load(&[], None)?; /// use aya::maps::perf::{AsyncPerfEventArray, PerfBufferError}; diff --git a/aya/src/programs/lirc_mode2.rs b/aya/src/programs/lirc_mode2.rs index 76700b97..d5c1b7cf 100644 --- a/aya/src/programs/lirc_mode2.rs +++ b/aya/src/programs/lirc_mode2.rs @@ -18,15 +18,27 @@ use libc::{close, dup}; /// # Examples /// /// ```no_run +/// # #[derive(thiserror::Error, Debug)] +/// # enum Error { +/// # #[error(transparent)] +/// # IO(#[from] std::io::Error), +/// # #[error(transparent)] +/// # Map(#[from] aya::maps::MapError), +/// # #[error(transparent)] +/// # Program(#[from] aya::programs::ProgramError), +/// # #[error(transparent)] +/// # Bpf(#[from] aya::BpfError) +/// # } +/// # let mut bpf = aya::Bpf::load(&[], None)?; /// use std::fs::File; /// use std::convert::TryInto; /// use aya::programs::LircMode2; /// -/// let file = File::open("/dev/lirc0").unwrap(); -/// let mut bpf = Bpf::load_file("imon_rsc.o").unwrap(); -/// let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc").unwrap().try_into().unwrap(); -/// decoder.load().unwrap(); -/// decoder.attach(file).unwrap(); +/// let file = File::open("/dev/lirc0")?; +/// let mut bpf = aya::Bpf::load_file("imon_rsc.o")?; +/// let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc")?.try_into().unwrap(); +/// decoder.load()?; +/// decoder.attach(file)?; /// # Ok::<(), Error>(()) /// ``` #[derive(Debug)]