-
Notifications
You must be signed in to change notification settings - Fork 37.7k
test: autogenerate bash completion #30860
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
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/30860. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
https://github.com/bitcoin/bitcoin/actions/runs/10788681404/job/29919981336?pr=30860#step:7:3564: Run rpc with args ['/Users/runner/work/bitcoin/bitcoin/ci/scratch/build-x86_64-apple-darwin/src/test/fuzz/fuzz', PosixPath('/Users/runner/work/bitcoin/bitcoin/ci/scratch/qa-assets/fuzz_corpora/rpc')]Error: RPC command "format" not found in RPC_COMMANDS_SAFE_FOR_FUZZING or RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update src/test/fuzz/rpc.cpp.
libc++abi: terminating
Error: RPC command "format" not found in RPC_COMMANDS_SAFE_FOR_FUZZING or RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update src/test/fuzz/rpc.cpp.
libc++abi: terminating
Target ['/Users/runner/work/bitcoin/bitcoin/ci/scratch/build-x86_64-apple-darwin/src/test/fuzz/fuzz', PosixPath('/Users/runner/work/bitcoin/bitcoin/ci/scratch/qa-assets/fuzz_corpora/rpc')] failed with exit code -6 |
🚧 At least one of the CI tasks failed. HintsMake sure to run all tests locally, according to the documentation. The failure may happen due to a number of reasons, for example:
Leave a comment here, if you need help tracking down a confusing failure. |
Are you still working on this? (It looks like this has been opened as draft, with failing CI, which is fine. However, without any progress, it seems better to close this for now.) |
791096d
to
6b6a721
Compare
2f4b076
to
7c8b021
Compare
- add format command to get infos about commands via a particular format - add output format args_cli to get arguments type info of shown commands - refactor RPCArg::ToTypeString to be used accross multiple output formats - overload CRPCTable::execute to call != methods than in their request Co-authored-by: pierrenn <git@pnn.sh>
Adds a functional test which parses available RPC commands, generates the associated bitcoin-cli autcomplete file and checks that the current autocomplete matches the file An outdated autcomplete file can be updated using the --overwrite parameter Co-authored-by: pierrenn <git@pnn.sh>
7c8b021
to
abf6ad4
Compare
if len(options) == 0: | ||
return "" | ||
|
||
generated = "" |
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.
Since there is a discussion (#17289 (comment)) on whether it will slow down when user hit TAB key to send request to bitcoind for auto completion, what about we add those cword==1 commands in contrib/completions/bash/bitcoin-cli.bash so that it will not rely on the startup of bitcoind?
The suggested code is pasted below and tested:
# create cword==1 block to avoid the calling of bitcoind to get auto complete
commands = []
for command in options:
commands.append(command.command)
commands_str = " ".join(commands)
cword_1_block = f""" if ((cword == 1)); then
options=\"{commands_str}\"
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
return 0\n fi\n\n"""
generated = cword_1_block
I tested the code in mac(Apple M1 chip) and it worked fine. Steps are: # validate bash-completion on mac, first install bash-completion: # switch to bash shell # source the bash_completion script # source bitcoin-cli bash # then, without starting bitcoind #this will auto complete to converttopsbt #this will auto complete to converttopsbt % bitcoin-cli converttopsbt some t[TAB] # it will auto complete true % bitcoin-cli converttopsbt some true t[TAB] # it will auto complete false % bitcoin-cli converttopsbt some true false Also, traced the code, especially in test/functional/tool_cli_bash_completion.py: |
- add format command to get infos about commands via a particular format - add output format args_cli to get arguments type info of shown commands - refactor RPCArg::ToTypeString to be used accross multiple output formats - overload CRPCTable::execute to call != methods than in their request Co-authored-by: pierrenn <git@pnn.sh> Github-Pull: bitcoin#30860 Rebased-From: eb43862
Adds a functional test which parses available RPC commands, generates the associated bitcoin-cli autcomplete file and checks that the current autocomplete matches the file An outdated autcomplete file can be updated using the --overwrite parameter Co-authored-by: pierrenn <git@pnn.sh> Github-Pull: bitcoin#30860 Rebased-From: 7c8b021
🐙 This pull request conflicts with the target branch and needs rebase. |
⌛ There hasn't been much activity lately and the patch still needs rebase. What is the status here?
|
Fixes #17289, and follows up on #18606
Adds a functional test that parses available RPC commands, generates the associated bitcoin-cli autocomplete file and checks that the current autocomplete file matches.
An outdated autocomplete file can be updated via the --overwrite test parameter.