Skip to content

Commit f125bae

Browse files
committed
[ci] Run doctests too.
See rust-lang/cargo#6669
1 parent 52e9d45 commit f125bae

File tree

6 files changed

+36
-18
lines changed

6 files changed

+36
-18
lines changed

.cargo/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ watch --clear
1818
-x ofl-fmt-project
1919
-x clippy-core
2020
-x test-core
21+
-x test-core-doc
2122
-x docs-clean
2223
-x docs-all
2324
"""
2425

2526
bench-core = "bench --all-targets --package illicit --package moxie --package topo"
2627
clippy-core = "clippy --package illicit --package moxie --package topo --package topo-macro"
2728
test-core = "test --all-targets --package illicit --package moxie --package topo --package topo-macro"
29+
test-core-doc = "test --doc --package illicit --package moxie --package topo --package topo-macro"
2830

2931
docs-all = "doc --workspace --no-deps --all-features"
3032
docs-clean = "clean --doc"
@@ -37,6 +39,7 @@ build-times = "build --workspace --all-targets --all-features -Z timings"
3739
dom-flow = """
3840
watch --clear
3941
-x test-dom
42+
-x test-dom-doc
4043
-x test-augdom
4144
-x test-dom-lib-browser
4245
-x test-dom-drivertest
@@ -64,6 +67,7 @@ test-dom-todo = "wa-test dom/examples/todo"
6467

6568
# standalones
6669
test-dom = "test --package moxie-dom --package ssr-poc --all-targets"
70+
test-dom-doc = "test --package moxie-dom --package ssr-poc --doc"
6771

6872
# dom utilities
6973
clippy-dom = """clippy

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ jobs:
6868
env:
6969
CARGO_TARGET_DIR: target/
7070
- run: bin/ofl coverage collect test-core
71+
- run: bin/ofl coverage collect test-core-doc
7172
- run: bin/ofl coverage collect test-dom
73+
- run: bin/ofl coverage collect test-dom-doc
7274
- run: bin/ofl coverage report
7375

7476
- uses: codecov/codecov-action@v1

illicit/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ owning_ref = "0.4"
1313
scopeguard = "1"
1414

1515
[dev-dependencies]
16+
assert-panic = "1.0.1"
1617
criterion = "0.3"
1718

1819
[[bench]]

illicit/src/lib.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,35 @@
1313
//! num + 1
1414
//! }
1515
//!
16-
//! illicit::Layer::new().with(1u8).enter(|| {
16+
//! illicit::Layer::new().offer(1u8).enter(|| {
1717
//! assert_eq!(env_num_plus_one(), 2u8);
18+
//!
19+
//! illicit::Layer::new().offer(7u8).enter(|| {
20+
//! assert_eq!(env_num_plus_one(), 8u8);
21+
//! });
1822
//! });
1923
//! ```
2024
//!
21-
//! This provides convenient sugar for values stored in the current `Env` as an
22-
//! alternative to thread-locals or a manually propagated context object.
25+
//! Here, both calls see a `u8` in their environment.
26+
//!
27+
//! # Caution
28+
//!
29+
//! This provides convenient sugar for values stored in the current environment
30+
//! as an alternative to thread-locals or a manually propagated context object.
2331
//! However this approach incurs a significant cost in that the following code
2432
//! will panic without the right type having been added to the environment:
2533
//!
26-
//! ```should_panic
34+
//! ```
35+
//! # use assert_panic::assert_panic;
2736
//! # #[illicit::from_env(num: &u8)]
2837
//! # fn env_num_plus_one() -> u8 {
2938
//! # num + 1
3039
//! # }
31-
//! // thread 'main' panicked at 'expected a value from the environment, found none'
32-
//! env_num_plus_one();
40+
//! assert_panic!(
41+
//! { env_num_plus_one(); },
42+
//! String,
43+
//! starts with "expected a `u8` from the environment",
44+
//! );
3345
//! ```
3446
//!
3547
//! See the attribute's documentation for more details, and please consider
@@ -118,13 +130,12 @@ pub fn hide<E: 'static>() {
118130
})
119131
}
120132

121-
/// Immutable environment container for the current scope. Environment values
122-
/// can be provided by parent environments, but child functions can only mutate
123-
/// their environment through interior mutability.
133+
/// A pending addition to the local environment.
124134
///
125-
/// The environment is type-indexed, and each `Scope` holds 0-1 references to
126-
/// every `[std::any::Any] + 'static` type. Access is provided through read-only
127-
/// references.
135+
/// The environment is type-indexed, and access is provided through read-only
136+
/// references. Call [`Layer::offer`] to include new values in the environment
137+
/// for called functions and [`get`] or [`expect`] to retrieve references to the
138+
/// offered values.
128139
///
129140
/// Aside: one interesting implication of the above is the ability to define
130141
/// "private scoped global values" which are private to functions which are
@@ -189,7 +200,7 @@ impl Layer {
189200
(self.location.file(), self.location.line(), self.location.column())
190201
}
191202

192-
/// Call `child_fn` with this environment as the current scope.
203+
/// Call `child_fn` with this layer added to the environment.
193204
pub fn enter<R>(self, child_fn: impl FnOnce() -> R) -> R {
194205
let _reset_when_done_please = CURRENT_SCOPE.with(|parent| {
195206
let mut parent = parent.borrow_mut();

src/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl std::fmt::Debug for Revision {
6060
/// state variables which might require mutation wakeups.
6161
///
6262
/// ```
63-
/// # use moxie::embed::{Revision, Runtime};
63+
/// # use moxie::runtime::{Revision, Runtime};
6464
/// let mut rt = Runtime::new();
6565
/// assert_eq!(rt.revision().0, 0);
6666
/// for i in 1..10 {

topo/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ where
9696
/// ```
9797
/// // a call to root() here ensures the child is always treated as the same tree
9898
/// // no matter from where the function is called
99-
/// let independent = || root(Id::current);
100-
/// assert_eq!(call(independent), call(independent));
99+
/// let independent = || topo::root(topo::Id::current);
100+
/// assert_eq!(topo::call(independent), topo::call(independent));
101101
///
102102
/// // this is a normal topo call, it returns `Id`s based on the parent state
103-
/// let dependent = || call(Id::current);
104-
/// assert_ne!(call(dependent), call(dependent));
103+
/// let dependent = || topo::call(topo::Id::current);
104+
/// assert_ne!(topo::call(dependent), topo::call(dependent));
105105
/// ```
106106
pub fn root<F, R>(op: F) -> R
107107
where

0 commit comments

Comments
 (0)