Skip to content

Commit

Permalink
tests: Replace skeptic by some custom logic code and rustdoc calls
Browse files Browse the repository at this point in the history
Unfortunately skeptic pulls all its dependencies in projects using
lettre (see budziq/rust-skeptic#60).
  • Loading branch information
Eijebong committed Apr 11, 2018
1 parent 27c8e20 commit 435926b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 14 deletions.
6 changes: 1 addition & 5 deletions lettre/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ license = "MIT"
authors = ["Alexis Mousset <[email protected]>"]
categories = ["email"]
keywords = ["email", "smtp", "mailer"]
build = "build.rs"

[badges]
travis-ci = { repository = "lettre/lettre" }
Expand All @@ -30,10 +29,7 @@ serde_derive = { version = "^1.0", optional = true }

[dev-dependencies]
env_logger = "^0.5"
skeptic = "^0.13"

[build-dependencies]
skeptic = "^0.13"
glob = "0.2"

[features]
default = ["file-transport", "crammd5-auth", "smtp-transport", "sendmail-transport"]
Expand Down
8 changes: 0 additions & 8 deletions lettre/build.rs

This file was deleted.

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

use self::glob::glob;
use std::env::consts::EXE_EXTENSION;
use std::env;
use std::path::Path;
use std::process::Command;

#[test]
fn test_readme() {
let readme = Path::new(file!())
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.join("README.md");

skeptic_test(&readme);
}

#[test]
fn book_test() {
let mut book_path = env::current_dir().unwrap();
book_path.push(
Path::new(file!())
.parent()
.unwrap()
.parent()
.unwrap()
.parent()
.unwrap()
.join("../website/content/sending-messages"),
); // For some reasons, calling .parent() once more gives us None...

for md in glob(&format!("{}/*.md", book_path.to_str().unwrap())).unwrap() {
skeptic_test(&md.unwrap());
}
}

fn skeptic_test(path: &Path) {
let rustdoc = Path::new("rustdoc").with_extension(EXE_EXTENSION);
let exe = env::current_exe().unwrap();
let depdir = exe.parent().unwrap();

let mut cmd = Command::new(rustdoc);
cmd.args(&["--verbose", "--test"])
.arg("-L")
.arg(&depdir)
.arg(path);

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

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

0 comments on commit 435926b

Please sign in to comment.