From 488fb256b4b9b8363dfeeef2002e418e3f40edcc Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Thu, 26 Oct 2017 06:12:23 -0700 Subject: [PATCH] add optional skeptic --- Cargo.toml | 6 ++++++ Makefile | 22 +++------------------- README.md | 1 + build.rs | 18 ++++++++++++++++++ examples/basic.rs | 2 +- tests/skeptic.rs | 2 ++ 6 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 build.rs create mode 100644 tests/skeptic.rs diff --git a/Cargo.toml b/Cargo.toml index bc67ab77..f1f83287 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,11 @@ readme = "README.md" keywords = ["actor", "http", "web"] homepage = "https://github.com/actix/actix-web" repository = "https://github.com/actix/actix-web.git" +documentation = "https://docs.rs/actix-web/" categories = ["network-programming", "asynchronous"] license = "Apache-2.0" exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"] +build = "build.rs" [badges] travis-ci = { repository = "actix/actix-web", branch = "master" } @@ -58,6 +60,10 @@ features = [] [dev-dependencies] env_logger = "0.4" reqwest = "0.8" +skeptic = "0.13" + +[build-dependencies] +skeptic = "0.13" [profile.release] lto = true diff --git a/Makefile b/Makefile index f1a134f0..c6a6cbd0 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ build: test: build clippy cargo test $(CARGO_FLAGS) +skeptic: + USE_SKEPTIC=1 cargo test $(CARGO_FLAGS) + # cd examples/word-count && python setup.py install && pytest -v tests clippy: @@ -17,22 +20,3 @@ clippy: doc: build cargo doc --no-deps $(CARGO_FLAGS) - -clean: - rm -r target - -gh-pages: - git clone --branch gh-pages git@github.com:fafhrd91/ctx.git gh-pages - -.PHONY: gh-pages-doc -gh-pages-doc: doc | gh-pages - cd gh-pages && git pull - rm -r gh-pages/doc - cp -r target/doc gh-pages/ - rm gh-pages/doc/.lock - cd gh-pages && git add . - cd gh-pages && git commit -m "Update documentation" - -publish: default gh-pages-doc - cargo publish - cd gh-pages && git push diff --git a/README.md b/README.md index 1c317363..ad4ddd5e 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ fn main() { .serve::<_, ()>("127.0.0.1:8080").unwrap(); println!("Started http server: 127.0.0.1:8080"); + Arbiter::system().send(msgs::SystemExit(0)); let _ = sys.run(); } ``` diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..b828ebe4 --- /dev/null +++ b/build.rs @@ -0,0 +1,18 @@ +extern crate skeptic; +use std::{env, fs}; + + +#[cfg(unix)] +fn main() { + if env::var("USE_SKEPTIC").is_ok() { + // generates doc tests for `README.md`. + skeptic::generate_doc_tests(&["README.md"]); + } else { + let f = env::var("OUT_DIR").unwrap() + "/skeptic-tests.rs"; + let _ = fs::File::create(f); + } +} + +#[cfg(not(unix))] +fn main() { +} diff --git a/examples/basic.rs b/examples/basic.rs index 91ede065..ab976b72 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -44,7 +44,7 @@ fn main() { .body(Body::Empty) })) // static files - .route_handler("/static", StaticFiles::new("static/", true))) + .route_handler("/static", StaticFiles::new("examples/static/", true))) .serve::<_, ()>("127.0.0.1:8080").unwrap(); println!("Started http server: 127.0.0.1:8080"); diff --git a/tests/skeptic.rs b/tests/skeptic.rs new file mode 100644 index 00000000..a0e0f9b3 --- /dev/null +++ b/tests/skeptic.rs @@ -0,0 +1,2 @@ +#[cfg(unix)] +include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));