Skip to content

Commit 6c9e02e

Browse files
bors[bot]GuillaumeGomezcuviper
committed
657: Automatically check if README.md examples are working when running "cargo test" r=cuviper a=GuillaumeGomez Since rustdoc nightly now provides "cfg(test)" when running on test mode, we can now use this macro on test mode only to check if README.md examples are working as expected. Co-authored-by: Guillaume Gomez <[email protected]> Co-authored-by: Josh Stone <[email protected]>
2 parents 047ea91 + 4547a27 commit 6c9e02e

File tree

5 files changed

+11
-4
lines changed

5 files changed

+11
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ rand = "0.6"
3434
rand_xorshift = "0.1"
3535
serde = "1"
3636
serde_derive = "1"
37+
doc-comment = "0.3"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ command to get a visualization of an nbody simulation. To see the
104104
effect of using Rayon, press `s` to run sequentially and `p` to run in
105105
parallel.
106106

107-
```
107+
```text
108108
> cd rayon-demo
109109
> cargo run --release -- nbody visualize
110110
```
111111

112112
For more information on demos, try:
113113

114-
```
114+
```text
115115
> cd rayon-demo
116116
> cargo run --release -- --help
117117
```

rayon-core/src/compile_fail/scope_join_bad.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! ```compile_fail,E0597
1+
/*! ```compile_fail,E0373
22
33
fn bad_scope<F>(f: F)
44
where F: FnOnce(&i32) + Send,

rayon-futures/src/compile_fail/future_escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! ```compile_fail,E0501,E0382,E0597
1+
/*! ```compile_fail,E0382,E0501,E0503,E0716
22
33
extern crate futures;
44
extern crate rayon_core;

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ extern crate rayon_core;
8585
extern crate rand;
8686
#[cfg(test)]
8787
extern crate rand_xorshift;
88+
#[cfg(test)]
89+
#[macro_use]
90+
extern crate doc_comment;
91+
92+
#[cfg(test)]
93+
doctest!("../README.md");
8894

8995
#[macro_use]
9096
mod delegate;

0 commit comments

Comments
 (0)