test: Consolidate builder tests

This is prep for moving the derive tests.  Besides organizing the test
folder for each API, this should reduce link time at the cost of
re-compiling more when a test changes.
This commit is contained in:
Ed Page 2021-11-30 09:31:19 -06:00
parent 2288f55cc1
commit 045bf99ae0
49 changed files with 70 additions and 61 deletions

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, AppSettings, Arg, ErrorKind}; use clap::{arg, App, AppSettings, Arg, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, Arg}; use clap::{arg, App, Arg};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, Arg}; use clap::{arg, App, Arg};

View file

@ -1,5 +1,3 @@
mod utils;
use clap::{Arg, ArgSettings}; use clap::{Arg, ArgSettings};
#[test] #[test]

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, Arg, ArgGroup, ErrorKind}; use clap::{arg, App, Arg, ArgGroup, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, Arg, ErrorKind}; use clap::{arg, App, Arg, ErrorKind};
#[test] #[test]

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use std::str; use std::str;

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::App; use clap::App;

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{App, Arg, ErrorKind}; use clap::{App, Arg, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{App, Arg, Error, ErrorKind}; use clap::{App, Arg, Error, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, AppSettings, Arg, ErrorKind}; use clap::{arg, App, AppSettings, Arg, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, Arg}; use clap::{arg, App, Arg};
const USE_FLAG_AS_ARGUMENT: &str = const USE_FLAG_AS_ARGUMENT: &str =

View file

@ -1,5 +1,3 @@
mod utils;
use clap::{arg, App, Arg}; use clap::{arg, App, Arg};
#[test] #[test]

View file

@ -1,7 +1,5 @@
#![cfg(feature = "unstable-grouped")] #![cfg(feature = "unstable-grouped")]
mod utils;
use clap::{App, AppSettings, Arg}; use clap::{App, AppSettings, Arg};
#[test] #[test]

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, Arg, ArgGroup, ErrorKind}; use clap::{arg, App, Arg, ArgGroup, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, AppSettings, Arg, ArgGroup, ErrorKind, PossibleValue}; use clap::{arg, App, AppSettings, Arg, ArgGroup, ErrorKind, PossibleValue};

View file

@ -4,7 +4,7 @@ use std::env;
use clap::{App, Arg}; use clap::{App, Arg};
mod utils; use crate::utils;
static HIDE_ENV: &str = "ctest 0.1 static HIDE_ENV: &str = "ctest 0.1

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, AppSettings, Arg}; use clap::{arg, App, AppSettings, Arg};

View file

@ -1,5 +1,3 @@
mod utils;
use clap::{App, Arg}; use clap::{App, Arg};
#[test] #[test]

47
tests/builder/main.rs Normal file
View file

@ -0,0 +1,47 @@
mod app_from_crate;
mod app_settings;
mod arg_aliases;
mod arg_aliases_short;
mod arg_matcher_assertions;
mod arg_settings;
mod borrowed;
mod cargo;
mod conflicts;
mod default_missing_vals;
mod default_vals;
mod delimiters;
mod derive_order;
mod display_order;
mod double_require;
mod empty_values;
mod env;
mod error;
mod flag_subcommands;
mod flags;
mod global_args;
mod grouped_values;
mod groups;
mod help;
mod help_env;
mod hidden_args;
mod ignore_errors;
mod indices;
mod multiple_occurrences;
mod multiple_values;
mod opts;
mod positionals;
mod posix_compatible;
mod possible_values;
mod propagate_globals;
mod regex;
mod require;
mod subcommands;
mod template_help;
mod tests;
mod unicode;
mod unique_args;
mod utf16;
mod utf8;
mod utils;
mod validators;
mod version;

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, AppSettings, Arg, ArgMatches, ErrorKind}; use clap::{arg, App, AppSettings, Arg, ArgMatches, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{App, Arg, ErrorKind, PossibleValue}; use clap::{App, Arg, ErrorKind, PossibleValue};

View file

@ -1,5 +1,3 @@
mod utils;
use clap::{App, Arg, ArgMatches}; use clap::{App, Arg, ArgMatches};
fn get_app() -> App<'static> { fn get_app() -> App<'static> {

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, Arg, ArgGroup, ErrorKind}; use clap::{arg, App, Arg, ArgGroup, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App, AppSettings, Arg, ErrorKind}; use clap::{arg, App, AppSettings, Arg, ErrorKind};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use clap::{arg, App}; use clap::{arg, App};

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use std::io::Write; use std::io::Write;
use std::str; use std::str;

View file

@ -1,4 +1,4 @@
mod utils; use crate::utils;
use std::str; use std::str;

View file

@ -1,28 +1,7 @@
mod utils;
// We intentionally don't import `clap_app!` here; not having it in scope protects against the // We intentionally don't import `clap_app!` here; not having it in scope protects against the
// class of errors where the macro refers to itself as `clap_app!` instead of `$crate::clap_app!` // class of errors where the macro refers to itself as `clap_app!` instead of `$crate::clap_app!`
use clap::ErrorKind; use clap::ErrorKind;
static LITERALS: &str = "clap-tests 0.1
USAGE:
clap-tests [OPTIONS] [SUBCOMMAND]
OPTIONS:
-4, --4 Sets priority to 4
-5, --5 Sets priority to 5
-6, --6 Sets priority to 6
-h, --help Print help information
-t, --task-num <task-num> Task number [possible values: all, 0, 1, 2]
-V, --version Print version information
SUBCOMMANDS:
0 Set everything to zero priority
help Print this message or the help of the given subcommand(s)
view-tasks View all tasks
";
#[test] #[test]
fn basic() { fn basic() {
#![allow(deprecated)] #![allow(deprecated)]
@ -441,7 +420,7 @@ fn group_macro_multiple_invocations() {
#[test] #[test]
fn literals() { fn literals() {
#![allow(deprecated)] #![allow(deprecated)]
let app = clap::clap_app!("clap-tests" => clap::clap_app!("clap-tests" =>
(version: "0.1") (version: "0.1")
(@arg "task-num": -"t-n" --"task-num" +takes_value possible_value["all" 0 1 2] (@arg "task-num": -"t-n" --"task-num" +takes_value possible_value["all" 0 1 2]
"Task number") "Task number")
@ -455,13 +434,6 @@ fn literals() {
(@subcommand 0 => (@subcommand 0 =>
(about: "Set everything to zero priority")) (about: "Set everything to zero priority"))
); );
assert!(utils::compare_output(
app,
"clap-tests --help",
LITERALS,
false
));
} }
#[test] #[test]