-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Add test codebase for shell completions #14681
base: master
Are you sure you want to change the base?
Conversation
…pletions` Passing `cwd` to custom completion functions makes that we could generate completions in the template project.
- Add an empty template project, which is used for building test cases - Add a format function used for completions result
- Sort the order of example candidates by the way
@@ -45,7 +45,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult { | |||
Ok(()) | |||
} | |||
|
|||
fn get_installed_crates() -> Vec<clap_complete::CompletionCandidate> { | |||
pub fn get_installed_crates() -> Vec<clap_complete::CompletionCandidate> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This being pub
doesn't make a difference as this only exists in the bin
@@ -0,0 +1,15 @@ | |||
#![allow(unused)] | |||
fn print_candidates(candidates: Vec<clap_complete::CompletionCandidate>) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
render_candidates
since this doesn't print to stdout/stderr
let current_dir = std::env::current_dir().expect("Failed to get current directory"); | ||
let cwd = PathBuf::from(file!()).parent().unwrap().join("template"); | ||
let cwd = current_dir.join(cwd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A temp directory is created for each test. I'd recommend going ahead and writing to that and using that as the "cwd" for the test case. We have ProjectBuilder
to help in creating these. You can also publish packages to a dev registry.
@@ -1104,14 +1105,15 @@ pub fn get_registry_candidates( | |||
{ | |||
Ok(registries | |||
.keys() | |||
.sorted() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This appears to be unrelated to the current commit
- This should likely be a
fix
commit on its own
What does this PR try to resolve?
Tracking issue #14520
get_registry_candidates
,get_example_candidates
,get_test_candidates
,get_bench_candidates
,get_bin_candidates