test: Support -cli tests using external bitcoin-cli #15155

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:test_external_bcli changing 1 files +7 −4
  1. luke-jr commented at 1:33 PM on January 12, 2019: member

    It can be useful to build only bitcoind and still run the full test suite using an external bitcoin-cli instance.

    Use case: Automated package testing can have a build-time dependency on the bitcoin-cli package and use it to run tests on a bitcoind-only build.

  2. test: Support -cli tests using external bitcoin-cli 0bcc0433b6
  3. fanquake added the label Tests on Jan 12, 2019
  4. in test/functional/test_framework/test_framework.py:541 in 0bcc0433b6
     540 |  
     541 | -    def is_cli_compiled(self):
     542 | -        """Checks whether bitcoin-cli was compiled."""
     543 | +    def is_cli_available(self):
     544 | +        """Checks whether bitcoin-cli is available."""
     545 | +        if os.getenv("BITCOINCLI", "__NOT_SET__") != "__NOT_SET__":
    


    kristapsk commented at 1:59 PM on January 12, 2019:

    Why not just - if os.getenv("BITCOINCLI") != None:?


    luke-jr commented at 2:29 PM on January 12, 2019:

    Python's documentation says getenv returns a string, but without a default it returns None in CPython. Providing a default avoids the ambiguity/contradiction.


    kristapsk commented at 3:32 PM on January 12, 2019:

    luke-jr commented at 11:07 PM on January 12, 2019:

    "key, default and the result are str."


    kristapsk commented at 11:24 PM on January 12, 2019:

    But it actually returns None, which isn't string, if environment variable is not set, both in Python2 and Python3.

    $ python
    Python 3.6.5 (default, Sep 11 2018, 13:54:50) 
    [GCC 4.9.3] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> type(os.getenv('unsetenvironmentvariable'))
    <class 'NoneType'>
    

    luke-jr commented at 11:25 PM on January 12, 2019:

    But that's not documented/guaranteed behaviour.


    kristapsk commented at 11:56 PM on January 12, 2019:

    Default being None is documented.


    luke-jr commented at 12:14 AM on January 13, 2019:

    Not as a return value.


    laanwj commented at 12:46 PM on January 14, 2019:

    I agree with @kristapsk here. The correct way to do this is:

    if os.getenv("BITCOINCLI") is not None:
    

    or, if you don't want to support an empty value / regard an empty value as unset

    if not os.getenv("BITCOINCLI"):
    

    Special-casing is a default value is, imo, fragile and ugly.


    luke-jr commented at 5:03 PM on January 14, 2019:

    Special-casing the default here is well-defined, not fragile... the alternatives are what is fragile, since they're not guaranteed behaviours [yet?].


    maflcko commented at 6:20 PM on January 14, 2019:

    Returning None or a string is just the pythonic way to say it returns optional<string>


    laanwj commented at 5:20 PM on January 16, 2019:

    Returning None or a string is just the pythonic way to say it returns optional<string>

    Exactly.

  5. laanwj commented at 3:56 PM on January 14, 2019: member

    Concept ACK anyhow

  6. laanwj commented at 12:21 PM on January 22, 2019: member

    @luke-jr can you please address the comment, it's a trivial change but not going to be merged like this

  7. laanwj added the label Up for grabs on Feb 12, 2019
  8. laanwj commented at 1:17 PM on February 12, 2019: member

    Closing this and putting up for grabs, it's desirable functionality but not implemented in an acceptable way imo.

  9. laanwj closed this on Feb 12, 2019

  10. maflcko removed the label Up for grabs on Nov 19, 2019
  11. maflcko added the label Up for grabs on Nov 19, 2019
  12. bitcoin locked this on Dec 16, 2021
  13. maflcko removed the label Up for grabs on Dec 12, 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: 2026-04-14 15:15 UTC

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