Rocket

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 58519e495e64e8b7cca5374b34e01697692ebc21
parent 9966a07c58a94e3e35ce4a4a15e0f3b36b5ac99f
Author: Sergio Benitez <sb@sergio.bz>
Date:   Sat, 18 Aug 2018 16:52:45 -0700

Test all contrib features individually.

Diffstat:
M.travis.yml | 1+
Mcontrib/lib/src/databases.rs | 1+
Mcontrib/lib/src/lib.rs | 1+
Mcontrib/lib/src/templates/engine.rs | 1+
Mcontrib/lib/src/templates/metadata.rs | 14++++++++------
Mscripts/test.sh | 38++++++++++++++++++++++++++++++++++----
6 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml @@ -5,6 +5,7 @@ cache: cargo env: - TEST_FLAGS= - TEST_FLAGS=--release + - TEST_FLAGS=--contrib rust: - nightly script: ./scripts/test.sh $TEST_FLAGS diff --git a/contrib/lib/src/databases.rs b/contrib/lib/src/databases.rs @@ -1,3 +1,4 @@ +#![doc(cfg(feature = "diesel_sqlite_pool"))] //! Traits, utilities, and a macro for easy database connection pooling. //! //! # Overview diff --git a/contrib/lib/src/lib.rs b/contrib/lib/src/lib.rs @@ -1,6 +1,7 @@ #![feature(use_extern_macros)] #![feature(crate_visibility_modifier)] #![feature(never_type)] +#![feature(doc_cfg)] // TODO: Version URLs. #![doc(html_root_url = "https://api.rocket.rs")] diff --git a/contrib/lib/src/templates/engine.rs b/contrib/lib/src/templates/engine.rs @@ -13,6 +13,7 @@ pub trait Engine: Send + Sync + 'static { fn render<C: Serialize>(&self, name: &str, context: C) -> Option<String>; } +#[doc(cfg(feature = "tera_templates"))] /// A structure exposing access to templating engines. /// /// Calling methods on the exposed template engine types may require importing diff --git a/contrib/lib/src/templates/metadata.rs b/contrib/lib/src/templates/metadata.rs @@ -9,8 +9,8 @@ use super::ContextManager; /// /// # Usage /// -/// First, ensure that the template [fairing](`rocket::fairing`) is attached to -/// your Rocket application: +/// First, ensure that the template [fairing](`rocket::fairing`), +/// [`Template::fairing()`] is attached to your Rocket application: /// /// ```rust /// # extern crate rocket; @@ -26,8 +26,8 @@ use super::ContextManager; /// } /// ``` /// -/// The `TemplateMetadata` type implements Rocket's `FromRequest` trait, so it can -/// be used as a request guard in any request handler. +/// The `TemplateMetadata` type implements Rocket's `FromRequest` trait, so it +/// can be used as a request guard in any request handler. /// /// ```rust /// # #![feature(plugin, decl_macro)] @@ -40,11 +40,13 @@ use super::ContextManager; /// /// #[get("/")] /// fn homepage(metadata: TemplateMetadata) -> Template { +/// # use std::collections::HashMap; +/// # let context: HashMap<String, String> = HashMap::new(); /// // Conditionally render a template if it's available. /// if metadata.contains_template("some-template") { -/// Template::render("some-template", json!({ /* .. */ })) +/// Template::render("some-template", &context) /// } else { -/// Template::render("fallback", json!({ /* .. */ })) +/// Template::render("fallback", &context) /// } /// } /// ``` diff --git a/scripts/test.sh b/scripts/test.sh @@ -79,8 +79,38 @@ ensure_trailing_whitespace_free echo ":: Updating dependencies..." cargo update -echo ":: Bootstrapping examples..." -bootstrap_examples +if [ "$1" = "--contrib" ]; then + FEATURES=( + json + msgpack + tera_templates + handlebars_templates + static_files + diesel_postgres_pool + diesel_sqlite_pool + diesel_mysql_pool + postgres_pool + mysql_pool + sqlite_pool + cypher_pool + redis_pool + ) -echo ":: Building and testing libraries..." -CARGO_INCREMENTAL=0 cargo test --all-features --all $@ + pushd "${CONTRIB_LIB_ROOT}" > /dev/null 2>&1 + + echo ":: Building and testing contrib [default]..." + CARGO_INCREMENTAL=0 cargo test + + for feature in "${FEATURES[@]}"; do + echo ":: Building and testing contrib [${feature}]..." + CARGO_INCREMENTAL=0 cargo test --no-default-features --features "${feature}" + done + + popd > /dev/null 2>&1 +else + echo ":: Bootstrapping examples..." + bootstrap_examples + + echo ":: Building and testing libraries..." + CARGO_INCREMENTAL=0 cargo test --all-features --all $@ +fi