From fd56ec8877ec54d44b015906cef05c4bbab9d0d8 Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Wed, 11 Apr 2018 18:16:14 +0200 Subject: [PATCH] test(lettre_email): Replace skeptic by some custom rustdoc invocations --- lettre_email/Cargo.toml | 6 +---- lettre_email/build.rs | 11 -------- lettre_email/tests/skeptic.rs | 49 ++++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 17 deletions(-) delete mode 100644 lettre_email/build.rs diff --git a/lettre_email/Cargo.toml b/lettre_email/Cargo.toml index 721eeb9..6ff0c9b 100644 --- a/lettre_email/Cargo.toml +++ b/lettre_email/Cargo.toml @@ -10,17 +10,13 @@ license = "MIT" authors = ["Alexis Mousset "] categories = ["email"] keywords = ["email", "mailer"] -build = "build.rs" [badges] travis-ci = { repository = "lettre/lettre_email" } [dev-dependencies] lettre = { version = "^0.8", path = "../lettre", features = ["smtp-transport"] } -skeptic = "^0.13" - -[build-dependencies] -skeptic = "^0.13" +glob = "0.2" [dependencies] email = "^0.0" diff --git a/lettre_email/build.rs b/lettre_email/build.rs deleted file mode 100644 index 530b757..0000000 --- a/lettre_email/build.rs +++ /dev/null @@ -1,11 +0,0 @@ -extern crate skeptic; - -use skeptic::*; - -fn main() { - let mut mdbook_files = markdown_files_of_directory("../website/content/creating-messages/"); - // Also add "README.md" to the list of files. - mdbook_files.push("README.md".into()); - - generate_doc_tests(&mdbook_files); -} diff --git a/lettre_email/tests/skeptic.rs b/lettre_email/tests/skeptic.rs index ff46c9c..f5f82a8 100644 --- a/lettre_email/tests/skeptic.rs +++ b/lettre_email/tests/skeptic.rs @@ -1 +1,48 @@ -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 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/creating-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(), + format!("Failed to run rustdoc tests on {:?}!", path) + ); +}