tests(auto-completion): Normalise names in tests/completions.rs

From            -> To
===========================================
with_underscore -> (with_)?special_commands
WUS             -> SPECIAL_CMDS
special         -> special_help
SPECIAL         -> SPECIAL_HELP
This commit is contained in:
Alex Helfet 2017-12-16 10:09:09 +00:00
parent e0f8479e0f
commit 09d1d4a568

View file

@ -270,7 +270,7 @@ static POWERSHELL: &'static str = r#"
"#; "#;
#[cfg(not(target_os="windows"))] #[cfg(not(target_os="windows"))]
static POWERSHELL_WUS: &'static str = r#" static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
@('my_app', './my_app') | %{ @('my_app', './my_app') | %{
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock { Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition) param($wordToComplete, $commandAst, $cursorPosition)
@ -330,7 +330,7 @@ static POWERSHELL_WUS: &'static str = r#"
"#; "#;
#[cfg(target_os="windows")] #[cfg(target_os="windows")]
static POWERSHELL_WUS: &'static str = r#" static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
@('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{ @('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock { Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition) param($wordToComplete, $commandAst, $cursorPosition)
@ -376,7 +376,7 @@ static POWERSHELL_WUS: &'static str = r#"
} }
"#; "#;
static ZSH_WUS: &'static str = r#"#compdef my_app static ZSH_SPECIAL_CMDS: &'static str = r#"#compdef my_app
_my_app() { _my_app() {
typeset -A opt_args typeset -A opt_args
@ -460,7 +460,7 @@ _my_app__test_commands() {
_my_app "$@""#; _my_app "$@""#;
static FISH_WUS: &'static str = r#"function __fish_using_command static FISH_SPECIAL_CMDS: &'static str = r#"function __fish_using_command
set cmd (commandline -opc) set cmd (commandline -opc)
if [ (count $cmd) -eq (count $argv) ] if [ (count $cmd) -eq (count $argv) ]
for i in (seq (count $argv)) for i in (seq (count $argv))
@ -488,7 +488,7 @@ complete -c my_app -n "__fish_using_command my_app help" -s h -l help -d 'Prints
complete -c my_app -n "__fish_using_command my_app help" -s V -l version -d 'Prints version information' complete -c my_app -n "__fish_using_command my_app help" -s V -l version -d 'Prints version information'
"#; "#;
static BASH_WUS: &'static str = r#"_my_app() { static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() {
local i cur prev opts cmds local i cur prev opts cmds
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -593,7 +593,7 @@ static BASH_WUS: &'static str = r#"_my_app() {
complete -F _my_app -o bashdefault -o default my_app complete -F _my_app -o bashdefault -o default my_app
"#; "#;
static FISH_SPECIAL: &'static str = r#"function __fish_using_command static FISH_SPECIAL_HELP: &'static str = r#"function __fish_using_command
set cmd (commandline -opc) set cmd (commandline -opc)
if [ (count $cmd) -eq (count $argv) ] if [ (count $cmd) -eq (count $argv) ]
for i in (seq (count $argv)) for i in (seq (count $argv))
@ -616,7 +616,7 @@ complete -c my_app -n "__fish_using_command my_app" -s h -l help -d 'Prints help
complete -c my_app -n "__fish_using_command my_app" -s V -l version -d 'Prints version information' complete -c my_app -n "__fish_using_command my_app" -s V -l version -d 'Prints version information'
"#; "#;
static ZSH_SPECIAL: &'static str = r#"#compdef my_app static ZSH_SPECIAL_HELP: &'static str = r#"#compdef my_app
_my_app() { _my_app() {
typeset -A opt_args typeset -A opt_args
@ -685,7 +685,7 @@ fn build_app_with_name(s: &'static str) -> App<'static, 'static> {
.help("the case to test"))) .help("the case to test")))
} }
fn build_app_with_underscore() -> App<'static, 'static> { fn build_app_special_commands() -> App<'static, 'static> {
build_app_with_name("my_app").subcommand(SubCommand::with_name("some_cmd") build_app_with_name("my_app").subcommand(SubCommand::with_name("some_cmd")
.about("tests other things") .about("tests other things")
.arg(Arg::with_name("config") .arg(Arg::with_name("config")
@ -694,7 +694,7 @@ fn build_app_with_underscore() -> App<'static, 'static> {
.help("the other case to test"))) .help("the other case to test")))
} }
fn build_app_special() -> App<'static, 'static> { fn build_app_special_help() -> App<'static, 'static> {
App::new("my_app") App::new("my_app")
.arg(Arg::with_name("single-quotes") .arg(Arg::with_name("single-quotes")
.long("single-quotes") .long("single-quotes")
@ -759,61 +759,61 @@ fn fish() {
// Disabled until I figure out this windows line ending and AppVeyor issues // Disabled until I figure out this windows line ending and AppVeyor issues
//#[test] //#[test]
// fn powershell_with_underscore() { // fn powershell_with_special_commands() {
// let mut app = build_app_with_underscore(); // let mut app = build_app_special_commands();
// let mut buf = vec![]; // let mut buf = vec![];
// app.gen_completions_to("my_app", Shell::PowerShell, &mut buf); // app.gen_completions_to("my_app", Shell::PowerShell, &mut buf);
// let string = String::from_utf8(buf).unwrap(); // let string = String::from_utf8(buf).unwrap();
// //
// assert!(compare(&*string, POWERSHELL_WUS)); // assert!(compare(&*string, POWERSHELL_SPECIAL_CMDS));
// } // }
#[test] #[test]
fn bash_with_underscore() { fn bash_with_special_commands() {
let mut app = build_app_with_underscore(); let mut app = build_app_special_commands();
let mut buf = vec![]; let mut buf = vec![];
app.gen_completions_to("my_app", Shell::Bash, &mut buf); app.gen_completions_to("my_app", Shell::Bash, &mut buf);
let string = String::from_utf8(buf).unwrap(); let string = String::from_utf8(buf).unwrap();
assert!(compare(&*string, BASH_WUS)); assert!(compare(&*string, BASH_SPECIAL_CMDS));
} }
#[test] #[test]
fn fish_with_underscore() { fn fish_with_special_commands() {
let mut app = build_app_with_underscore(); let mut app = build_app_special_commands();
let mut buf = vec![]; let mut buf = vec![];
app.gen_completions_to("my_app", Shell::Fish, &mut buf); app.gen_completions_to("my_app", Shell::Fish, &mut buf);
let string = String::from_utf8(buf).unwrap(); let string = String::from_utf8(buf).unwrap();
assert!(compare(&*string, FISH_WUS)); assert!(compare(&*string, FISH_SPECIAL_CMDS));
} }
#[test] #[test]
fn zsh_with_underscore() { fn zsh_with_special_commands() {
let mut app = build_app_with_underscore(); let mut app = build_app_special_commands();
let mut buf = vec![]; let mut buf = vec![];
app.gen_completions_to("my_app", Shell::Zsh, &mut buf); app.gen_completions_to("my_app", Shell::Zsh, &mut buf);
let string = String::from_utf8(buf).unwrap(); let string = String::from_utf8(buf).unwrap();
assert!(compare(&*string, ZSH_WUS)); assert!(compare(&*string, ZSH_SPECIAL_CMDS));
} }
#[test] #[test]
fn fish_special() { fn fish_with_special_help() {
let mut app = build_app_special(); let mut app = build_app_special_help();
let mut buf = vec![]; let mut buf = vec![];
app.gen_completions_to("my_app", Shell::Fish, &mut buf); app.gen_completions_to("my_app", Shell::Fish, &mut buf);
let string = String::from_utf8(buf).unwrap(); let string = String::from_utf8(buf).unwrap();
assert!(compare(&*string, FISH_SPECIAL)); assert!(compare(&*string, FISH_SPECIAL_HELP));
} }
#[test] #[test]
fn zsh_special() { fn zsh_with_special_help() {
let mut app = build_app_special(); let mut app = build_app_special_help();
let mut buf = vec![]; let mut buf = vec![];
app.gen_completions_to("my_app", Shell::Zsh, &mut buf); app.gen_completions_to("my_app", Shell::Zsh, &mut buf);
let string = String::from_utf8(buf).unwrap(); let string = String::from_utf8(buf).unwrap();
assert!(compare(&*string, ZSH_SPECIAL)); assert!(compare(&*string, ZSH_SPECIAL_HELP));
} }