move to cargo clippy instead of using the clippy plugin (#733)

* move to cargo clippy instead of using the clippy plugin

fixes #729

* non-exectable scripts must be run with `sh`

* don't build serde in the clippy travis job

* only run clippy tests if installing clippy succeeds

* why is travis so picky?

* no more serde_codegen

* serde_test_suite_deps has no features

* don't use empty loops, llvm optimizes them to undefined behaviour

* abort the clippy job when clippy lints are triggered

* use caches on travis to speed up builds

* why are we even using `travis-cargo`?

* need to reinstall clippy frequently due to nightly updates

* command line tools are hard
This commit is contained in:
Oliver Schneider 2017-01-31 18:09:37 +01:00 committed by David Tolnay
parent 74cf80989d
commit 368784949e
13 changed files with 38 additions and 45 deletions

View File

@ -1,5 +1,6 @@
sudo: false
language: rust
cache: cargo
# run builds for all the trains (and more)
rust:
@ -8,20 +9,16 @@ rust:
- beta
- nightly
matrix:
include:
- rust: nightly
env: CLIPPY=true
before_script:
- pip install 'travis-cargo<0.2' --user
- export PATH=$HOME/.local/bin:$PATH
script:
- (cd serde && travis-cargo build)
- (cd serde && travis-cargo --only beta test)
- (cd serde && travis-cargo --only nightly test -- --features unstable-testing)
- (cd serde && travis-cargo build -- --no-default-features)
- (cd serde && travis-cargo --only nightly build -- --no-default-features --features alloc)
- (cd serde && travis-cargo --only nightly build -- --no-default-features --features collections)
- (cd test_suite && travis-cargo --only beta test)
- (cd test_suite/deps && travis-cargo --only nightly build && cd .. && travis-cargo --only nightly test -- --features unstable-testing)
- (cd test_suite/no_std && travis-cargo --only nightly build)
script: sh travis.sh
env:
global:

View File

@ -22,10 +22,7 @@ std = []
unstable = []
alloc = ["unstable"]
collections = ["alloc"]
unstable-testing = ["clippy", "unstable", "std"]
[dependencies]
clippy = { version = "0.*", optional = true }
unstable-testing = ["unstable", "std"]
[dev-dependencies]
serde_derive = "0.9"

View File

@ -64,9 +64,7 @@
#![cfg_attr(feature = "unstable", feature(nonzero, inclusive_range, zero_one))]
#![cfg_attr(feature = "alloc", feature(alloc))]
#![cfg_attr(feature = "collections", feature(collections, enumset))]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "clippy", allow(linkedlist, type_complexity, doc_markdown))]
#![cfg_attr(feature = "cargo-clippy", allow(linkedlist, type_complexity, doc_markdown))]
#![deny(missing_docs)]
#[cfg(feature = "collections")]

View File

@ -10,11 +10,7 @@ documentation = "https://docs.serde.rs/serde_codegen_internals/"
keywords = ["serde", "serialization"]
include = ["Cargo.toml", "src/**/*.rs"]
[features]
unstable-testing = ["clippy"]
[dependencies]
clippy = { version = "0.*", optional = true }
syn = "0.11"
[badges]

View File

@ -1,6 +1,3 @@
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "clippy", feature(plugin))]
extern crate syn;
pub mod ast;

View File

@ -12,7 +12,6 @@ include = ["Cargo.toml", "src/**/*.rs"]
[features]
unstable = []
unstable-testing = ["clippy", "serde_codegen_internals/unstable-testing"]
[badges]
travis-ci = { repository = "serde-rs/serde" }
@ -22,7 +21,6 @@ name = "serde_derive"
proc-macro = true
[dependencies]
clippy = { version = "0.*", optional = true }
quote = "0.3.8"
serde_codegen_internals = { version = "=0.12.0", default-features = false, path = "../serde_codegen_internals" }
syn = { version = "0.11", features = ["aster", "visit"] }

View File

@ -1,7 +1,5 @@
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", allow(too_many_arguments))]
#![cfg_attr(feature = "clippy", allow(used_underscore_binding))]
#![cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#![cfg_attr(feature = "cargo-clippy", allow(used_underscore_binding))]
// The `quote!` macro requires deep recursion.
#![recursion_limit = "192"]

View File

@ -11,11 +11,7 @@ readme = "../README.md"
keywords = ["serde", "serialization"]
include = ["Cargo.toml", "src/**/*.rs"]
[features]
unstable-testing = ["clippy"]
[dependencies]
clippy = { version = "0.*", optional = true }
serde = { version = "0.9", path = "../serde" }
[badges]

View File

@ -1,6 +1,3 @@
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
extern crate serde;
mod assert;

View File

@ -13,11 +13,8 @@ publish = false
[features]
unstable-testing = [
"clippy",
"compiletest_rs",
"serde/unstable-testing",
"serde_derive/unstable-testing",
"serde_test/unstable-testing",
]
[dev-dependencies]
@ -28,7 +25,6 @@ serde_derive = { path = "../serde_derive" }
serde_test = { path = "../serde_test" }
[dependencies]
clippy = { version = "0.*", optional = true }
compiletest_rs = { version = "0.2", optional = true }
[[test]]

View File

@ -21,7 +21,9 @@ pub extern fn rust_eh_unwind_resume() {}
pub extern fn rust_begin_panic(_msg: core::fmt::Arguments,
_file: &'static str,
_line: u32) -> ! {
loop {}
unsafe {
libc::abort()
}
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,3 @@
#![cfg_attr(feature = "clippy", feature(plugin))]
#![cfg_attr(feature = "clippy", plugin(clippy))]
#![cfg_attr(feature = "unstable-testing", feature(test, non_ascii_idents))]
#[cfg(feature = "unstable-testing")]

24
travis.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
set -ev
if [ "${CLIPPY}" = "true" ]; then
if cargo install clippy -f; then
(cd serde && cargo clippy --features unstable-testing -- -Dclippy)
(cd serde_derive && cargo clippy --features unstable-testing -- -Dclippy)
(cd test_suite && cargo clippy --features unstable-testing -- -Dclippy)
(cd test_suite/deps && cargo clippy -- -Dclippy)
(cd test_suite/no_std && cargo clippy -- -Dclippy)
else
echo "could not compile clippy, ignoring clippy tests"
fi
else
(cd serde && travis-cargo build)
(cd serde && travis-cargo --only beta test)
(cd serde && travis-cargo --only nightly test -- --features unstable-testing)
(cd serde && travis-cargo build -- --no-default-features)
(cd serde && travis-cargo --only nightly build -- --no-default-features --features alloc)
(cd serde && travis-cargo --only nightly build -- --no-default-features --features collections)
(cd test_suite && travis-cargo --only beta test)
(cd test_suite/deps && travis-cargo --only nightly build)
(cd test_suite travis-cargo --only nightly test -- --features unstable-testing)
(cd test_suite/no_std && travis-cargo --only nightly build)
fi