From f1f67e5aac3552c46ed0fabc6505b2f04ea1ef19 Mon Sep 17 00:00:00 2001
From: Isaac van Bakel <ivb@vanbakel.io>
Date: Fri, 19 Oct 2018 22:39:11 +0100
Subject: [PATCH 1/8] Added compile tests to check keyword warning

compiletest_rs is now used to check that elements which have keyword
names are now warned against in a UI test.
compiletest_rs has been added as a build dependency.
---
 maud_macros/Cargo.toml                            |  3 +++
 maud_macros/tests/warnings.rs                     | 15 +++++++++++++++
 .../tests/warnings/warn_on_keyword_names.rs       | 11 +++++++++++
 .../tests/warnings/warn_on_keyword_names.stderr   |  6 ++++++
 4 files changed, 35 insertions(+)
 create mode 100644 maud_macros/tests/warnings.rs
 create mode 100644 maud_macros/tests/warnings/warn_on_keyword_names.rs
 create mode 100644 maud_macros/tests/warnings/warn_on_keyword_names.stderr

diff --git a/maud_macros/Cargo.toml b/maud_macros/Cargo.toml
index 698cb92..292f890 100644
--- a/maud_macros/Cargo.toml
+++ b/maud_macros/Cargo.toml
@@ -16,6 +16,9 @@ literalext = { version = "0.1", default-features = false, features = ["proc-macr
 matches = "0.1.6"
 maud_htmlescape = { version = "0.17.0", path = "../maud_htmlescape" }
 
+[dev-dependencies]
+compiletest_rs = "0.3.14"
+
 [lib]
 name = "maud_macros"
 proc-macro = true
diff --git a/maud_macros/tests/warnings.rs b/maud_macros/tests/warnings.rs
new file mode 100644
index 0000000..5e635f9
--- /dev/null
+++ b/maud_macros/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_macros/tests/warnings/warn_on_keyword_names.rs b/maud_macros/tests/warnings/warn_on_keyword_names.rs
new file mode 100644
index 0000000..3a24674
--- /dev/null
+++ b/maud_macros/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() {
+    let markup = html!{ 
+        if {} //~WARNING found keyword `if` - should this be a `@if`?
+    };
+}
diff --git a/maud_macros/tests/warnings/warn_on_keyword_names.stderr b/maud_macros/tests/warnings/warn_on_keyword_names.stderr
new file mode 100644
index 0000000..d2d5e31
--- /dev/null
+++ b/maud_macros/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 {} //~WARNING found keyword `if` - should this be a `@if`?
+  |         ^^
+

From ccf54ad6eba3ed7d42fd4e0310283e7b0d15124a Mon Sep 17 00:00:00 2001
From: Isaac van Bakel <ivb@vanbakel.io>
Date: Wed, 24 Oct 2018 17:34:00 +0100
Subject: [PATCH 2/8] Try to change travis build ordering to fix compiletests

Multiple versions of the maud base crate get built, so compiletest
doesn't know which one to use in the same way that cargo would.
A possible solution is to build a canonical version of the crate first
(no features) and then explicitly run the compiletest tests. After, we
run builds and tests as normal, excluding the compiletest tests.
---
 .travis.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 588975f..6305646 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,10 +6,12 @@ before_script:
   - rustup component add clippy-preview --toolchain=nightly
 
 script:
+  - (cd maud && cargo build) 
+  - (cd maud_macros && cargo test)
   - (cd maud && cargo build --features="iron")
   - (cd maud && cargo build --features="rocket")
   - (cd maud && cargo build --features="actix-web")
-  - cargo test --all
+  - cargo test --all --exclude maud_macros
   - (cd benchmarks && cargo bench --no-run)
   - |
     CLIPPY_STATUS=0

From 19bb1b351bd1a4e87cb24fcfdd22bd1bbe3ff28d Mon Sep 17 00:00:00 2001
From: Isaac van Bakel <ivb@vanbakel.io>
Date: Sun, 4 Nov 2018 16:47:30 +0000
Subject: [PATCH 3/8] Remove redundant warning comment in UI test

---
 maud_macros/tests/warnings/warn_on_keyword_names.rs     | 2 +-
 maud_macros/tests/warnings/warn_on_keyword_names.stderr | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/maud_macros/tests/warnings/warn_on_keyword_names.rs b/maud_macros/tests/warnings/warn_on_keyword_names.rs
index 3a24674..a26c10f 100644
--- a/maud_macros/tests/warnings/warn_on_keyword_names.rs
+++ b/maud_macros/tests/warnings/warn_on_keyword_names.rs
@@ -6,6 +6,6 @@ use maud_macros::html;
 
 fn main() {
     let markup = html!{ 
-        if {} //~WARNING found keyword `if` - should this be a `@if`?
+        if {}
     };
 }
diff --git a/maud_macros/tests/warnings/warn_on_keyword_names.stderr b/maud_macros/tests/warnings/warn_on_keyword_names.stderr
index d2d5e31..70cacc2 100644
--- a/maud_macros/tests/warnings/warn_on_keyword_names.stderr
+++ b/maud_macros/tests/warnings/warn_on_keyword_names.stderr
@@ -1,6 +1,6 @@
 warning: found keyword `if` - should this be a `@if`?
  --> $DIR/warn_on_keyword_names.rs:9:9
   |
-9 |         if {} //~WARNING found keyword `if` - should this be a `@if`?
+9 |         if {}
   |         ^^
 

From 59d9ec9620a225c3e295861dbff4eb47a578879b Mon Sep 17 00:00:00 2001
From: Isaac van Bakel <ivb@vanbakel.io>
Date: Mon, 5 Nov 2018 23:31:36 +0000
Subject: [PATCH 4/8] Moved compiletests into the maud crate

---
 .travis.yml                                                | 7 ++++---
 maud/Cargo.toml                                            | 4 ++++
 {maud_macros => maud}/tests/warnings.rs                    | 0
 .../tests/warnings/warn_on_keyword_names.rs                | 0
 .../tests/warnings/warn_on_keyword_names.stderr            | 0
 maud_macros/Cargo.toml                                     | 3 ---
 6 files changed, 8 insertions(+), 6 deletions(-)
 rename {maud_macros => maud}/tests/warnings.rs (100%)
 rename {maud_macros => maud}/tests/warnings/warn_on_keyword_names.rs (100%)
 rename {maud_macros => maud}/tests/warnings/warn_on_keyword_names.stderr (100%)

diff --git a/.travis.yml b/.travis.yml
index 6305646..682d284 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,12 +6,13 @@ before_script:
   - rustup component add clippy-preview --toolchain=nightly
 
 script:
-  - (cd maud && cargo build) 
-  - (cd maud_macros && cargo test)
   - (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 --test warnings 
   - (cd maud && cargo build --features="rocket")
   - (cd maud && cargo build --features="actix-web")
-  - cargo test --all --exclude maud_macros
+  - cargo test --all --exclude warnings
   - (cd benchmarks && cargo bench --no-run)
   - |
     CLIPPY_STATUS=0
diff --git a/maud/Cargo.toml b/maud/Cargo.toml
index 1a56fd0..b30c2b5 100644
--- a/maud/Cargo.toml
+++ b/maud/Cargo.toml
@@ -19,6 +19,10 @@ 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_macros/tests/warnings.rs b/maud/tests/warnings.rs
similarity index 100%
rename from maud_macros/tests/warnings.rs
rename to maud/tests/warnings.rs
diff --git a/maud_macros/tests/warnings/warn_on_keyword_names.rs b/maud/tests/warnings/warn_on_keyword_names.rs
similarity index 100%
rename from maud_macros/tests/warnings/warn_on_keyword_names.rs
rename to maud/tests/warnings/warn_on_keyword_names.rs
diff --git a/maud_macros/tests/warnings/warn_on_keyword_names.stderr b/maud/tests/warnings/warn_on_keyword_names.stderr
similarity index 100%
rename from maud_macros/tests/warnings/warn_on_keyword_names.stderr
rename to maud/tests/warnings/warn_on_keyword_names.stderr
diff --git a/maud_macros/Cargo.toml b/maud_macros/Cargo.toml
index 292f890..698cb92 100644
--- a/maud_macros/Cargo.toml
+++ b/maud_macros/Cargo.toml
@@ -16,9 +16,6 @@ literalext = { version = "0.1", default-features = false, features = ["proc-macr
 matches = "0.1.6"
 maud_htmlescape = { version = "0.17.0", path = "../maud_htmlescape" }
 
-[dev-dependencies]
-compiletest_rs = "0.3.14"
-
 [lib]
 name = "maud_macros"
 proc-macro = true

From 2e41db8c70e66fa9a73f34a8d89beb8b84b6b06f Mon Sep 17 00:00:00 2001
From: Chris Wong <lambda.fairy@gmail.com>
Date: Sun, 9 Dec 2018 10:46:05 +1300
Subject: [PATCH 5/8] Run all the tests at the beginning

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

diff --git a/.travis.yml b/.travis.yml
index 682d284..d7df365 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,10 +9,9 @@ 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 --test warnings 
+  - cargo test --all
   - (cd maud && cargo build --features="rocket")
   - (cd maud && cargo build --features="actix-web")
-  - cargo test --all --exclude warnings
   - (cd benchmarks && cargo bench --no-run)
   - |
     CLIPPY_STATUS=0

From 6d9aa86506d9d5141f288154bb6c3066f32e342b Mon Sep 17 00:00:00 2001
From: Chris Wong <lambda.fairy@gmail.com>
Date: Sun, 9 Dec 2018 10:48:49 +1300
Subject: [PATCH 6/8] Fix formatting

---
 maud/Cargo.toml                              | 1 -
 maud/tests/warnings/warn_on_keyword_names.rs | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/maud/Cargo.toml b/maud/Cargo.toml
index b30c2b5..7fc6a5b 100644
--- a/maud/Cargo.toml
+++ b/maud/Cargo.toml
@@ -22,7 +22,6 @@ 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/warn_on_keyword_names.rs b/maud/tests/warnings/warn_on_keyword_names.rs
index a26c10f..fcdbc00 100644
--- a/maud/tests/warnings/warn_on_keyword_names.rs
+++ b/maud/tests/warnings/warn_on_keyword_names.rs
@@ -5,7 +5,7 @@ extern crate maud_macros;
 use maud_macros::html;
 
 fn main() {
-    let markup = html!{ 
+    html! {
         if {}
     };
 }

From c70bd98656672bd2f138fa79ad9b16bf07a5a7b2 Mon Sep 17 00:00:00 2001
From: Chris Wong <lambda.fairy@gmail.com>
Date: Sun, 9 Dec 2018 11:14:50 +1300
Subject: [PATCH 7/8] Skip Clippy if it is missing

---
 .travis.yml | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index d7df365..ebe0182 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,7 +3,9 @@ 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")
@@ -14,8 +16,10 @@ script:
   - (cd maud && cargo build --features="actix-web")
   - (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

From 4b2707c51ee2d5f022cc67eedd2edfd2c6de7894 Mon Sep 17 00:00:00 2001
From: Chris Wong <lambda.fairy@gmail.com>
Date: Sun, 9 Dec 2018 11:38:27 +1300
Subject: [PATCH 8/8] Remove `#![feature(tool_lints)]`

---
 maud_macros/src/lib.rs | 1 -
 1 file changed, 1 deletion(-)

diff --git a/maud_macros/src/lib.rs b/maud_macros/src/lib.rs
index f1f08dd..3aedfe8 100644
--- a/maud_macros/src/lib.rs
+++ b/maud_macros/src/lib.rs
@@ -3,7 +3,6 @@
 #![feature(proc_macro_hygiene)]
 #![feature(proc_macro_quote)]
 #![feature(proc_macro_span)]
-#![feature(tool_lints)]
 
 #![doc(html_root_url = "https://docs.rs/maud_macros/0.18.1")]