Merge branch 'keyword_warn_compiletest'

This commit is contained in:
Chris Wong 2018-12-09 11:49:50 +13:00
commit b1dd7b729f
5 changed files with 48 additions and 7 deletions

View file

@ -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

View file

@ -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" }

15
maud/tests/warnings.rs Normal file
View file

@ -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);
}

View file

@ -0,0 +1,11 @@
#![feature(proc_macro_hygiene)]
extern crate maud_macros;
use maud_macros::html;
fn main() {
html! {
if {}
};
}

View file

@ -0,0 +1,6 @@
warning: found keyword `if` - should this be a `@if`?
--> $DIR/warn_on_keyword_names.rs:9:9
|
9 | if {}
| ^^