mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 14:54:15 +00:00
tests: silence some warnings
This commit is contained in:
parent
1fa4afa45d
commit
4c54c2a696
3 changed files with 30 additions and 26 deletions
|
@ -10,7 +10,7 @@ use std::io::Cursor;
|
|||
use clap::App;
|
||||
use clap::{Arg, SubCommand};
|
||||
|
||||
fn build_help(app: &App) -> String {
|
||||
fn build_help(app: &mut App) -> String {
|
||||
let mut buf = Cursor::new(Vec::with_capacity(50));
|
||||
app.write_help(&mut buf).unwrap();
|
||||
let content = buf.into_inner();
|
||||
|
@ -165,60 +165,60 @@ fn app_example10<'b, 'c>() -> App<'b, 'c> {
|
|||
|
||||
#[bench]
|
||||
fn example1(b: &mut Bencher) {
|
||||
let app = app_example1();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example1();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example2(b: &mut Bencher) {
|
||||
let app = app_example2();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example2();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example3(b: &mut Bencher) {
|
||||
let app = app_example3();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example3();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example4(b: &mut Bencher) {
|
||||
let app = app_example4();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example4();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example5(b: &mut Bencher) {
|
||||
let app = app_example5();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example5();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example6(b: &mut Bencher) {
|
||||
let app = app_example6();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example6();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example7(b: &mut Bencher) {
|
||||
let app = app_example7();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example7();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example8(b: &mut Bencher) {
|
||||
let app = app_example8();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example8();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example10(b: &mut Bencher) {
|
||||
let app = app_example10();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example10();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn example4_template(b: &mut Bencher) {
|
||||
let app = app_example4().template("{bin} {version}\n{author}\n{about}\n\nUSAGE:\n {usage}\n\nFLAGS:\n{flags}\n\nARGS:\n{args}\n");
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_example4().template("{bin} {version}\n{author}\n{about}\n\nUSAGE:\n {usage}\n\nFLAGS:\n{flags}\n\nARGS:\n{args}\n");
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ fn build_app_long(b: &mut Bencher) { b.iter(|| app_long()); }
|
|||
|
||||
#[bench]
|
||||
fn build_help_short(b: &mut Bencher) {
|
||||
let app = app_short();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_short();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
fn build_help_long(b: &mut Bencher) {
|
||||
let app = app_long();
|
||||
b.iter(|| build_help(&app));
|
||||
let mut app = app_long();
|
||||
b.iter(|| build_help(&mut app));
|
||||
}
|
||||
|
||||
#[bench]
|
||||
|
@ -261,7 +261,7 @@ pub fn app_short() -> App<'static, 'static> { app(false, |k| USAGES[k].short) }
|
|||
pub fn app_long() -> App<'static, 'static> { app(true, |k| USAGES[k].long) }
|
||||
|
||||
/// Build the help text of an application.
|
||||
fn build_help(app: &App) -> String {
|
||||
fn build_help(app: &mut App) -> String {
|
||||
let mut buf = Cursor::new(Vec::with_capacity(50));
|
||||
app.write_help(&mut buf).unwrap();
|
||||
let content = buf.into_inner();
|
||||
|
|
|
@ -189,6 +189,7 @@ complete -c myapp -n "__fish_using_command myapp help" -s h -l help -d 'Prints h
|
|||
complete -c myapp -n "__fish_using_command myapp help" -s V -l version -d 'Prints version information'
|
||||
"#;
|
||||
|
||||
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
static POWERSHELL: &'static str = r#"
|
||||
@('myapp', './myapp') | %{
|
||||
|
@ -240,6 +241,7 @@ static POWERSHELL: &'static str = r#"
|
|||
}
|
||||
"#;
|
||||
|
||||
#[cfg_attr(target_os = "windows", allow(dead_code))]
|
||||
#[cfg(target_os = "windows")]
|
||||
static POWERSHELL: &'static str = r#"
|
||||
@('myapp', './myapp', 'myapp.exe', '.\myapp', '.\myapp.exe', './myapp.exe') | %{
|
||||
|
@ -280,6 +282,7 @@ static POWERSHELL: &'static str = r#"
|
|||
}
|
||||
"#;
|
||||
|
||||
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
||||
@('my_app', './my_app') | %{
|
||||
|
@ -340,6 +343,7 @@ static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
|||
}
|
||||
"#;
|
||||
|
||||
#[cfg_attr(target_os = "windows", allow(dead_code))]
|
||||
#[cfg(target_os = "windows")]
|
||||
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
||||
@('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{
|
||||
|
|
Loading…
Reference in a new issue