Skip to content

Commit

Permalink
Run "rustdoc --test README.md" directly instead of using skeptic.
Browse files Browse the repository at this point in the history
Should fix #16.

See also budziq/rust-skeptic#60.
  • Loading branch information
im-0 committed Jan 15, 2018
1 parent 2624a77 commit 74be644
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ publish = true
repository = "https://github.com/im-0/log4rs-syslog"
documentation = "https://docs.rs/crate/log4rs-syslog"
readme = "README.md"
build = "build.rs"

[badges]
travis-ci = { repository = "im-0/log4rs-syslog", branch = "b3.0.0" }
Expand All @@ -29,10 +28,8 @@ log4rs = { version = "0.8", default_features = false }
serde = { version = "1.0", default_features = false, optional = true }
serde_derive = { version = "1.0", default_features = false, optional = true }

[build-dependencies]
skeptic = "0.13"

[dev-dependencies]
glob = "0.2"
log4rs = "0.8"
tempfile = "2.2"
skeptic = "0.13"
which = "1.0"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ There is no proper way to fix this limitations while using libc's interface.
## Usage

Add this to your Cargo.toml:

```toml
[dependencies]
log4rs-syslog = "3.0"
Expand All @@ -42,6 +43,7 @@ log4rs-syslog = "3.0"
### Initialization based on configuration file

Example configuration file:

```yaml
appenders:
syslog:
Expand All @@ -59,6 +61,7 @@ root:
```
Example code:
```rust,no_run
#[macro_use]
extern crate log;
Expand Down Expand Up @@ -87,6 +90,7 @@ fn main() {
### Manual initialization

Example code:

```rust,no_run
#[macro_use]
extern crate log;
Expand Down
6 changes: 0 additions & 6 deletions build.rs

This file was deleted.

38 changes: 37 additions & 1 deletion tests/skeptic.rs
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));
extern crate glob;
extern crate which;

#[test]
fn readme_test() {
let rustdoc = which::which("rustdoc").unwrap();

let readme = std::path::Path::new(file!()).canonicalize().unwrap();
let readme = readme.parent().unwrap().parent().unwrap().join("README.md");
let readme = readme.to_str().unwrap();

let deps = std::path::Path::new(&std::env::current_exe().unwrap())
.canonicalize()
.unwrap();
let deps = deps.parent().unwrap();

let liblog = glob::glob(deps.join("liblog-*.rlib").to_str().unwrap())
.unwrap()
.next()
.unwrap()
.unwrap();
let liblog = liblog.to_str().unwrap();

let mut cmd = std::process::Command::new(rustdoc);
cmd.arg("--verbose")
.args(&["--library-path", deps.to_str().unwrap()])
.args(&["--extern", &format!("log={}", liblog)])
.arg("--test")
.arg(&readme);

let result = cmd.spawn()
.expect("Failed to spawn rustdoc process")
.wait()
.expect("Failed to run rustdoc process");

assert!(result.success(), "Failed to run rustdoc tests on README.md");
}

0 comments on commit 74be644

Please sign in to comment.