Repository: clap-rs/clap
Pull request #1667 (2020-02-04 08:41:20)

Several things
* Updated `Cargo.toml` for both crates to be consistent with each other
  * Removed `exclude` key since it is exclusive with `include`
  * Remove things from profiles when they are using default values anyway
* Used `workspace.default-members`
* Cherry pick [this](https://github.com/clap-rs/clap/commit/a525b57cb5a9e12df068c703dd6739f93774cba5) commit from 2.x branch which does not exist in master
* Put the test helper into `tests` folder.

  > The old tests used the include!() macro, which is quite hacky, and hurts compile times


Patch:
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index 8abb1158..cd523a41 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -48,11 +48,11 @@ stages:
             displayName: Caching compiled
           - script: rustup default $(rust)-$(target)
             displayName: Install rust
-          - script: cargo test --all --no-default-features
+          - script: cargo test --no-default-features
             displayName: Test without default features
             env:
               RUST_BACKTRACE: full
-          - script: cargo test --all --features "yaml unstable"
+          - script: cargo test --features "yaml unstable"
             displayName: Test with most features
             env:
               RUST_BACKTRACE: full
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index f2d242c8..f8912b92 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -9,8 +9,8 @@ Another really great way to help is if you find an interesting, or helpful way i
 To test with all features both enabled and disabled, you can run these commands:
 
 ```sh
-$ cargo test --all --no-default-features
-$ cargo test --all --features "yaml unstable"
+$ cargo test --no-default-features
+$ cargo test --features "yaml unstable"
 ```
 
 Alternatively, if you have [`just`](https://github.com/casey/just) installed you can run the prebuilt recipes. *Not* using `just` is perfectly fine as well, it simply bundles commands automatically.
@@ -26,7 +26,7 @@ From here on, I will list the appropriate `cargo` command as well as the `just`
 Sometimes it's helpful to only run a subset of the tests, which can be done via:
 
 ```sh
-$ cargo test --all --test <test_name>
+$ cargo test --test <test_name>
 
 # Or
 
@@ -40,8 +40,8 @@ During the CI process `clap` runs against many different lints using [`clippy`](
 In order to check the code for lints and to format it run either:
 
 ```sh
-$ cargo clippy --all --lib --features "yaml unstable" -- -D warnings
-$ cargo clippy --all --tests --examples --features "yaml unstable"
+$ cargo clippy --lib --features "yaml unstable" -- -D warnings
+$ cargo clippy --tests --examples --features "yaml unstable"
 $ cargo fmt -- --check
 
 # Or
@@ -54,10 +54,10 @@ $ just lint
 Another helpful technique is to see the `clap` debug output while developing features. In order to see the debug output while running the full test suite or individual tests, run:
 
 ```sh
-$ cargo test --all --features debug
+$ cargo test --features debug
 
 # Or for individual tests
-$ cargo test --all --test <test_name> --features debug
+$ cargo test --test <test_name> --features debug
 
 # The corresponding just command for individual debugging tests is:
 $ just debug <test_name>
diff --git a/.gitignore b/.gitignore
index 6a097d46..fb7ecb01 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,8 +8,7 @@
 *.exe
 
 # Generated by Cargo
-/target/
-/clap-test/target/
+target/
 
 # Cargo files
 Cargo.lock
diff --git a/.travis.yml b/.travis.yml
index c1425ea9..669b59dc 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -43,8 +43,8 @@ jobs:
         - rustup component add rustfmt
       script:
         - echo "Checking codebase with Clippy release `cargo clippy --version`."
-        - cargo clippy --all --lib --features "yaml unstable" -- -D warnings
-        - cargo clippy --all --tests --examples --features "yaml unstable"
+        - cargo clippy --lib --features "yaml unstable" -- -D warnings
+        - cargo clippy --tests --examples --features "yaml unstable"
         - cargo fmt -- --check
     - rust: nightly
       env:
@@ -66,8 +66,8 @@ jobs:
       script:
         - cargo tarpaulin --workspace --features "yaml unstable" --ciserver travis-ci --coveralls $TRAVIS_JOB_ID
 script:
-  - cargo test --all --no-default-features
-  - cargo test --all --features yaml unstable
+  - cargo test --no-default-features
+  - cargo test --features yaml unstable
 notifications:
   email: false
 env:
diff --git a/Cargo.toml b/Cargo.toml
index 989a01e2..d956df5a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,31 +1,17 @@
 [package]
 name = "clap"
 version = "3.0.0-beta.1"
+edition = "2018"
 authors = ["Kevin K. <kbknapp@gmail.com>"]
-exclude = [
-	".github/*",
-	"examples/*",
-	"tests/*",
-	"benches/*",
-	"clap-perf/*",
-	"etc/*",
-	"*.png",
-	"*.dot",
-	"*.yml",
-	"*.toml",
-	"*.md",
-	"clap-test.rs"
-]
 include = [
 	"src/**/*",
 	"Cargo.toml",
 	"README.md"
 ]
+description = "A simple to use, efficient, and full-featured Command Line Argument Parser"
 repository = "https://github.com/clap-rs/clap"
 documentation = "https://docs.rs/clap/"
 homepage = "https://clap.rs/"
-readme = "README.md"
-license = "MIT OR Apache-2.0"
 keywords = [
 	"argument",
 	"cli",
@@ -34,10 +20,8 @@ keywords = [
 	"parse"
 ]
 categories = ["command-line-interface"]
-description = """
-A simple to use, efficient, and full-featured Command Line Argument Parser
-"""
-edition = "2018"
+license = "MIT OR Apache-2.0"
+readme = "README.md"
 
 [badges]
 travis-ci = { repository = "clap-rs/clap", branch = "master" }
@@ -75,34 +59,22 @@ color       = ["ansi_term", "atty"]
 wrap_help   = ["term_size", "textwrap/term_size"]
 derive      = ["clap_derive"]
 yaml        = ["yaml-rust"]
+no_cargo    = [] # Enable if you're not using Cargo, disables Cargo-env-var-dependent macros
 unstable    = [] # for building with unstable clap features (doesn't require nightly Rust) (currently none)
 nightly     = [] # for building with unstable Rust features (currently none)
 debug       = [] # Enables debug messages
-no_cargo    = [] # Enable if you're not using Cargo, disables Cargo-env-var-dependent macros
 doc         = ["yaml"] # All the features which add to documentation
 
 [profile.dev]
-opt-level = 0
-debug = true
-rpath = false
-lto = false
-debug-assertions = true
 codegen-units = 4
 
 [profile.test]
 opt-level = 1
 debug = true
-rpath = false
-lto = false
-debug-assertions = true
 codegen-units = 4
 
 [profile.bench]
-opt-level = 3
-debug = false
-rpath = false
 lto = true
-debug-assertions = false
 codegen-units = 1
 
 [package.metadata.docs.rs]
@@ -112,3 +84,6 @@ features = ["doc"]
 members = [
 	"clap_derive",
 ]
+default-members = [
+	".", "clap_derive",
+]
diff --git a/clap_derive/Cargo.toml b/clap_derive/Cargo.toml
index cfbdf352..489c031d 100644
--- a/clap_derive/Cargo.toml
+++ b/clap_derive/Cargo.toml
@@ -3,18 +3,35 @@ name = "clap_derive"
 version = "3.0.0-beta.1"
 edition = "2018"
 authors = [
-    "Guillaume Pinot <texitoi@texitoi.eu>",
-    "Kevin K. <kbknapp@gmail.com>",
-    "hoverbear <andrew@hoverbear.org>"
+	"Guillaume Pinot <texitoi@texitoi.eu>",
+	"Kevin K. <kbknapp@gmail.com>",
+	"hoverbear <andrew@hoverbear.org>"
+]
+include = [
+	"src/**/*",
+	"Cargo.toml",
+	"README.md"
 ]
 description = "Parse command line argument by defining a struct, derive crate."
+repository = "https://github.com/clap-rs/clap/tree/master/clap_derive"
 documentation = "https://docs.rs/clap_derive"
-repository = "https://github.com/clap-rs/clap_derive"
-keywords = ["clap", "cli", "derive", "proc_macro", "parse"]
+homepage = "https://clap.rs/"
+keywords = [
+	"clap",
+	"cli",
+	"derive",
+	"proc_macro",
+	"parse"
+]
 categories = ["command-line-interface", "development-tools::procedural-macro-helpers"]
-license = "Apache-2.0/MIT"
+license = "MIT OR Apache-2.0"
 readme = "README.md"
 
+[badges]
+is-it-maintained-issue-resolution = { repository = "clap-rs/clap" }
+is-it-maintained-open-issues = { repository = "clap-rs/clap" }
+maintenance = {status = "actively-developed"}
+
 [lib]
 proc-macro = true
 
@@ -32,7 +49,10 @@ rustversion = "1"
 
 [features]
 default = []
+unstable = []
 nightly = []
-lints = []
 debug = []
 doc = []
+
+[package.metadata.docs.rs]
+features = ["doc"]
diff --git a/justfile b/justfile
index 2fa2a859..e6e9e440 100644
--- a/justfile
+++ b/justfile
@@ -13,13 +13,13 @@
 	rm CONTRIBUTORS.md.bak
 
 run-test TESTG TEST="":
-	cargo test --all --test {{TESTG}} -- {{TEST}}
+	cargo test --test {{TESTG}} -- {{TEST}}
 
 debug TESTG TEST="":
-	cargo test --all --test {{TESTG}} --features debug -- {{TEST}}
+	cargo test --test {{TESTG}} --features debug -- {{TEST}}
 
 run-tests:
-	cargo test --all --features "yaml unstable"
+	cargo test --features "yaml unstable"
 
 @bench:
 	cargo bench
@@ -27,8 +27,8 @@ run-tests:
 @lint:
 	rustup add component clippy
 	rustup add component rustfmt
-	cargo clippy --all --lib --features "yaml unstable" -- -D warnings
-	cargo clippy --all --tests --examples --features "yaml unstable"
+	cargo clippy --lib --features "yaml unstable" -- -D warnings
+	cargo clippy --tests --examples --features "yaml unstable"
 	cargo fmt -- --check
 
 clean:
diff --git a/src/parse/parser.rs b/src/parse/parser.rs
index 1f4ee098..df786802 100644
--- a/src/parse/parser.rs
+++ b/src/parse/parser.rs
@@ -735,6 +735,12 @@ where
                 .filter(|s| starts(s, &*arg_os))
                 .collect::<Vec<_>>();
 
+            for sc in &v {
+                if OsStr::new(sc) == arg_os {
+                    return (true, Some(sc));
+                }
+            }
+
             if v.len() == 1 {
                 return (true, Some(v[0]));
             }


Test patch:
diff --git a/clap-test.rs b/clap-test.rs
deleted file mode 100644
index 757f56f1..00000000
--- a/clap-test.rs
+++ /dev/null
@@ -1,87 +0,0 @@
-#[allow(unused_imports, dead_code)]
-mod test {
-    use std::str;
-    use std::io::{Cursor, Write};
-
-    use regex::Regex;
-
-    use clap::{App, Arg, ArgGroup};
-
-    fn compare<S, S2>(l: S, r: S2) -> bool
-        where S: AsRef<str>,
-              S2: AsRef<str>
-    {
-        let re = Regex::new("\x1b[^m]*m").unwrap();
-        // Strip out any mismatching \r character on windows that might sneak in on either side
-        let ls = l.as_ref().trim().replace("\r", "");
-        let rs = r.as_ref().trim().replace("\r", "");
-        let left = re.replace_all(&*ls, "");
-        let right = re.replace_all(&*rs, "");
-        let b = left == right;
-        if !b {
-            println!("");
-            println!("--> left");
-            println!("{}", left);
-            println!("--> right");
-            println!("{}", right);
-            println!("--")
-        }
-        b
-    }
-
-    pub fn compare_output(l: App, args: &str, right: &str, stderr: bool) -> bool {
-        let mut buf = Cursor::new(Vec::with_capacity(50));
-        let res = l.try_get_matches_from(args.split(' ').collect::<Vec<_>>());
-        let err = res.unwrap_err();
-        err.write_to(&mut buf).unwrap();
-        let content = buf.into_inner();
-        let left = String::from_utf8(content).unwrap();
-        assert_eq!(stderr, err.use_stderr(),
-            "Should Use STDERR failed. Should be {} but is {}", stderr, err.use_stderr());
-        compare(left, right)
-    }
-
-    pub fn compare_output2(l: App, args: &str, right1: &str, right2: &str, stderr: bool) -> bool {
-        let mut buf = Cursor::new(Vec::with_capacity(50));
-        let res = l.try_get_matches_from(args.split(' ').collect::<Vec<_>>());
-        let err = res.unwrap_err();
-        err.write_to(&mut buf).unwrap();
-        let content = buf.into_inner();
-        let left = String::from_utf8(content).unwrap();
-        assert_eq!(stderr, err.use_stderr());
-        compare(&*left, right1) || compare(&*left, right2)
-    }
-
-    // Legacy tests from the pyhton script days
-
-    pub fn complex_app() -> App<'static> {
-        let opt3_vals = ["fast", "slow"];
-        let pos3_vals = ["vi", "emacs"];
-        App::new("clap-test")
-            .version("v1.4.8")
-            .about("tests clap library")
-            .author("Kevin K. <kbknapp@gmail.com>")
-            .arg("-o --option=[opt]... 'tests options'")
-            .arg("[positional] 'tests positionals'")
-            .arg(Arg::from("-f --flag... 'tests flags'")
-                .global(true))
-            .args(&[
-                Arg::from("[flag2] -F 'tests flags with exclusions'").conflicts_with("flag").requires("long-option-2"),
-                Arg::from("--long-option-2 [option2] 'tests long options with exclusions'").conflicts_with("option").requires("positional2"),
-                Arg::from("[positional2] 'tests positionals with exclusions'"),
-                Arg::from("-O --Option [option3] 'specific vals'").possible_values(&opt3_vals),
-                Arg::from("[positional3]... 'tests specific values'").possible_values(&pos3_vals),
-                Arg::from("--multvals [one] [two] 'Tests mutliple values, not mult occs'"),
-                Arg::from("--multvalsmo... [one] [two] 'Tests mutliple values, and mult occs'"),
-                Arg::from("--minvals2 [minvals]... 'Tests 2 min vals'").min_values(2),
-                Arg::from("--maxvals3 [maxvals]... 'Tests 3 max vals'").max_values(3)
-            ])
-            .subcommand(App::new("subcmd")
-                                    .about("tests subcommands")
-                                    .version("0.1")
-                                    .author("Kevin K. <kbknapp@gmail.com>")
-                                    .arg("-o --option [scoption]... 'tests options'")
-                                    .arg("-s --subcmdarg [subcmdarg] 'tests other args'")
-                                    .arg("[scpositional] 'tests positionals'"))
-    }
-}
diff --git a/clap_test/Cargo.toml b/clap_test/Cargo.toml
deleted file mode 100644
index 76b08334..00000000
--- a/clap_test/Cargo.toml
+++ /dev/null
@@ -1,8 +0,0 @@
-[package]
-name = "clap_test"
-version = "0.1.0"
-authors = ["Kevin K. <kbknapp@gmail.com>"]
-
-[dependencies]
-clap = {path = "../"}
-regex = "0.2"
\ No newline at end of file
diff --git a/clap_test/src/lib.rs b/clap_test/src/lib.rs
deleted file mode 100644
index 7da913e6..00000000
--- a/clap_test/src/lib.rs
+++ /dev/null
@@ -1,60 +0,0 @@
-use std::str;
-use std::io::Cursor;
-
-extern crate clap;
-extern crate regex;
-
-use regex::Regex;
-
-use clap::App;
-
-fn compare<S, S2>(l: S, r: S2) -> bool
-where
-    S: AsRef<str>,
-    S2: AsRef<str>,
-{
-    let re = Regex::new("\x1b[^m]*m").unwrap();
-    // Strip out any mismatching \r character on windows that might sneak in on either side
-    let ls = l.as_ref().trim().replace("\r", "");
-    let rs = r.as_ref().trim().replace("\r", "");
-    let left = re.replace_all(&*ls, "");
-    let right = re.replace_all(&*rs, "");
-    let b = left == right;
-    if !b {
-        println!("");
-        println!("--> left");
-        println!("{}", left);
-        println!("--> right");
-        println!("{}", right);
-        println!("--")
-    }
-    b
-}
-
-pub fn compare_output(l: App, args: &str, right: &str, stderr: bool) -> bool {
-    let mut buf = Cursor::new(Vec::with_capacity(50));
-    let res = l.try_get_matches_from(args.split(' ').collect::<Vec<_>>());
-    let err = res.unwrap_err();
-    err.write_to(&mut buf).unwrap();
-    let content = buf.into_inner();
-    let left = String::from_utf8(content).unwrap();
-    assert_eq!(
-        stderr,
-        err.use_stderr(),
-        "Should Use STDERR failed. Should be {} but is {}",
-        stderr,
-        err.use_stderr()
-    );
-    compare(left, right)
-}
-
-pub fn compare_output2(l: App, args: &str, right1: &str, right2: &str, stderr: bool) -> bool {
-    let mut buf = Cursor::new(Vec::with_capacity(50));
-    let res = l.try_get_matches_from(args.split(' ').collect::<Vec<_>>());
-    let err = res.unwrap_err();
-    err.write_to(&mut buf).unwrap();
-    let content = buf.into_inner();
-    let left = String::from_utf8(content).unwrap();
-    assert_eq!(stderr, err.use_stderr());
-    compare(&*left, right1) || compare(&*left, right2)
-}
diff --git a/tests/app_settings.rs b/tests/app_settings.rs
index 44cd7e21..266c064e 100644
--- a/tests/app_settings.rs
+++ b/tests/app_settings.rs
@@ -1,10 +1,7 @@
-extern crate clap;
-extern crate regex;
+mod utils;
 
 use clap::{App, AppSettings, Arg, ErrorKind, Propagation};
 
-include!("../clap-test.rs");
-
 static ALLOW_EXT_SC: &str = "clap-test v1.4.8
 
 USAGE:
@@ -204,6 +201,17 @@ fn infer_subcommands_pass_close() {
     assert_eq!(m.subcommand_name(), Some("test"));
 }
 
+#[test]
+fn infer_subcommands_pass_exact_match() {
+    let m = App::new("prog")
+        .setting(AppSettings::InferSubcommands)
+        .subcommand(App::new("test"))
+        .subcommand(App::new("testa"))
+        .subcommand(App::new("testb"))
+        .get_matches_from(vec!["prog", "test"]);
+    assert_eq!(m.subcommand_name(), Some("test"));
+}
+
 #[cfg(feature = "suggestions")]
 #[test]
 fn infer_subcommands_fail_suggestions() {
@@ -251,7 +259,7 @@ fn unified_help() {
         .arg("[arg1] 'some pos arg'")
         .arg("--option [opt] 'some option'");
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         UNIFIED_HELP,
@@ -271,7 +279,7 @@ fn skip_possible_values() {
             Arg::from("[arg1] 'some pos arg'").possible_values(&["three", "four"]),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         SKIP_POS_VALS,
@@ -537,7 +545,7 @@ fn dont_collapse_args() {
             Arg::with_name("arg2").help("some"),
             Arg::with_name("arg3").help("some"),
         ]);
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "clap-test --help",
         DONT_COLLAPSE_ARGS,
@@ -556,7 +564,7 @@ fn require_eq() {
             .value_name("FILE")
             .help("some"),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "clap-test --help",
         REQUIRE_EQUALS,
@@ -758,7 +766,7 @@ fn issue_1093_allow_ext_sc() {
     let app = App::new("clap-test")
         .version("v1.4.8")
         .setting(AppSettings::AllowExternalSubcommands);
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "clap-test --help",
         ALLOW_EXT_SC,
diff --git a/tests/arg_aliases.rs b/tests/arg_aliases.rs
index 9c926c06..0331a3d6 100644
--- a/tests/arg_aliases.rs
+++ b/tests/arg_aliases.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg};
 
@@ -176,7 +173,7 @@ fn invisible_arg_aliases_help_output() {
             )
             .arg(Arg::from("-f, --flag").aliases(&["invisible", "flg1", "anyway"])),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ct test --help",
         SC_INVISIBLE_ALIAS_HELP,
@@ -205,7 +202,7 @@ fn visible_arg_aliases_help_output() {
                     .visible_aliases(&["v_flg", "flag2", "flg3"]),
             ),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ct test --help",
         SC_VISIBLE_ALIAS_HELP,
diff --git a/tests/borrowed.rs b/tests/borrowed.rs
index 8a5ff5bb..4b79d921 100644
--- a/tests/borrowed.rs
+++ b/tests/borrowed.rs
@@ -1,10 +1,5 @@
-extern crate clap;
-extern crate regex;
-
 use clap::{App, Arg};
 
-include!("../clap-test.rs");
-
 #[test]
 fn borrowed_args() {
     let arg = Arg::with_name("some")
diff --git a/tests/conflicts.rs b/tests/conflicts.rs
index d7fe35a2..ca164c9c 100644
--- a/tests/conflicts.rs
+++ b/tests/conflicts.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg, ArgGroup, ErrorKind};
 
@@ -101,8 +98,8 @@ fn group_conflict_2() {
 
 #[test]
 fn conflict_output() {
-    test::compare_output(
-        test::complex_app(),
+    utils::compare_output(
+        utils::complex_app(),
         "clap-test val1 --flag --long-option-2 val2 -F",
         CONFLICT_ERR,
         true,
@@ -111,8 +108,8 @@ fn conflict_output() {
 
 #[test]
 fn conflict_output_rev() {
-    test::compare_output(
-        test::complex_app(),
+    utils::compare_output(
+        utils::complex_app(),
         "clap-test val1 -F --long-option-2 val2 --flag",
         CONFLICT_ERR_REV,
         true,
diff --git a/tests/default_vals.rs b/tests/default_vals.rs
index 3f1ce07d..9b671d81 100644
--- a/tests/default_vals.rs
+++ b/tests/default_vals.rs
@@ -1,8 +1,3 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
-
 use clap::{App, Arg, ErrorKind};
 
 #[test]
diff --git a/tests/delimiters.rs b/tests/delimiters.rs
index b5d193cb..0aecaa96 100644
--- a/tests/delimiters.rs
+++ b/tests/delimiters.rs
@@ -1,5 +1,3 @@
-extern crate clap;
-
 use clap::{App, Arg, ArgSettings};
 
 #[test]
diff --git a/tests/derive_order.rs b/tests/derive_order.rs
index ac56e335..9c36afe7 100644
--- a/tests/derive_order.rs
+++ b/tests/derive_order.rs
@@ -1,12 +1,9 @@
-extern crate clap;
-extern crate regex;
+mod utils;
 
 use std::str;
 
 use clap::{App, AppSettings, Arg};
 
-include!("../clap-test.rs");
-
 static NO_DERIVE_ORDER: &str = "test 1.2
 
 USAGE:
@@ -132,7 +129,7 @@ fn no_derive_order() {
             .help("second option"),
     ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         NO_DERIVE_ORDER,
@@ -158,7 +155,7 @@ fn derive_order() {
                 .help("second option"),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         DERIVE_ORDER,
@@ -184,7 +181,7 @@ fn unified_help() {
                 .help("second option"),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         UNIFIED_HELP,
@@ -211,7 +208,7 @@ fn unified_help_and_derive_order() {
                 .help("second option"),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         UNIFIED_HELP_AND_DERIVE,
@@ -239,7 +236,7 @@ fn derive_order_subcommand_propagate() {
             ]),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test sub --help",
         DERIVE_ORDER_SC_PROP,
@@ -266,7 +263,7 @@ fn unified_help_subcommand_propagate() {
             ]),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test sub --help",
         UNIFIED_SC_PROP,
@@ -294,7 +291,7 @@ fn unified_help_and_derive_order_subcommand_propagate() {
             ]),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test sub --help",
         UNIFIED_DERIVE_SC_PROP,
@@ -325,7 +322,7 @@ fn unified_help_and_derive_order_subcommand_propagate_with_explicit_display_orde
             ]),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test sub --help",
         UNIFIED_DERIVE_SC_PROP_EXPLICIT_ORDER,
diff --git a/tests/env.rs b/tests/env.rs
index 263b6ca5..4fa84e0e 100644
--- a/tests/env.rs
+++ b/tests/env.rs
@@ -1,5 +1,3 @@
-extern crate clap;
-
 use std::env;
 use std::ffi::OsStr;
 
diff --git a/tests/example1_tmpl_full.txt b/tests/example1_tmpl_full.txt
deleted file mode 100644
index 6ae57fa5..00000000
--- a/tests/example1_tmpl_full.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-{bin} {version}
-{author}
-{about}
-
-USAGE:
-    {usage}
-
-FLAGS:
-{flags}
-OPTIONS:
-{options}
-ARGS:
-{positionals}
-SUBCOMMANDS:
-{subcommands}
diff --git a/tests/example1_tmpl_simple.txt b/tests/example1_tmpl_simple.txt
deleted file mode 100644
index af6c4b07..00000000
--- a/tests/example1_tmpl_simple.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-{bin} {version}
-{author}
-{about}
-
-USAGE:
-    {usage}
-
-{all-args}
diff --git a/tests/app.yml b/tests/fixtures/app.yml
similarity index 100%
rename from tests/app.yml
rename to tests/fixtures/app.yml
diff --git a/tests/app_2space.yml b/tests/fixtures/app_2space.yml
similarity index 100%
rename from tests/app_2space.yml
rename to tests/fixtures/app_2space.yml
diff --git a/tests/flags.rs b/tests/flags.rs
index 06c05f0b..e2ac8c71 100644
--- a/tests/flags.rs
+++ b/tests/flags.rs
@@ -1,5 +1,3 @@
-extern crate clap;
-
 use clap::{App, Arg, ArgSettings};
 
 #[test]
diff --git a/tests/global_args.rs b/tests/global_args.rs
index 769da9cc..873234e1 100644
--- a/tests/global_args.rs
+++ b/tests/global_args.rs
@@ -1,36 +1,31 @@
-extern crate clap;
-extern crate regex;
+mod utils;
 
-#[cfg(test)]
-mod tests {
-    include!("../clap-test.rs");
-    use clap::{App, Arg};
+use clap::{App, Arg};
 
-    fn get_app() -> App<'static> {
-        App::new("myprog")
-            .arg(
-                Arg::with_name("GLOBAL_ARG")
-                    .long("global-arg")
-                    .help("Specifies something needed by the subcommands")
-                    .global(true)
-                    .takes_value(true)
-                    .default_value("default_value"),
-            )
-            .arg(
-                Arg::with_name("GLOBAL_FLAG")
-                    .long("global-flag")
-                    .help("Specifies something needed by the subcommands")
-                    .multiple(true)
-                    .global(true),
-            )
-            .subcommand(App::new("outer").subcommand(App::new("inner")))
-    }
+fn get_app() -> App<'static> {
+    App::new("myprog")
+        .arg(
+            Arg::with_name("GLOBAL_ARG")
+                .long("global-arg")
+                .help("Specifies something needed by the subcommands")
+                .global(true)
+                .takes_value(true)
+                .default_value("default_value"),
+        )
+        .arg(
+            Arg::with_name("GLOBAL_FLAG")
+                .long("global-flag")
+                .help("Specifies something needed by the subcommands")
+                .multiple(true)
+                .global(true),
+        )
+        .subcommand(App::new("outer").subcommand(App::new("inner")))
+}
 
-    #[test]
-    fn issue_1076() {
-        let mut app = get_app();
-        let _ = app.try_get_matches_from_mut(vec!["myprog"]);
-        let _ = app.try_get_matches_from_mut(vec!["myprog"]);
-        let _ = app.try_get_matches_from_mut(vec!["myprog"]);
-    }
+#[test]
+fn issue_1076() {
+    let mut app = get_app();
+    let _ = app.try_get_matches_from_mut(vec!["myprog"]);
+    let _ = app.try_get_matches_from_mut(vec!["myprog"]);
+    let _ = app.try_get_matches_from_mut(vec!["myprog"]);
 }
diff --git a/tests/groups.rs b/tests/groups.rs
index b00576ad..b7ea3f43 100644
--- a/tests/groups.rs
+++ b/tests/groups.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg, ArgGroup, ErrorKind};
 
@@ -160,7 +157,7 @@ fn req_group_usage_string() {
                 .required(true),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "clap-test",
         REQ_GROUP_USAGE,
@@ -181,7 +178,7 @@ fn req_group_with_conflict_usage_string() {
                 .required(true),
         );
 
-    assert!(test::compare_output2(
+    assert!(utils::compare_output2(
         app,
         "clap-test --delete base",
         REQ_GROUP_CONFLICT_REV,
diff --git a/tests/help.rs b/tests/help.rs
index 1d2d58d2..d7f9f92d 100644
--- a/tests/help.rs
+++ b/tests/help.rs
@@ -1,4 +1,4 @@
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{clap_app, App, AppSettings, Arg, ArgGroup, ArgSettings, ErrorKind};
 
@@ -593,7 +593,7 @@ fn req_last_arg_usage() {
         (@arg FIRST: ... * "First")
         (@arg SECOND: ... * +last "Second")
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "example --help",
         LAST_ARG_REQ_MULT,
@@ -642,7 +642,7 @@ fn args_with_last_usage() {
                 ])
                 .value_name("ARGS"),
         );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "flamegraph --help",
         LAST_ARG_USAGE,
@@ -652,7 +652,7 @@ fn args_with_last_usage() {
 
 #[test]
 fn subcommand_short_help() {
-    let m = test::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "-h"]);
+    let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "-h"]);
 
     assert!(m.is_err());
     assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
@@ -660,7 +660,7 @@ fn subcommand_short_help() {
 
 #[test]
 fn subcommand_long_help() {
-    let m = test::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "--help"]);
+    let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "subcmd", "--help"]);
 
     assert!(m.is_err());
     assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
@@ -668,7 +668,7 @@ fn subcommand_long_help() {
 
 #[test]
 fn subcommand_help_rev() {
-    let m = test::complex_app().try_get_matches_from(vec!["clap-test", "help", "subcmd"]);
+    let m = utils::complex_app().try_get_matches_from(vec!["clap-test", "help", "subcmd"]);
 
     assert!(m.is_err());
     assert_eq!(m.unwrap_err().kind, ErrorKind::HelpDisplayed);
@@ -676,8 +676,8 @@ fn subcommand_help_rev() {
 
 #[test]
 fn complex_help_output() {
-    assert!(test::compare_output(
-        test::complex_app(),
+    assert!(utils::compare_output(
+        utils::complex_app(),
         "clap-test --help",
         HELP,
         false
@@ -691,7 +691,7 @@ fn after_and_before_help_output() {
         .about("tests clap library")
         .before_help("some text that comes before the help")
         .after_help("some text that comes after the help");
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "clap-test --help",
         AFTER_HELP,
@@ -711,7 +711,7 @@ fn multi_level_sc_help() {
                 .arg("-o, --option [scoption]...    'tests options'"),
         ),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest help subcmd multi",
         MULTI_SC_HELP,
@@ -724,7 +724,7 @@ fn no_wrap_help() {
     let app = App::new("ctest")
         .set_term_width(0)
         .override_help(MULTI_SC_HELP);
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         MULTI_SC_HELP,
@@ -735,7 +735,7 @@ fn no_wrap_help() {
 #[test]
 fn no_wrap_default_help() {
     let app = App::new("ctest").version("1.0").set_term_width(0);
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         DEFAULT_HELP,
@@ -745,8 +745,8 @@ fn no_wrap_default_help() {
 
 #[test]
 fn complex_subcommand_help_output() {
-    let a = test::complex_app();
-    assert!(test::compare_output(
+    let a = utils::complex_app();
+    assert!(utils::compare_output(
         a,
         "clap-test subcmd --help",
         SC_HELP,
@@ -771,7 +771,7 @@ fn issue_626_unicode_cutoff() {
             )
             .takes_value(true),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         ISSUE_626_CUTOFF,
@@ -802,7 +802,7 @@ fn hide_possible_vals() {
                 .help("A coffeehouse, coffee shop, or café.")
                 .takes_value(true),
         );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         HIDE_POS_VALS,
@@ -823,7 +823,7 @@ fn issue_626_panic() {
            d'Afrique et d'Asie, dans des plantations qui sont cultivées pour les marchés d'exportation. \
            Le café est souvent une contribution majeure aux exportations des régions productrices.")
            .takes_value(true));
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         ISSUE_626_PANIC,
@@ -852,7 +852,7 @@ fn issue_626_variable_panic() {
 #[test]
 fn final_word_wrapping() {
     let app = App::new("ctest").version("0.1").set_term_width(24);
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         FINAL_WORD_WRAPPING,
@@ -870,7 +870,7 @@ fn wrapping_newline_chars() {
              l, long           Copy-friendly, 14 characters, contains symbols.{n}\
              m, med, medium    Copy-friendly, 8 characters, contains symbols.{n}",
         ));
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         WRAPPING_NEWLINE_CHARS,
@@ -885,7 +885,7 @@ fn old_newline_chars() {
             .short('m')
             .help("Some help with some wrapping{n}(Defaults to something)"),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         OLD_NEWLINE_CHARS,
@@ -907,7 +907,12 @@ fn issue_688_hidden_pos_vals() {
 				.long("filter")
 				.possible_values(&filter_values)
 				.takes_value(true));
-    assert!(test::compare_output(app1, "ctest --help", ISSUE_688, false));
+    assert!(utils::compare_output(
+        app1,
+        "ctest --help",
+        ISSUE_688,
+        false
+    ));
 
     let app2 = App::new("ctest")
             .version("0.1")
@@ -918,7 +923,12 @@ fn issue_688_hidden_pos_vals() {
 				.long("filter")
 				.possible_values(&filter_values)
 				.takes_value(true));
-    assert!(test::compare_output(app2, "ctest --help", ISSUE_688, false));
+    assert!(utils::compare_output(
+        app2,
+        "ctest --help",
+        ISSUE_688,
+        false
+    ));
 
     let app3 = App::new("ctest")
             .version("0.1")
@@ -928,7 +938,12 @@ fn issue_688_hidden_pos_vals() {
                 images. The default is Linear (Bilinear). [possible values: Nearest, Linear, Cubic, Gaussian, Lanczos3]")
 				.long("filter")
 				.takes_value(true));
-    assert!(test::compare_output(app3, "ctest --help", ISSUE_688, false));
+    assert!(utils::compare_output(
+        app3,
+        "ctest --help",
+        ISSUE_688,
+        false
+    ));
 }
 
 #[test]
@@ -961,7 +976,7 @@ fn issue_702_multiple_values() {
                 .multiple(true)
                 .takes_value(true),
         );
-    assert!(test::compare_output(app, "myapp --help", ISSUE_702, false));
+    assert!(utils::compare_output(app, "myapp --help", ISSUE_702, false));
 }
 
 #[test]
@@ -974,7 +989,12 @@ fn long_about() {
             "something really really long, with\nmultiple lines of text\nthat should be displayed",
         )
         .arg(Arg::with_name("arg1").help("some option"));
-    assert!(test::compare_output(app, "myapp --help", LONG_ABOUT, false));
+    assert!(utils::compare_output(
+        app,
+        "myapp --help",
+        LONG_ABOUT,
+        false
+    ));
 }
 
 #[test]
@@ -997,7 +1017,7 @@ fn issue_760() {
                 .long("opt")
                 .takes_value(true),
         );
-    assert!(test::compare_output(app, "ctest --help", ISSUE_760, false));
+    assert!(utils::compare_output(app, "ctest --help", ISSUE_760, false));
 }
 
 #[test]
@@ -1009,7 +1029,12 @@ fn ripgrep_usage() {
     rg [OPTIONS] --type-list",
     );
 
-    assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
+    assert!(utils::compare_output(
+        app,
+        "rg --help",
+        RIPGREP_USAGE,
+        false
+    ));
 }
 
 #[test]
@@ -1033,7 +1058,12 @@ FLAGS:
 {flags}",
         );
 
-    assert!(test::compare_output(app, "rg --help", RIPGREP_USAGE, false));
+    assert!(utils::compare_output(
+        app,
+        "rg --help",
+        RIPGREP_USAGE,
+        false
+    ));
 }
 
 #[test]
@@ -1044,7 +1074,7 @@ fn sc_negates_reqs() {
         .arg("-o, --opt <FILE> 'tests options'")
         .arg(Arg::with_name("PATH").help("help"))
         .subcommand(App::new("test"));
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "prog --help",
         SC_NEGATES_REQS,
@@ -1059,7 +1089,12 @@ fn hidden_args() {
         .arg("-f, --flag 'testing flags'")
         .arg("-o, --opt [FILE] 'tests options'")
         .arg(Arg::with_name("pos").hidden(true));
-    assert!(test::compare_output(app, "prog --help", HIDDEN_ARGS, false));
+    assert!(utils::compare_output(
+        app,
+        "prog --help",
+        HIDDEN_ARGS,
+        false
+    ));
 }
 
 #[test]
@@ -1071,7 +1106,7 @@ fn args_negate_sc() {
         .arg("-o, --opt [FILE] 'tests options'")
         .arg(Arg::with_name("PATH").help("help"))
         .subcommand(App::new("test"));
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "prog --help",
         ARGS_NEGATE_SC,
@@ -1087,7 +1122,7 @@ fn issue_1046_hidden_scs() {
         .arg("-o, --opt [FILE] 'tests options'")
         .arg(Arg::with_name("PATH").help("some"))
         .subcommand(App::new("test").setting(AppSettings::Hidden));
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "prog --help",
         ISSUE_1046_HIDDEN_SCS,
@@ -1102,7 +1137,7 @@ fn issue_777_wrap_all_things() {
         .author("Some Very Long Name and crazy long email <email@server.com>")
         .about("Show how the about text is not wrapped")
         .set_term_width(35);
-    assert!(test::compare_output(app, "ctest --help", ISSUE_777, false));
+    assert!(utils::compare_output(app, "ctest --help", ISSUE_777, false));
 }
 
 #[test]
@@ -1119,7 +1154,7 @@ fn customize_version_and_help() {
                 .long("version")
                 .help("Print version information")
         });
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "customize --help",
         CUSTOM_VERSION_AND_HELP,
@@ -1139,7 +1174,7 @@ fn last_arg_mult_usage() {
                 .last(true)
                 .help("some"),
         );
-    assert!(test::compare_output(app, "last --help", LAST_ARG, false));
+    assert!(utils::compare_output(app, "last --help", LAST_ARG, false));
 }
 
 #[test]
@@ -1155,7 +1190,7 @@ fn last_arg_mult_usage_req() {
                 .required(true)
                 .help("some"),
         );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "last --help",
         LAST_ARG_REQ,
@@ -1178,7 +1213,7 @@ fn last_arg_mult_usage_req_with_sc() {
                 .help("some"),
         )
         .subcommand(App::new("test").about("some"));
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "last --help",
         LAST_ARG_REQ_SC,
@@ -1200,7 +1235,12 @@ fn last_arg_mult_usage_with_sc() {
                 .help("some"),
         )
         .subcommand(App::new("test").about("some"));
-    assert!(test::compare_output(app, "last --help", LAST_ARG_SC, false));
+    assert!(utils::compare_output(
+        app,
+        "last --help",
+        LAST_ARG_SC,
+        false
+    ));
 }
 
 #[test]
@@ -1212,7 +1252,7 @@ fn hidden_default_val() {
             .default_value("default-argument")
             .hide_default_value(true),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app1,
         "default --help",
         HIDE_DEFAULT_VAL,
@@ -1225,7 +1265,7 @@ fn hidden_default_val() {
             .long("arg")
             .default_value("default-argument"),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app2,
         "default --help",
         HIDE_DEFAULT_VAL,
@@ -1295,7 +1335,7 @@ fn issue_1052_require_delim_help() {
                 .value_delimiter(":"),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         REQUIRE_DELIM_HELP,
@@ -1329,7 +1369,7 @@ fn hide_env_vals() {
                 .help("A coffeehouse, coffee shop, or café.")
                 .takes_value(true),
         );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         HIDE_ENV_VALS,
@@ -1363,7 +1403,7 @@ fn show_env_vals() {
                 .help("A coffeehouse, coffee shop, or café.")
                 .takes_value(true),
         );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest --help",
         SHOW_ENV_VALS,
@@ -1390,7 +1430,7 @@ fn custom_headers_headers() {
                 .help("Do not use system proxy settings"),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         CUSTOM_HELP_SECTION,
@@ -1452,7 +1492,7 @@ fn multiple_custom_help_headers() {
                 .takes_value(true),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         MULTIPLE_CUSTOM_HELP_SECTIONS,
@@ -1481,7 +1521,7 @@ fn show_long_about_issue_897() {
             .about("About foo")
             .long_about("Long about foo"),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest foo --help",
         ISSUE_897,
@@ -1507,7 +1547,7 @@ fn show_short_about_issue_897() {
             .about("About foo")
             .long_about("Long about foo"),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "ctest foo -h",
         ISSUE_897_SHORT,
@@ -1526,5 +1566,5 @@ fn issue_1487() {
         .group(ArgGroup::with_name("group1")
             .args(&["arg1", "arg2"])
             .required(true));
-    assert!(test::compare_output(app, "ctest -h", ISSUE_1487, false));
+    assert!(utils::compare_output(app, "ctest -h", ISSUE_1487, false));
 }
diff --git a/tests/hidden_args.rs b/tests/hidden_args.rs
index a560d560..0ced6b70 100644
--- a/tests/hidden_args.rs
+++ b/tests/hidden_args.rs
@@ -1,10 +1,7 @@
-extern crate clap;
-extern crate regex;
+mod utils;
 
 use clap::{App, Arg};
 
-include!("../clap-test.rs");
-
 static HIDDEN_ARGS: &str = "test 1.4
 Kevin K.
 tests stuff
@@ -32,7 +29,12 @@ fn hidden_args() {
             Arg::from("--option [opt] 'some option'"),
             Arg::with_name("DUMMY").hidden(true),
         ]);
-    assert!(test::compare_output(app, "test --help", HIDDEN_ARGS, false));
+    assert!(utils::compare_output(
+        app,
+        "test --help",
+        HIDDEN_ARGS,
+        false
+    ));
 }
 
 static HIDDEN_SHORT_ARGS: &str = "test 2.31.2
@@ -86,7 +88,7 @@ fn hidden_short_args() {
                 .help("This text should be visible"),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test -h",
         HIDDEN_SHORT_ARGS,
@@ -113,7 +115,7 @@ fn hidden_short_args_long_help() {
                 .help("This text should be visible"),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         HIDDEN_SHORT_ARGS_LONG_HELP,
@@ -156,7 +158,7 @@ fn hidden_long_args() {
                 .help("This text should be visible"),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --help",
         HIDDEN_LONG_ARGS,
@@ -195,7 +197,7 @@ fn hidden_long_args_short_help() {
                 .help("This text should be visible"),
         ]);
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test -h",
         HIDDEN_LONG_ARGS_SHORT_HELP,
diff --git a/tests/indices.rs b/tests/indices.rs
index 60295295..1e68c187 100644
--- a/tests/indices.rs
+++ b/tests/indices.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg};
 
diff --git a/tests/multiple_occurrences.rs b/tests/multiple_occurrences.rs
index caa74280..1a40bd95 100644
--- a/tests/multiple_occurrences.rs
+++ b/tests/multiple_occurrences.rs
@@ -1,5 +1,3 @@
-extern crate clap;
-
 use clap::{App, Arg, ArgSettings};
 
 #[test]
diff --git a/tests/multiple_values.rs b/tests/multiple_values.rs
index 001adafa..616f5ea5 100644
--- a/tests/multiple_values.rs
+++ b/tests/multiple_values.rs
@@ -1,5 +1,3 @@
-extern crate clap;
-
 use clap::{App, Arg, ErrorKind};
 
 #[test]
diff --git a/tests/opts.rs b/tests/opts.rs
index cfd454f3..ca693262 100644
--- a/tests/opts.rs
+++ b/tests/opts.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg, ArgMatches, ArgSettings, ErrorKind};
 
@@ -361,8 +358,8 @@ fn leading_hyphen_with_only_pos_follows() {
 #[test]
 #[cfg(feature = "suggestions")]
 fn did_you_mean() {
-    assert!(test::compare_output(
-        test::complex_app(),
+    assert!(utils::compare_output(
+        utils::complex_app(),
         "clap-test --optio=foo",
         DYM,
         true
diff --git a/tests/positionals.rs b/tests/positionals.rs
index 725147fd..54c3584a 100644
--- a/tests/positionals.rs
+++ b/tests/positionals.rs
@@ -1,5 +1,3 @@
-extern crate clap;
-
 use clap::{App, Arg, ErrorKind};
 
 #[test]
diff --git a/tests/posix_compatible.rs b/tests/posix_compatible.rs
index ab5cc217..be3a72ed 100644
--- a/tests/posix_compatible.rs
+++ b/tests/posix_compatible.rs
@@ -1,6 +1,5 @@
-extern crate clap;
-
 use clap::{App, Arg, ErrorKind};
+
 #[test]
 fn flag_overrides_itself() {
     let res = App::new("posix")
diff --git a/tests/possible_values.rs b/tests/possible_values.rs
index 2c4eb1ca..f7b8b971 100644
--- a/tests/possible_values.rs
+++ b/tests/possible_values.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg, ErrorKind};
 
@@ -174,8 +171,8 @@ fn possible_values_of_option_multiple_fail() {
 
 #[test]
 fn possible_values_output() {
-    assert!(test::compare_output(
-        test::complex_app(),
+    assert!(utils::compare_output(
+        utils::complex_app(),
         "clap-test -O slo",
         PV_ERROR,
         true
diff --git a/tests/propagate_globals.rs b/tests/propagate_globals.rs
index 4843ac12..8a78d914 100644
--- a/tests/propagate_globals.rs
+++ b/tests/propagate_globals.rs
@@ -1,150 +1,145 @@
-extern crate clap;
-extern crate regex;
-
-#[cfg(test)]
-mod tests {
-    include!("../clap-test.rs");
-    use clap::{App, Arg, ArgMatches, ArgSettings};
-
-    fn get_app() -> App<'static> {
-        App::new("myprog")
-            .arg(
-                Arg::with_name("GLOBAL_ARG")
-                    .long("global-arg")
-                    .help("Specifies something needed by the subcommands")
-                    .global(true)
-                    .setting(ArgSettings::TakesValue)
-                    .default_value("default_value"),
-            )
-            .arg(
-                Arg::with_name("GLOBAL_FLAG")
-                    .long("global-flag")
-                    .help("Specifies something needed by the subcommands")
-                    .global(true)
-                    .setting(ArgSettings::MultipleOccurrences),
-            )
-            .subcommand(App::new("outer").subcommand(App::new("inner")))
-    }
-
-    fn get_matches(app: App<'static>, argv: &'static str) -> ArgMatches {
-        app.get_matches_from(argv.split(' ').collect::<Vec<_>>())
-    }
-
-    fn get_outer_matches(m: &ArgMatches) -> &ArgMatches {
-        m.subcommand_matches("outer")
-            .expect("could not access outer subcommand")
-    }
-
-    fn get_inner_matches(m: &ArgMatches) -> &ArgMatches {
-        get_outer_matches(m)
-            .subcommand_matches("inner")
-            .expect("could not access inner subcommand")
-    }
-
-    fn top_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches, val: T) -> bool {
-        m.value_of("GLOBAL_ARG") == val.into()
-    }
-
-    fn inner_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches, val: T) -> bool {
-        get_inner_matches(m).value_of("GLOBAL_ARG") == val.into()
-    }
-
-    fn outer_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches, val: T) -> bool {
-        get_outer_matches(m).value_of("GLOBAL_ARG") == val.into()
-    }
-
-    fn top_can_access_flag(m: &ArgMatches, present: bool, occurrences: u64) -> bool {
-        (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
-    }
-
-    fn inner_can_access_flag(m: &ArgMatches, present: bool, occurrences: u64) -> bool {
-        let m = get_inner_matches(m);
-        (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
-    }
-
-    fn outer_can_access_flag(m: &ArgMatches, present: bool, occurrences: u64) -> bool {
-        let m = get_outer_matches(m);
-        (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
-    }
-
-    #[test]
-    fn global_arg_used_top_level() {
-        let m = get_matches(get_app(), "myprog --global-arg=some_value outer inner");
-
-        assert!(top_can_access_arg(&m, "some_value"));
-        assert!(inner_can_access_arg(&m, "some_value"));
-        assert!(outer_can_access_arg(&m, "some_value"));
-    }
-
-    #[test]
-    fn global_arg_used_outer() {
-        let m = get_matches(get_app(), "myprog outer --global-arg=some_value inner");
-
-        assert!(top_can_access_arg(&m, "some_value"));
-        assert!(inner_can_access_arg(&m, "some_value"));
-        assert!(outer_can_access_arg(&m, "some_value"));
-    }
-
-    #[test]
-    fn global_arg_used_inner() {
-        let m = get_matches(get_app(), "myprog outer inner --global-arg=some_value");
-
-        assert!(top_can_access_arg(&m, "some_value"));
-        assert!(inner_can_access_arg(&m, "some_value"));
-        assert!(outer_can_access_arg(&m, "some_value"));
-    }
-
-    #[test]
-    fn global_arg_default_value() {
-        let m = get_matches(get_app(), "myprog outer inner");
-
-        assert!(top_can_access_arg(&m, "default_value"));
-        assert!(inner_can_access_arg(&m, "default_value"));
-        assert!(outer_can_access_arg(&m, "default_value"));
-    }
-
-    #[test]
-    fn global_flag_used_top_level() {
-        let m = get_matches(get_app(), "myprog --global-flag outer inner");
-
-        assert!(top_can_access_flag(&m, true, 1));
-        assert!(inner_can_access_flag(&m, true, 1));
-        assert!(outer_can_access_flag(&m, true, 1));
-    }
-
-    #[test]
-    fn global_flag_used_outer() {
-        let m = get_matches(get_app(), "myprog outer --global-flag inner");
-
-        assert!(top_can_access_flag(&m, true, 1));
-        assert!(inner_can_access_flag(&m, true, 1));
-        assert!(outer_can_access_flag(&m, true, 1));
-    }
-
-    #[test]
-    fn global_flag_used_inner() {
-        let m = get_matches(get_app(), "myprog outer inner --global-flag");
-
-        assert!(top_can_access_flag(&m, true, 1));
-        assert!(inner_can_access_flag(&m, true, 1));
-        assert!(outer_can_access_flag(&m, true, 1));
-    }
-
-    #[test]
-    fn global_flag_2x_used_top_level() {
-        let m = get_matches(get_app(), "myprog --global-flag --global-flag outer inner");
-
-        assert!(top_can_access_flag(&m, true, 2));
-        assert!(inner_can_access_flag(&m, true, 2));
-        assert!(outer_can_access_flag(&m, true, 2));
-    }
-
-    #[test]
-    fn global_flag_2x_used_inner() {
-        let m = get_matches(get_app(), "myprog outer inner --global-flag --global-flag");
-
-        assert!(top_can_access_flag(&m, true, 2));
-        assert!(inner_can_access_flag(&m, true, 2));
-        assert!(outer_can_access_flag(&m, true, 2));
-    }
+mod utils;
+
+use clap::{App, Arg, ArgMatches, ArgSettings};
+
+fn get_app() -> App<'static> {
+    App::new("myprog")
+        .arg(
+            Arg::with_name("GLOBAL_ARG")
+                .long("global-arg")
+                .help("Specifies something needed by the subcommands")
+                .global(true)
+                .setting(ArgSettings::TakesValue)
+                .default_value("default_value"),
+        )
+        .arg(
+            Arg::with_name("GLOBAL_FLAG")
+                .long("global-flag")
+                .help("Specifies something needed by the subcommands")
+                .global(true)
+                .setting(ArgSettings::MultipleOccurrences),
+        )
+        .subcommand(App::new("outer").subcommand(App::new("inner")))
+}
+
+fn get_matches(app: App<'static>, argv: &'static str) -> ArgMatches {
+    app.get_matches_from(argv.split(' ').collect::<Vec<_>>())
+}
+
+fn get_outer_matches(m: &ArgMatches) -> &ArgMatches {
+    m.subcommand_matches("outer")
+        .expect("could not access outer subcommand")
+}
+
+fn get_inner_matches(m: &ArgMatches) -> &ArgMatches {
+    get_outer_matches(m)
+        .subcommand_matches("inner")
+        .expect("could not access inner subcommand")
+}
+
+fn top_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches, val: T) -> bool {
+    m.value_of("GLOBAL_ARG") == val.into()
+}
+
+fn inner_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches, val: T) -> bool {
+    get_inner_matches(m).value_of("GLOBAL_ARG") == val.into()
+}
+
+fn outer_can_access_arg<T: Into<Option<&'static str>>>(m: &ArgMatches, val: T) -> bool {
+    get_outer_matches(m).value_of("GLOBAL_ARG") == val.into()
+}
+
+fn top_can_access_flag(m: &ArgMatches, present: bool, occurrences: u64) -> bool {
+    (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
+}
+
+fn inner_can_access_flag(m: &ArgMatches, present: bool, occurrences: u64) -> bool {
+    let m = get_inner_matches(m);
+    (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
+}
+
+fn outer_can_access_flag(m: &ArgMatches, present: bool, occurrences: u64) -> bool {
+    let m = get_outer_matches(m);
+    (m.is_present("GLOBAL_FLAG") == present) && (m.occurrences_of("GLOBAL_FLAG") == occurrences)
+}
+
+#[test]
+fn global_arg_used_top_level() {
+    let m = get_matches(get_app(), "myprog --global-arg=some_value outer inner");
+
+    assert!(top_can_access_arg(&m, "some_value"));
+    assert!(inner_can_access_arg(&m, "some_value"));
+    assert!(outer_can_access_arg(&m, "some_value"));
+}
+
+#[test]
+fn global_arg_used_outer() {
+    let m = get_matches(get_app(), "myprog outer --global-arg=some_value inner");
+
+    assert!(top_can_access_arg(&m, "some_value"));
+    assert!(inner_can_access_arg(&m, "some_value"));
+    assert!(outer_can_access_arg(&m, "some_value"));
+}
+
+#[test]
+fn global_arg_used_inner() {
+    let m = get_matches(get_app(), "myprog outer inner --global-arg=some_value");
+
+    assert!(top_can_access_arg(&m, "some_value"));
+    assert!(inner_can_access_arg(&m, "some_value"));
+    assert!(outer_can_access_arg(&m, "some_value"));
+}
+
+#[test]
+fn global_arg_default_value() {
+    let m = get_matches(get_app(), "myprog outer inner");
+
+    assert!(top_can_access_arg(&m, "default_value"));
+    assert!(inner_can_access_arg(&m, "default_value"));
+    assert!(outer_can_access_arg(&m, "default_value"));
+}
+
+#[test]
+fn global_flag_used_top_level() {
+    let m = get_matches(get_app(), "myprog --global-flag outer inner");
+
+    assert!(top_can_access_flag(&m, true, 1));
+    assert!(inner_can_access_flag(&m, true, 1));
+    assert!(outer_can_access_flag(&m, true, 1));
+}
+
+#[test]
+fn global_flag_used_outer() {
+    let m = get_matches(get_app(), "myprog outer --global-flag inner");
+
+    assert!(top_can_access_flag(&m, true, 1));
+    assert!(inner_can_access_flag(&m, true, 1));
+    assert!(outer_can_access_flag(&m, true, 1));
+}
+
+#[test]
+fn global_flag_used_inner() {
+    let m = get_matches(get_app(), "myprog outer inner --global-flag");
+
+    assert!(top_can_access_flag(&m, true, 1));
+    assert!(inner_can_access_flag(&m, true, 1));
+    assert!(outer_can_access_flag(&m, true, 1));
+}
+
+#[test]
+fn global_flag_2x_used_top_level() {
+    let m = get_matches(get_app(), "myprog --global-flag --global-flag outer inner");
+
+    assert!(top_can_access_flag(&m, true, 2));
+    assert!(inner_can_access_flag(&m, true, 2));
+    assert!(outer_can_access_flag(&m, true, 2));
+}
+
+#[test]
+fn global_flag_2x_used_inner() {
+    let m = get_matches(get_app(), "myprog outer inner --global-flag --global-flag");
+
+    assert!(top_can_access_flag(&m, true, 2));
+    assert!(inner_can_access_flag(&m, true, 2));
+    assert!(outer_can_access_flag(&m, true, 2));
 }
diff --git a/tests/require.rs b/tests/require.rs
index 9849eda7..0da7bbf9 100644
--- a/tests/require.rs
+++ b/tests/require.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg, ArgGroup, ErrorKind};
 
@@ -424,8 +421,8 @@ fn required_unless_one_err() {
 
 #[test]
 fn missing_required_output() {
-    assert!(test::compare_output(
-        test::complex_app(),
+    assert!(utils::compare_output(
+        utils::complex_app(),
         "clap-test -F",
         MISSING_REQ,
         true
@@ -557,7 +554,7 @@ fn required_if_val_present_fail_error_output() {
                 .long("output"),
         );
 
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "test --input somepath --target file",
         COND_REQ_IN_USAGE,
@@ -657,7 +654,12 @@ fn require_eq() {
             .value_name("FILE")
             .help("some"),
     );
-    assert!(test::compare_output(app, "clap-test", REQUIRE_EQUALS, true));
+    assert!(utils::compare_output(
+        app,
+        "clap-test",
+        REQUIRE_EQUALS,
+        true
+    ));
 }
 
 static ISSUE_1158: &str = "error: The following required arguments were not provided:
@@ -692,7 +694,7 @@ fn issue_1158_app() -> App<'static> {
 fn issue_1158_conflicting_requirements() {
     let app = issue_1158_app();
 
-    assert!(test::compare_output(app, "example id", ISSUE_1158, true));
+    assert!(utils::compare_output(app, "example id", ISSUE_1158, true));
 }
 
 #[test]
diff --git a/tests/subcommands.rs b/tests/subcommands.rs
index 4d6b788d..af72d264 100644
--- a/tests/subcommands.rs
+++ b/tests/subcommands.rs
@@ -1,7 +1,4 @@
-extern crate clap;
-extern crate regex;
-
-include!("../clap-test.rs");
+mod utils;
 
 use clap::{App, Arg, ErrorKind};
 
@@ -136,7 +133,7 @@ fn multiple_aliases() {
 #[cfg(feature = "suggestions")]
 fn subcmd_did_you_mean_output() {
     let app = App::new("dym").subcommand(App::new("subcmd"));
-    assert!(test::compare_output(app, "dym subcm", DYM_SUBCMD, true));
+    assert!(utils::compare_output(app, "dym subcm", DYM_SUBCMD, true));
 }
 
 #[test]
@@ -144,7 +141,7 @@ fn subcmd_did_you_mean_output() {
 fn subcmd_did_you_mean_output_arg() {
     let app =
         App::new("dym").subcommand(App::new("subcmd").arg("-s --subcmdarg [subcmdarg] 'tests'"));
-    assert!(test::compare_output(app, "dym --subcm foo", DYM_ARG, true));
+    assert!(utils::compare_output(app, "dym --subcm foo", DYM_ARG, true));
 }
 
 #[test]
@@ -165,7 +162,7 @@ fn visible_aliases_help_output() {
             .visible_alias("dongle")
             .visible_alias("done"),
     );
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "clap-test --help",
         VISIBLE_ALIAS_HELP,
@@ -178,7 +175,7 @@ fn invisible_aliases_help_output() {
     let app = App::new("clap-test")
         .version("2.6")
         .subcommand(App::new("test").about("Some help").alias("invisible"));
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "clap-test --help",
         INVISIBLE_ALIAS_HELP,
diff --git a/tests/template_help.rs b/tests/template_help.rs
index a1f2013a..5f1f5d73 100644
--- a/tests/template_help.rs
+++ b/tests/template_help.rs
@@ -1,12 +1,31 @@
-extern crate clap;
-extern crate regex;
+mod utils;
 
 use clap::App;
 
-include!("../clap-test.rs");
+static EXAMPLE1_TMPL_S: &str = "{bin} {version}
+{author}
+{about}
 
-static EXAMPLE1_TMPL_S: &str = include_str!("example1_tmpl_simple.txt");
-static EXAMPLE1_TMPS_F: &str = include_str!("example1_tmpl_full.txt");
+USAGE:
+    {usage}
+
+{all-args}";
+
+static EXAMPLE1_TMPS_F: &str = "{bin} {version}
+{author}
+{about}
+
+USAGE:
+    {usage}
+
+FLAGS:
+{flags}
+OPTIONS:
+{options}
+ARGS:
+{positionals}
+SUBCOMMANDS:
+{subcommands}";
 
 static CUSTOM_TEMPL_HELP: &str = "MyApp 1.0
 Kevin K. <kbknapp@gmail.com>
@@ -51,8 +70,8 @@ SUBCOMMANDS:
 
 #[test]
 fn with_template() {
-    let app = app_example1().help_template(EXAMPLE1_TMPL_S);
-    assert!(test::compare_output(
+    let app = get_app().help_template(EXAMPLE1_TMPL_S);
+    assert!(utils::compare_output(
         app,
         "MyApp --help",
         SIMPLE_TEMPLATE,
@@ -62,8 +81,8 @@ fn with_template() {
 
 #[test]
 fn custom_template() {
-    let app = app_example1().help_template(EXAMPLE1_TMPS_F);
-    assert!(test::compare_output(
+    let app = get_app().help_template(EXAMPLE1_TMPS_F);
+    assert!(utils::compare_output(
         app,
         "MyApp --help",
         CUSTOM_TEMPL_HELP,
@@ -78,7 +97,7 @@ fn template_empty() {
         .author("Kevin K. <kbknapp@gmail.com>")
         .about("Does awesome things")
         .help_template("");
-    assert!(test::compare_output(app, "MyApp --help", "", false));
+    assert!(utils::compare_output(app, "MyApp --help", "", false));
 }
 
 #[test]
@@ -88,7 +107,7 @@ fn template_notag() {
         .author("Kevin K. <kbknapp@gmail.com>")
         .about("Does awesome things")
         .help_template("test no tag test");
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "MyApp --help",
         "test no tag test",
@@ -103,7 +122,7 @@ fn template_unknowntag() {
         .author("Kevin K. <kbknapp@gmail.com>")
         .about("Does awesome things")
         .help_template("test {unknown_tag} test");
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "MyApp --help",
         "test {unknown_tag} test",
@@ -118,7 +137,7 @@ fn template_author_version() {
         .author("Kevin K. <kbknapp@gmail.com>")
         .about("Does awesome things")
         .help_template("{author}\n{version}\n{about}\n{bin}");
-    assert!(test::compare_output(
+    assert!(utils::compare_output(
         app,
         "MyApp --help",
         "Kevin K. <kbknapp@gmail.com>\n1.0\nDoes awesome things\nMyApp",
@@ -128,7 +147,7 @@ fn template_author_version() {
 
 // ----------
 
-fn app_example1<'c>() -> App<'c> {
+fn get_app() -> App<'static> {
     App::new("MyApp")
         .version("1.0")
         .author("Kevin K. <kbknapp@gmail.com>")
diff --git a/tests/tests.rs b/tests/tests.rs
index 9f376bb3..5e58a41e 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -1,8 +1,8 @@
+mod utils;
+
 use std::io::Write;
 use std::str;
 
-include!("../clap-test.rs");
-
 use clap::{arg_enum, App, Arg};
 
 static SCF2OP: &str = "flag present 2 times
@@ -88,7 +88,7 @@ subcmd NOT present
 
 pub fn check_complex_output(args: &str, out: &str) {
     let mut w = vec![];
-    let matches = test::complex_app().get_matches_from(args.split(' ').collect::<Vec<_>>());
+    let matches = utils::complex_app().get_matches_from(args.split(' ').collect::<Vec<_>>());
     if matches.is_present("flag") {
         writeln!(w, "flag present {} times", matches.occurrences_of("flag")).unwrap();
     } else {
diff --git a/tests/unique_args.rs b/tests/unique_args.rs
index 6f3d41e8..5b8ae149 100644
--- a/tests/unique_args.rs
+++ b/tests/unique_args.rs
@@ -1,5 +1,3 @@
-extern crate clap;
-
 use clap::{App, Arg};
 
 // This tests a programmer error and will only succeed with debug_assertions
diff --git a/tests/utf8.rs b/tests/utf8.rs
index 23064d06..a2aa404f 100644
--- a/tests/utf8.rs
+++ b/tests/utf8.rs
@@ -1,7 +1,5 @@
 #![cfg(not(windows))]
 
-extern crate clap;
-
 use clap::{App, AppSettings, Arg, ErrorKind};
 use std::ffi::OsString;
 use std::os::unix::ffi::OsStringExt;
diff --git a/tests/utils.rs b/tests/utils.rs
new file mode 100644
index 00000000..295da222
--- /dev/null
+++ b/tests/utils.rs
@@ -0,0 +1,98 @@
+#![allow(unused_imports, dead_code)]
+
+use std::io::{Cursor, Write};
+use std::str;
+
+use regex::Regex;
+
+use clap::{App, Arg, ArgGroup};
+
+fn compare<S, S2>(l: S, r: S2) -> bool
+where
+    S: AsRef<str>,
+    S2: AsRef<str>,
+{
+    let re = Regex::new("\x1b[^m]*m").unwrap();
+    // Strip out any mismatching \r character on windows that might sneak in on either side
+    let ls = l.as_ref().trim().replace("\r", "");
+    let rs = r.as_ref().trim().replace("\r", "");
+    let left = re.replace_all(&*ls, "");
+    let right = re.replace_all(&*rs, "");
+    let b = left == right;
+    if !b {
+        println!();
+        println!("--> left");
+        println!("{}", left);
+        println!("--> right");
+        println!("{}", right);
+        println!("--")
+    }
+    b
+}
+
+pub fn compare_output(l: App, args: &str, right: &str, stderr: bool) -> bool {
+    let mut buf = Cursor::new(Vec::with_capacity(50));
+    let res = l.try_get_matches_from(args.split(' ').collect::<Vec<_>>());
+    let err = res.unwrap_err();
+    err.write_to(&mut buf).unwrap();
+    let content = buf.into_inner();
+    let left = String::from_utf8(content).unwrap();
+    assert_eq!(
+        stderr,
+        err.use_stderr(),
+        "Should Use STDERR failed. Should be {} but is {}",
+        stderr,
+        err.use_stderr()
+    );
+    compare(left, right)
+}
+
+pub fn compare_output2(l: App, args: &str, right1: &str, right2: &str, stderr: bool) -> bool {
+    let mut buf = Cursor::new(Vec::with_capacity(50));
+    let res = l.try_get_matches_from(args.split(' ').collect::<Vec<_>>());
+    let err = res.unwrap_err();
+    err.write_to(&mut buf).unwrap();
+    let content = buf.into_inner();
+    let left = String::from_utf8(content).unwrap();
+    assert_eq!(stderr, err.use_stderr());
+    compare(&*left, right1) || compare(&*left, right2)
+}
+
+// Legacy tests from the pyhton script days
+
+pub fn complex_app() -> App<'static> {
+    let opt3_vals = ["fast", "slow"];
+    let pos3_vals = ["vi", "emacs"];
+
+    App::new("clap-test")
+        .version("v1.4.8")
+        .about("tests clap library")
+        .author("Kevin K. <kbknapp@gmail.com>")
+        .arg("-o --option=[opt]... 'tests options'")
+        .arg("[positional] 'tests positionals'")
+        .arg(Arg::from("-f --flag... 'tests flags'").global(true))
+        .args(&[
+            Arg::from("[flag2] -F 'tests flags with exclusions'")
+                .conflicts_with("flag")
+                .requires("long-option-2"),
+            Arg::from("--long-option-2 [option2] 'tests long options with exclusions'")
+                .conflicts_with("option")
+                .requires("positional2"),
+            Arg::from("[positional2] 'tests positionals with exclusions'"),
+            Arg::from("-O --Option [option3] 'specific vals'").possible_values(&opt3_vals),
+            Arg::from("[positional3]... 'tests specific values'").possible_values(&pos3_vals),
+            Arg::from("--multvals [one] [two] 'Tests mutliple values, not mult occs'"),
+            Arg::from("--multvalsmo... [one] [two] 'Tests mutliple values, and mult occs'"),
+            Arg::from("--minvals2 [minvals]... 'Tests 2 min vals'").min_values(2),
+            Arg::from("--maxvals3 [maxvals]... 'Tests 3 max vals'").max_values(3),
+        ])
+        .subcommand(
+            App::new("subcmd")
+                .about("tests subcommands")
+                .version("0.1")
+                .author("Kevin K. <kbknapp@gmail.com>")
+                .arg("-o --option [scoption]... 'tests options'")
+                .arg("-s --subcmdarg [subcmdarg] 'tests other args'")
+                .arg("[scpositional] 'tests positionals'"),
+        )
+}
diff --git a/tests/version.rs b/tests/version.rs
index 6a934777..8407b40d 100644
--- a/tests/version.rs
+++ b/tests/version.rs
@@ -1,12 +1,9 @@
-extern crate clap;
-extern crate regex;
+mod utils;
 
 use std::str;
 
 use clap::{App, AppSettings, ErrorKind};
 
-include!("../clap-test.rs");
-
 static VERSION: &str = "clap-test v1.4.8";
 
 #[test]
diff --git a/tests/yaml.rs b/tests/yaml.rs
index e9c524fd..f211d815 100644
--- a/tests/yaml.rs
+++ b/tests/yaml.rs
@@ -4,20 +4,20 @@ use clap::{load_yaml, App};
 
 #[test]
 fn create_app_from_yaml() {
-    let yml = load_yaml!("app.yml");
+    let yml = load_yaml!("fixtures/app.yml");
     App::from(yml);
 }
 
 // TODO: Uncomment to test yaml with 2 spaces https://github.com/chyh1990/yaml-rust/issues/101
 // #[test]
 // fn create_app_from_yaml_2spaces() {
-//     let yml = load_yaml!("app_2space.yml");
+//     let yml = load_yaml!("fixtures/app_2space.yml");
 //     App::from(yml);
 // }
 
 #[test]
 fn help_message() {
-    let yml = load_yaml!("app.yml");
+    let yml = load_yaml!("fixtures/app.yml");
     let mut app = App::from(yml);
     // Generate the full help message!
     let _ = app.try_get_matches_from_mut(Vec::<String>::new());
@@ -32,7 +32,7 @@ fn help_message() {
 
 #[test]
 fn author() {
-    let yml = load_yaml!("app.yml");
+    let yml = load_yaml!("fixtures/app.yml");
     let mut app = App::from(yml);
     // Generate the full help message!
     let _ = app.try_get_matches_from_mut(Vec::<String>::new());