From 89fcd3586c9714a923b6a3147f60e43d5de74942 Mon Sep 17 00:00:00 2001 From: John Newbery Date: Tue, 21 Mar 2017 14:38:09 -0400 Subject: [PATCH] Use an .ini config file for environment vars in bitcoin-util-test.py --- .gitignore | 2 -- Makefile.am | 3 --- configure.ac | 3 +-- test/util/bitcoin-util-test.py | 9 ++++++++- test/util/buildenv.py.in | 4 ---- test/util/config.ini.in | 11 +++++++++++ 6 files changed, 20 insertions(+), 12 deletions(-) delete mode 100644 test/util/buildenv.py.in create mode 100644 test/util/config.ini.in diff --git a/.gitignore b/.gitignore index f1e9ca20c..aa37e381e 100644 --- a/.gitignore +++ b/.gitignore @@ -80,7 +80,6 @@ Bitcoin-Qt.app # Unit-tests Makefile.test bitcoin-qt_test -src/test/buildenv.py # Resources cpp qrc_*.cpp @@ -102,7 +101,6 @@ linux-coverage-build linux-build win32-build test/functional/config.ini -test/util/buildenv.py test/cache/* !src/leveldb*/Makefile diff --git a/Makefile.am b/Makefile.am index 3a56eea0c..b0ba0c850 100644 --- a/Makefile.am +++ b/Makefile.am @@ -277,9 +277,6 @@ EXTRA_DIST += \ CLEANFILES = $(OSX_DMG) $(BITCOIN_WIN_INSTALLER) -# This file is problematic for out-of-tree builds if it exists. -DISTCLEANFILES = test/util/buildenv.pyc - .INTERMEDIATE: $(COVERAGE_INFO) DISTCHECK_CONFIGURE_FLAGS = --enable-man diff --git a/configure.ac b/configure.ac index 367270048..26a9d082c 100644 --- a/configure.ac +++ b/configure.ac @@ -1160,8 +1160,7 @@ AC_SUBST(EVENT_PTHREADS_LIBS) AC_SUBST(ZMQ_LIBS) AC_SUBST(PROTOBUF_LIBS) AC_SUBST(QR_LIBS) -AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/functional/config.ini]) -AC_CONFIG_FILES([test/util/buildenv.py],[chmod +x test/util/buildenv.py]) +AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile share/setup.nsi share/qt/Info.plist test/functional/config.ini test/util/config.ini]) AC_CONFIG_FILES([contrib/devtools/split-debug.sh],[chmod +x contrib/devtools/split-debug.sh]) AC_CONFIG_FILES([doc/Doxyfile]) AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py]) diff --git a/test/util/bitcoin-util-test.py b/test/util/bitcoin-util-test.py index 0c67663ed..f85bd13f9 100755 --- a/test/util/bitcoin-util-test.py +++ b/test/util/bitcoin-util-test.py @@ -9,6 +9,7 @@ Runs automatically during `make check`. Can also be run manually.""" +import configparser import os import sys import argparse @@ -16,9 +17,15 @@ import logging if __name__ == '__main__': sys.path.append(os.path.dirname(os.path.abspath(__file__))) - import buildenv import bctest + config = configparser.ConfigParser() + config.read_file(open(os.path.dirname(__file__) + "/config.ini")) + + buildenv = argparse.Namespace(exeext=config["environment"]["EXEEXT"], + SRCDIR=config["environment"]["SRCDIR"], + BUILDDIR=config["environment"]["BUILDDIR"]) + parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('-v', '--verbose', action='store_true') args = parser.parse_args() diff --git a/test/util/buildenv.py.in b/test/util/buildenv.py.in deleted file mode 100644 index 33030b034..000000000 --- a/test/util/buildenv.py.in +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -exeext="@EXEEXT@" -SRCDIR="@abs_top_srcdir@" -BUILDDIR="@abs_top_builddir@" diff --git a/test/util/config.ini.in b/test/util/config.ini.in new file mode 100644 index 000000000..a1f8f09ce --- /dev/null +++ b/test/util/config.ini.in @@ -0,0 +1,11 @@ +# Copyright (c) 2013-2017 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# These environment variables are set by the build process and read by +# test/util/bitcoin-util-test.py + +[environment] +SRCDIR=@abs_top_srcdir@ +BUILDDIR=@abs_top_builddir@ +EXEEXT=@EXEEXT@