Skip to content

Commit b4a509a

Browse files
author
MarcoFalke
committed
Merge #11433: qa: Restore bitcoin-util-test py2 compatibility
fafff12 qa: Restore bitcoin-util-test py2 compatibility (MarcoFalke) Pull request description: Currently `./configure && make check` will look for python3, then python2. As long as we support python2 (and use it as fallback), `make check` should run fine with both python2 and python3. Fixes #11352 by @Zenitur Tree-SHA512: a335ebdd224328d6f924fe52a9b97de196926476c9ee04ce3280743ea93bcae355eb2d5d4bed4050c01b2e904105595eac7db2eaa9307207581caa0a98ebcc0b
2 parents dbc4ae0 + fafff12 commit b4a509a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bitcoin_test_clean : FORCE
149149

150150
check-local:
151151
@echo "Running test/util/bitcoin-util-test.py..."
152-
$(top_builddir)/test/util/bitcoin-util-test.py
152+
$(PYTHON) $(top_builddir)/test/util/bitcoin-util-test.py
153153
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C secp256k1 check
154154
if EMBEDDED_UNIVALUE
155155
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C univalue check

test/util/bitcoin-util-test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
1010
Can also be run manually."""
1111

12+
from __future__ import division,print_function,unicode_literals
13+
1214
import argparse
1315
import binascii
14-
import configparser
16+
try:
17+
import configparser
18+
except ImportError:
19+
import ConfigParser as configparser
1520
import difflib
1621
import json
1722
import logging
@@ -22,7 +27,9 @@
2227

2328
def main():
2429
config = configparser.ConfigParser()
25-
config.read_file(open(os.path.dirname(__file__) + "/../config.ini"))
30+
config.optionxform = str
31+
config.readfp(open(os.path.join(os.path.dirname(__file__), "../config.ini")))
32+
env_conf = dict(config.items('environment'))
2633

2734
parser = argparse.ArgumentParser(description=__doc__)
2835
parser.add_argument('-v', '--verbose', action='store_true')
@@ -37,7 +44,7 @@ def main():
3744
# Add the format/level to the logger
3845
logging.basicConfig(format=formatter, level=level)
3946

40-
bctester(config["environment"]["SRCDIR"] + "/test/util/data", "bitcoin-util-test.json", config["environment"])
47+
bctester(os.path.join(env_conf["SRCDIR"], "test/util/data"), "bitcoin-util-test.json", env_conf)
4148

4249
def bctester(testDir, input_basename, buildenv):
4350
""" Loads and parses the input file, runs all tests and reports results"""

0 commit comments

Comments
 (0)