mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 23:09:44 -04:00
test, refactor: Add set_binary_paths
function
This change factors out the repeated code into a new `set_binary_paths` function.
This commit is contained in:
parent
da9f62f912
commit
dda961cec5
1 changed files with 17 additions and 18 deletions
|
@ -228,6 +228,22 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
|
|
||||||
PortSeed.n = self.options.port_seed
|
PortSeed.n = self.options.port_seed
|
||||||
|
|
||||||
|
def set_binary_paths(self):
|
||||||
|
"""Update self.options with the paths of all binaries from environment variables or their default values"""
|
||||||
|
|
||||||
|
binaries = {
|
||||||
|
"bitcoind": ("bitcoind", "BITCOIND"),
|
||||||
|
"bitcoin-cli": ("bitcoincli", "BITCOINCLI"),
|
||||||
|
"bitcoin-util": ("bitcoinutil", "BITCOINUTIL"),
|
||||||
|
}
|
||||||
|
for binary, [attribute_name, env_variable_name] in binaries.items():
|
||||||
|
default_filename = os.path.join(
|
||||||
|
self.config["environment"]["BUILDDIR"],
|
||||||
|
"src",
|
||||||
|
binary + self.config["environment"]["EXEEXT"],
|
||||||
|
)
|
||||||
|
setattr(self.options, attribute_name, os.getenv(env_variable_name, default=default_filename))
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Call this method to start up the test framework object with options set."""
|
"""Call this method to start up the test framework object with options set."""
|
||||||
|
|
||||||
|
@ -237,24 +253,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
|
|
||||||
config = self.config
|
config = self.config
|
||||||
|
|
||||||
fname_bitcoind = os.path.join(
|
self.set_binary_paths()
|
||||||
config["environment"]["BUILDDIR"],
|
|
||||||
"src",
|
|
||||||
"bitcoind" + config["environment"]["EXEEXT"],
|
|
||||||
)
|
|
||||||
fname_bitcoincli = os.path.join(
|
|
||||||
config["environment"]["BUILDDIR"],
|
|
||||||
"src",
|
|
||||||
"bitcoin-cli" + config["environment"]["EXEEXT"],
|
|
||||||
)
|
|
||||||
fname_bitcoinutil = os.path.join(
|
|
||||||
config["environment"]["BUILDDIR"],
|
|
||||||
"src",
|
|
||||||
"bitcoin-util" + config["environment"]["EXEEXT"],
|
|
||||||
)
|
|
||||||
self.options.bitcoind = os.getenv("BITCOIND", default=fname_bitcoind)
|
|
||||||
self.options.bitcoincli = os.getenv("BITCOINCLI", default=fname_bitcoincli)
|
|
||||||
self.options.bitcoinutil = os.getenv("BITCOINUTIL", default=fname_bitcoinutil)
|
|
||||||
|
|
||||||
os.environ['PATH'] = os.pathsep.join([
|
os.environ['PATH'] = os.pathsep.join([
|
||||||
os.path.join(config['environment']['BUILDDIR'], 'src'),
|
os.path.join(config['environment']['BUILDDIR'], 'src'),
|
||||||
|
|
Loading…
Add table
Reference in a new issue