diff --git a/.travis.yml b/.travis.yml index 588975f..ebe0182 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,17 +3,23 @@ rust: nightly sudo: false before_script: - - rustup component add clippy-preview --toolchain=nightly + - | + RUN_CLIPPY=true + rustup component add clippy-preview --toolchain=nightly || RUN_CLIPPY=false script: - (cd maud && cargo build --features="iron") + # The compiletest tests require a single version of the crate to be built + # or else there will be errors in picking the right version - so we test now + - cargo test --all - (cd maud && cargo build --features="rocket") - (cd maud && cargo build --features="actix-web") - - cargo test --all - (cd benchmarks && cargo bench --no-run) - | - CLIPPY_STATUS=0 - for package in maud_htmlescape maud_macros maud maud_extras; do - (cd $package && cargo clippy -- -D warnings) || CLIPPY_STATUS=$? - done - (exit $CLIPPY_STATUS) + if $RUN_CLIPPY; then + CLIPPY_STATUS=0 + for package in maud_htmlescape maud_macros maud maud_extras; do + (cd $package && cargo clippy -- -D warnings) || CLIPPY_STATUS=$? + done + (exit $CLIPPY_STATUS) + fi diff --git a/maud/Cargo.toml b/maud/Cargo.toml index 53b148f..61f17d1 100644 --- a/maud/Cargo.toml +++ b/maud/Cargo.toml @@ -19,6 +19,9 @@ iron = { version = ">= 0.5.1, < 0.7.0", optional = true } rocket = { version = "0.3", optional = true } actix-web = { version = ">= 0.6.12, < 0.8.0", optional = true } +[dev-dependencies] +compiletest_rs = "0.3.15" + [badges] travis-ci = { repository = "lfairy/maud" } diff --git a/maud/tests/warnings.rs b/maud/tests/warnings.rs new file mode 100644 index 0000000..5e635f9 --- /dev/null +++ b/maud/tests/warnings.rs @@ -0,0 +1,15 @@ +extern crate compiletest_rs; + +use std::path::PathBuf; + +#[test] +fn run_warnings() { + let mut config = compiletest_rs::Config::default(); + + config.mode = compiletest_rs::common::Mode::Ui; + config.src_base = PathBuf::from("tests/warnings"); + config.link_deps(); // Populate config.target_rustcflags with dependencies on the path + config.clean_rmeta(); // If your tests import the parent crate, this helps with E0464 + + compiletest_rs::run_tests(&config); +} diff --git a/maud/tests/warnings/warn_on_keyword_names.rs b/maud/tests/warnings/warn_on_keyword_names.rs new file mode 100644 index 0000000..fcdbc00 --- /dev/null +++ b/maud/tests/warnings/warn_on_keyword_names.rs @@ -0,0 +1,11 @@ +#![feature(proc_macro_hygiene)] + +extern crate maud_macros; + +use maud_macros::html; + +fn main() { + html! { + if {} + }; +} diff --git a/maud/tests/warnings/warn_on_keyword_names.stderr b/maud/tests/warnings/warn_on_keyword_names.stderr new file mode 100644 index 0000000..70cacc2 --- /dev/null +++ b/maud/tests/warnings/warn_on_keyword_names.stderr @@ -0,0 +1,6 @@ +warning: found keyword `if` - should this be a `@if`? + --> $DIR/warn_on_keyword_names.rs:9:9 + | +9 | if {} + | ^^ +