mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Merge pull request #745 from mcarton/tests
Don’t fail tests when regex_macros does not compile
This commit is contained in:
commit
88ac226ac2
7 changed files with 44 additions and 25 deletions
|
@ -4,4 +4,8 @@ sudo: false
|
|||
|
||||
script:
|
||||
- python util/update_lints.py -c
|
||||
- cargo build --features debugging
|
||||
- cargo test --features debugging
|
||||
|
||||
# only test regex_macros if it compiles
|
||||
- if [[ "$(cargo build --features 'debugging test-regex_macros')" = 101 ]]; then cargo test --features 'debugging test-regex_macros'; fi
|
||||
|
|
10
Cargo.toml
10
Cargo.toml
|
@ -18,17 +18,17 @@ name = "clippy"
|
|||
plugin = true
|
||||
|
||||
[dependencies]
|
||||
unicode-normalization = "0.1"
|
||||
semver = "0.2.1"
|
||||
regex-syntax = "0.2.2"
|
||||
regex_macros = { version = "0.1.28", optional = true }
|
||||
semver = "0.2.1"
|
||||
unicode-normalization = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
compiletest_rs = "0.0.11"
|
||||
regex = "0.1.47"
|
||||
regex_macros = "0.1.28"
|
||||
lazy_static = "0.1.15"
|
||||
regex = "0.1.47"
|
||||
rustc-serialize = "0.3"
|
||||
|
||||
[features]
|
||||
|
||||
debugging = []
|
||||
test-regex_macros = ["regex_macros"]
|
||||
|
|
12
tests/compile-fail-regex_macros/regex.rs
Normal file
12
tests/compile-fail-regex_macros/regex.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy, regex_macros)]
|
||||
|
||||
#![allow(unused)]
|
||||
#![deny(invalid_regex, trivial_regex, regex_macro)]
|
||||
|
||||
extern crate regex;
|
||||
|
||||
fn main() {
|
||||
let some_regex = regex!("for real!"); //~ERROR `regex!(_)`
|
||||
let other_regex = regex!("[a-z]_[A-Z]"); //~ERROR `regex!(_)`
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy, regex_macros)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
#![allow(unused)]
|
||||
#![deny(invalid_regex, trivial_regex, regex_macro)]
|
||||
|
@ -70,14 +70,7 @@ fn trivial_regex() {
|
|||
let non_trivial_ends_with = Regex::new("foo|bar");
|
||||
}
|
||||
|
||||
fn regex_macro() {
|
||||
let some_regex = regex!("for real!"); //~ERROR `regex!(_)`
|
||||
let other_regex = regex!("[a-z]_[A-Z]"); //~ERROR `regex!(_)`
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
regex_macro();
|
||||
syntax_error();
|
||||
trivial_regex();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,15 @@ fn run_mode(mode: &'static str) {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "test-regex_macros"))]
|
||||
fn compile_test() {
|
||||
run_mode("run-pass");
|
||||
run_mode("compile-fail");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "test-regex_macros")]
|
||||
fn compile_test() {
|
||||
run_mode("run-pass-regex_macros");
|
||||
run_mode("compile-fail-regex_macros");
|
||||
}
|
||||
|
|
12
tests/run-pass-regex_macros/mut_mut_macro.rs
Normal file
12
tests/run-pass-regex_macros/mut_mut_macro.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy, regex_macros)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate regex;
|
||||
|
||||
#[deny(mut_mut)]
|
||||
#[allow(regex_macro)]
|
||||
fn main() {
|
||||
let pattern = regex!(r"^(?P<level>[#]+)\s(?P<title>.+)$");
|
||||
assert!(pattern.is_match("# headline"));
|
||||
}
|
|
@ -1,24 +1,14 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy, regex_macros)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate regex;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[test]
|
||||
#[deny(mut_mut)]
|
||||
#[allow(regex_macro)]
|
||||
fn test_regex() {
|
||||
let pattern = regex!(r"^(?P<level>[#]+)\s(?P<title>.+)$");
|
||||
assert!(pattern.is_match("# headline"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[deny(mut_mut)]
|
||||
#[allow(unused_variables, unused_mut)]
|
||||
fn test_lazy_static() {
|
||||
fn main() {
|
||||
lazy_static! {
|
||||
static ref MUT_MAP : HashMap<usize, &'static str> = {
|
||||
let mut m = HashMap::new();
|
Loading…
Reference in a new issue