From 004fc4e09a0f85929af81812d829486d2c0775f9 Mon Sep 17 00:00:00 2001
From: mcarton <cartonmartin+git@gmail.com>
Date: Mon, 7 Mar 2016 18:40:13 +0100
Subject: [PATCH 1/2] Split travis tests into build + test

---
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 1029c67ee6b..6df1b49e484 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,4 +4,5 @@ sudo: false
 
 script:
  - python util/update_lints.py -c
+ - cargo build --features debugging
  - cargo test --features debugging

From 6ad2f645be848f4c9e0be136a612271a6bf202f1 Mon Sep 17 00:00:00 2001
From: mcarton <cartonmartin+git@gmail.com>
Date: Mon, 7 Mar 2016 19:08:46 +0100
Subject: [PATCH 2/2] Put regex_macros tests in a separate feature

---
 .travis.yml                                  |  3 +++
 Cargo.toml                                   | 10 +++++-----
 tests/compile-fail-regex_macros/regex.rs     | 12 ++++++++++++
 tests/compile-fail/regex.rs                  |  9 +--------
 tests/compile-test.rs                        |  8 ++++++++
 tests/run-pass-regex_macros/mut_mut_macro.rs | 12 ++++++++++++
 tests/{ => run-pass}/mut_mut_macro.rs        | 14 ++------------
 7 files changed, 43 insertions(+), 25 deletions(-)
 create mode 100644 tests/compile-fail-regex_macros/regex.rs
 create mode 100644 tests/run-pass-regex_macros/mut_mut_macro.rs
 rename tests/{ => run-pass}/mut_mut_macro.rs (64%)

diff --git a/.travis.yml b/.travis.yml
index 6df1b49e484..d0c614aaae9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,3 +6,6 @@ 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
diff --git a/Cargo.toml b/Cargo.toml
index 97dcb20390b..5fede91ea2f 100644
--- a/Cargo.toml
+++ b/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"]
diff --git a/tests/compile-fail-regex_macros/regex.rs b/tests/compile-fail-regex_macros/regex.rs
new file mode 100644
index 00000000000..aab196fb795
--- /dev/null
+++ b/tests/compile-fail-regex_macros/regex.rs
@@ -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!(_)`
+}
diff --git a/tests/compile-fail/regex.rs b/tests/compile-fail/regex.rs
index df52cc3dff0..606c3d513b2 100644
--- a/tests/compile-fail/regex.rs
+++ b/tests/compile-fail/regex.rs
@@ -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();
 }
diff --git a/tests/compile-test.rs b/tests/compile-test.rs
index 822d9339ba3..ff2d94d2777 100644
--- a/tests/compile-test.rs
+++ b/tests/compile-test.rs
@@ -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");
+}
diff --git a/tests/run-pass-regex_macros/mut_mut_macro.rs b/tests/run-pass-regex_macros/mut_mut_macro.rs
new file mode 100644
index 00000000000..92b44dbdd48
--- /dev/null
+++ b/tests/run-pass-regex_macros/mut_mut_macro.rs
@@ -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"));
+}
diff --git a/tests/mut_mut_macro.rs b/tests/run-pass/mut_mut_macro.rs
similarity index 64%
rename from tests/mut_mut_macro.rs
rename to tests/run-pass/mut_mut_macro.rs
index 67d73ce0ac4..e652862c4ff 100644
--- a/tests/mut_mut_macro.rs
+++ b/tests/run-pass/mut_mut_macro.rs
@@ -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();