Merge pull request #4 from seanyoung/doctest

Fix doctest and run them during CI
pull/14/head
Alessandro Decina 3 years ago committed by GitHub
commit 521ef09463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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};

@ -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)]

Loading…
Cancel
Save