Skip to content

Commit 35e367e

Browse files
committed
Use doc_comment for README doctests
1 parent 7944398 commit 35e367e

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ keywords = ["ansi", "escape", "terminal"]
1212

1313
[dependencies]
1414
vte = "0.10"
15+
16+
[dev-dependencies]
17+
doc-comment = "0.3"

src/lib.rs

+6-32
Original file line numberDiff line numberDiff line change
@@ -151,42 +151,16 @@ where
151151
}
152152
}
153153

154+
#[cfg(doctest)]
155+
extern crate doc_comment;
156+
157+
#[cfg(doctest)]
158+
doc_comment::doctest!("../README.md", readme);
159+
154160
#[cfg(test)]
155161
mod tests {
156162
use super::*;
157163

158-
use std::env;
159-
use std::env::consts::EXE_EXTENSION;
160-
use std::path::Path;
161-
use std::process::Command;
162-
163-
#[test]
164-
fn readme_test() {
165-
let rustdoc = Path::new("rustdoc").with_extension(EXE_EXTENSION);
166-
let readme = Path::new(file!())
167-
.parent()
168-
.unwrap()
169-
.parent()
170-
.unwrap()
171-
.join("README.md");
172-
let exe = env::current_exe().unwrap();
173-
let outdir = exe.parent().unwrap();
174-
let mut cmd = Command::new(rustdoc);
175-
cmd.args(&["--verbose", "--test", "-L"])
176-
.arg(&outdir)
177-
.arg(&readme);
178-
println!("{:?}", cmd);
179-
let result = cmd
180-
.spawn()
181-
.expect("Failed to spawn process")
182-
.wait()
183-
.expect("Failed to run process");
184-
assert!(
185-
result.success(),
186-
"Failed to run rustdoc tests on README.md!"
187-
);
188-
}
189-
190164
fn assert_parsed(input: &[u8], expected: &[u8]) {
191165
let bytes = strip(input).expect("Failed to strip escapes");
192166
assert_eq!(bytes, expected);

0 commit comments

Comments
 (0)