test: checks that bitcoin-cli autocomplete is in sync #18606

pull pierreN wants to merge 4 commits into bitcoin:master from pierreN:feature-auto-cli changing 12 files +588 −100
  1. pierreN commented at 2:52 pm on April 12, 2020: contributor

    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.

    The first commit syncs the auto-completion file with the current master. The second commits adds the test. It just changes the header of the autocomplete file and moves it to test/functional/data/completion/bitcoin-cli.bash-completion (plus for ease of use and backward compatibility a symlink from contrib/bitcoin-cli.bash-completion to the moved file is created).

    This PR aims to fix: https://github.com/bitcoin/bitcoin/issues/17289

  2. pierreN renamed this:
    test: check that bitcoin-cli autocomplete is in sync
    test: checks that bitcoin-cli autocomplete is in sync
    on Apr 12, 2020
  3. DrahtBot added the label Scripts and tools on Apr 12, 2020
  4. DrahtBot added the label Tests on Apr 12, 2020
  5. in contrib/bitcoin-cli.bash-completion:1 in b9ee5478b4 outdated
    -1@@ -1,141 +0,0 @@
    0-# bash programmable completion for bitcoin-cli(1)
    


    MarcoFalke commented at 5:13 pm on April 12, 2020:

    Why?

    I’d argue the file should stay in the old directory. All the functional test needs is read-access to the file. You can get the file path in the test with:

    0os.path.join(config["environment"]["SRCDIR"], 'contrib', ...
    

    pierreN commented at 5:39 pm on April 12, 2020:
    Thanks, I was missing the config["environment"] variable. Branch updated.
  6. MarcoFalke approved
  7. MarcoFalke commented at 5:13 pm on April 12, 2020: member
    Concept ACK
  8. MarcoFalke removed the label Tests on Apr 12, 2020
  9. pierreN force-pushed on Apr 12, 2020
  10. pierreN force-pushed on Apr 12, 2020
  11. pierreN commented at 9:19 pm on April 12, 2020: contributor

    It seems that even when using SRCDIR CI builds fail: https://travis-ci.org/github/pierreN/bitcoin/jobs/674154306#L3417

    A decent way to fix this would be to add the bash auto-completion file to Makefile.am’s EXTRA_DIST. I updated the PR to reflect that.

    If you think this is too intrusive, another more hackish way would be to just look for the file in the parent directories (https://github.com/pierreN/bitcoin/blob/feature-auto-cli-2/test/functional/tool_cli_completion.py#L260)?

  12. in test/functional/tool_cli_completion.py:153 in 4576b77818 outdated
    148+
    149+    def parse_single_helper(self, option):
    150+        """ Complete the arguments of option via the RPC help command. """
    151+
    152+        # if we can't find an argument list in the help text, then it has no option to add
    153+        regexp_res = ARG_REGEXP.match(self.nodes[0].help(option.command))
    


    MarcoFalke commented at 10:43 pm on April 12, 2020:
    0        res = self.nodes[0].format(command=option.command, output=args_cli)
    

    Instead of using regex to parse the pseudo doc-json, a hidden RPC could be added that spits out the format you want.

    I think all you need to do is register a formatter in RPCMan::Check


    pierreN commented at 7:37 am on April 14, 2020:

    Yes, good idea. I have updated the branch to do that. Please have a look at the new code, thanks.

    Note that some non-hidden RPC calls didn’t use RPCHelpMan::Check so I added a commit to fix that first (otherwise they wouldn’t appear in the bash cli completion file).


    pierreN commented at 2:57 pm on April 18, 2020:
    I hadn’t notice #18531 when writing 412bb2f - I’ll rebase this PR after #18531 is merged.
  13. rpc: make all unhidden actors use RPCHelpMan::Check 18602f1993
  14. in Makefile.am:49 in 4576b77818 outdated
    44@@ -45,7 +45,8 @@ OSX_QT_TRANSLATIONS = da,de,es,hu,ru,uk,zh_CN,zh_TW
    45 
    46 DIST_CONTRIB = \
    47 	       $(top_srcdir)/contrib/linearize/linearize-data.py \
    48-	       $(top_srcdir)/contrib/linearize/linearize-hashes.py
    49+	       $(top_srcdir)/contrib/linearize/linearize-hashes.py \
    50+	       $(top_srcdir)/contrib/bitcoin-cli.bash-completion
    


    MarcoFalke commented at 10:44 pm on April 12, 2020:
    Looks good this way, if it makes out-of-tree builds happy. :+1:
  15. pierreN force-pushed on Apr 14, 2020
  16. DrahtBot commented at 12:24 pm on April 14, 2020: member

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #19386 (rpc: Assert that RPCArg names are equal to CRPCCommand ones (server) by MarcoFalke)
    • #19262 (rpc: Replace OMITTED_NAMED_ARG with OMITTED by MarcoFalke)
    • #18788 (tests: Update more tests to work with descriptor wallets by achow101)
    • #16365 (Log RPC parameters (arguments) if -debug=rpcparams by LarryRuane)

    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.

  17. rpc: add format command with support for args_cli
    - 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
    92a8bf422f
  18. contrib: sync bitcoin-cli bash autocompletion e159c3e562
  19. test: keeps bitcoin-cli autocomplete in sync
    Add a functional test which 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.
    a08159006f
  20. pierreN force-pushed on Apr 14, 2020
  21. pierreN commented at 12:57 pm on April 14, 2020: contributor

    Updated branch to partially get rid of conflict with #17356 (some conflict might be left if git is not clever enough).

    Added a comment for #12674 : https://github.com/bitcoin/bitcoin/pull/12674/files#r408113386

  22. DrahtBot added the label Needs rebase on Jul 15, 2020
  23. DrahtBot commented at 6:58 pm on July 15, 2020: member

    🐙 This pull request conflicts with the target branch and needs rebase.

  24. adamjonas commented at 7:52 pm on January 14, 2021: member
    @pierreN is this something you plan on continuing to work on?
  25. adamjonas commented at 3:02 pm on March 19, 2021: member
    @pierreN ping for rebase.
  26. pierreN commented at 9:39 pm on May 6, 2021: contributor
    Sorry for the few months delay. I have a bit more time now and will try to follow through with this PR.
  27. DrahtBot commented at 11:22 am on December 15, 2021: member
    • Is it still relevant? ➡️ Please solve the conflicts to make it ready for review and to ensure the CI passes.
    • Is it no longer relevant? ➡️ Please close.
    • Did the author lose interest or time to work on this? ➡️ Please close it and mark it ‘Up for grabs’ with the label, so that it can be picked up in the future.
  28. in contrib/bitcoin-cli.bash-completion:7 in a08159006f
    0@@ -1,5 +1,10 @@
    1-# bash programmable completion for bitcoin-cli(1)
    2-# Copyright (c) 2012-2019 The Bitcoin Core developers
    3+# Dynamic bash programmable completion for bitcoin-cli(1)
    4+#     DO NOT EDIT THIS FILE BY HAND -- THIS WILL FAIL THE FUNCTIONAL TEST tool_cli_completion
    5+# This file is auto-generated by the functional test tool_cli_completion.
    6+# If you want to modify this file, modify test/functional/tool_cli_completion.py and re-autogenerate
    7+# this file via the --overwrite test flag.
    8+
    9+# Copyright (c) 2012-2020 The Bitcoin Core developers
    


    niVelion commented at 11:49 am on January 14, 2022:

    Happy New Year :clinking_glasses:

    0# Copyright (c) 2012-2022 The Bitcoin Core developers
    
  29. niVelion commented at 12:27 pm on January 14, 2022: none

    ACK, would be great to see this merged.

    I can see in https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#squashing-commits that the next task is primarily to amend the commit message after squashing, the message that’ll make it into the master branch to describe this improvement.

    Here’s the starting point:

     0# This is a combination of 4 commits.
     1# This is the 1st commit message:
     2
     3rpc: make all unhidden actors use RPCHelpMan::Check
     4
     5# This is the commit message [#2](/bitcoin-bitcoin/2/):
     6
     7rpc: add format command with support for args_cli
     8
     9- add format command to get infos about commands via a particular format
    10- add output format args_cli to get arguments type info of shown commands
    11- refactor RPCArg::ToTypeString to be used accross multiple output formats
    12- overload CRPCTable::execute to call != methods than in their request
    13
    14# This is the commit message [#3](/bitcoin-bitcoin/3/):
    15
    16contrib: sync bitcoin-cli bash autocompletion
    17
    18# This is the commit message [#4](/bitcoin-bitcoin/4/):
    19
    20test: keeps bitcoin-cli autocomplete in sync
    21
    22Add a functional test which parses available RPC commands, generates
    23the associated bitcoin-cli autocomplete file and checks that the current
    24autocomplete file matches.
    25An outdated autocomplete file can be updated via the --overwrite test
    26parameter.
    
  30. fanquake added the label Up for grabs on Apr 26, 2022
  31. fanquake closed this on Apr 26, 2022

  32. fanquake removed the label Up for grabs on May 30, 2022
  33. fanquake commented at 9:37 am on May 30, 2022: member
    #25243 has picked this up.
  34. DrahtBot locked this on May 30, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-05 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me