test: Add test codebase for shell completions#14681
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
| } | ||
|
|
||
| fn get_installed_crates() -> Vec<clap_complete::CompletionCandidate> { | ||
| pub fn get_installed_crates() -> Vec<clap_complete::CompletionCandidate> { |
There was a problem hiding this comment.
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.
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.
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.
| { | ||
| Ok(registries | ||
| .keys() | ||
| .sorted() |
There was a problem hiding this comment.
- This appears to be unrelated to the current commit
- This should likely be a
fixcommit on its own
|
☔ The latest upstream changes (possibly 307cbfd) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
I'm interested in working on this. Would you mind if I took over this PR? @shannmu |
|
As this has been in draft for over a year, I'm going to go ahead and close this. |
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