Fix doctest and run them during CI

Signed-off-by: Sean Young <sean@mess.org>
pull/4/head
Sean Young 3 years ago
parent 59cfbc51c8
commit 1196ba1dcc

@ -34,4 +34,4 @@ jobs:
run: cargo build --verbose run: cargo build --verbose
- name: Run tests - name: Run tests
run: RUST_BACKTRACE=full cargo test --verbose --tests run: RUST_BACKTRACE=full cargo test --verbose

@ -40,6 +40,7 @@ use crate::maps::{
/// # #[error(transparent)] /// # #[error(transparent)]
/// # PerfBuf(#[from] aya::maps::perf::PerfBufferError), /// # PerfBuf(#[from] aya::maps::perf::PerfBufferError),
/// # } /// # }
/// # #[cfg(feature = "async_tokio")]
/// # async fn try_main() -> Result<(), Error> { /// # async fn try_main() -> Result<(), Error> {
/// # let bpf = aya::Bpf::load(&[], None)?; /// # let bpf = aya::Bpf::load(&[], None)?;
/// use aya::maps::perf::{AsyncPerfEventArray, PerfBufferError}; /// use aya::maps::perf::{AsyncPerfEventArray, PerfBufferError};

@ -18,15 +18,27 @@ use libc::{close, dup};
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```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::fs::File;
/// use std::convert::TryInto; /// use std::convert::TryInto;
/// use aya::programs::LircMode2; /// use aya::programs::LircMode2;
/// ///
/// let file = File::open("/dev/lirc0").unwrap(); /// let file = File::open("/dev/lirc0")?;
/// let mut bpf = Bpf::load_file("imon_rsc.o").unwrap(); /// let mut bpf = aya::Bpf::load_file("imon_rsc.o")?;
/// let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc").unwrap().try_into().unwrap(); /// let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc")?.try_into().unwrap();
/// decoder.load().unwrap(); /// decoder.load()?;
/// decoder.attach(file).unwrap(); /// decoder.attach(file)?;
/// # Ok::<(), Error>(()) /// # Ok::<(), Error>(())
/// ``` /// ```
#[derive(Debug)] #[derive(Debug)]

Loading…
Cancel
Save