Skip to content

Commit df1f064

Browse files
author
Jonas Schievink
committed
Run doctests in CI
1 parent bd1a80e commit df1f064

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

nrf-hal-common/src/saadc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//!
33
//! Example usage:
44
//!
5-
//! ```no_run
5+
#![cfg_attr(feature = "52840", doc = "```no_run")]
6+
#![cfg_attr(not(feature = "52840"), doc = "```ignore")]
67
//! # use nrf_hal_common as hal;
78
//! # use hal::pac::{saadc, SAADC};
89
//! // subsititute `hal` with the HAL of your board, e.g. `nrf52840_hal`
@@ -115,7 +116,8 @@ pub struct SaadcConfig {
115116
/// Default SAADC configuration. 0 volts reads as 0, VDD volts reads as `u16::MAX`.
116117
/// The returned SaadcConfig is configured with the following values:
117118
///
118-
/// ```rust
119+
#[cfg_attr(feature = "52840", doc = "```")]
120+
#[cfg_attr(not(feature = "52840"), doc = "```ignore")]
119121
/// # use nrf_hal_common::saadc::SaadcConfig;
120122
/// # use nrf_hal_common::pac::{saadc, SAADC};
121123
/// # use saadc::{

xtask/tests/ci.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ fn main() {
4747
);
4848
}
4949

50+
// Build/Run doc-tests in `nrf-hal-common` for each chip.
51+
for (hal, _) in HALS {
52+
let feature = hal.trim_start_matches("nrf").trim_end_matches("-hal");
53+
54+
let mut cargo = Command::new("cargo");
55+
let status = cargo
56+
.current_dir("nrf-hal-common")
57+
.args(&["test", "--features", feature])
58+
.status()
59+
.map_err(|e| format!("could not execute {:?}: {}", cargo, e))
60+
.unwrap();
61+
assert!(
62+
status.success(),
63+
"command exited with error status: {:?}",
64+
cargo
65+
);
66+
}
67+
5068
// Build-test every example with each supported feature.
5169
for (example, features) in EXAMPLES {
5270
// Features are exclusive (they select the target chip), so we test each one

0 commit comments

Comments
 (0)