mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Merge #11858: qa: Prepare tests for Windows
faefd29
qa: Prepare functional tests for Windows (MarcoFalke)
Pull request description:
* Pass `sys.executable` when calling a python script via the subprocess
module
* Don't remove the log file while it is still open and written to
* Properly use os.pathsep and os.path.sep when modifying the PATH
environment variable
* util-tests: Use os.path.join for Windows compatibility
Ref: #8227
Tree-SHA512: c507a536af104b3bde4366b6634099db826532bd3e7c35d694b5883c550920643b3eab79c76703ca67e1044ed09979e855088f7324321c8d52112514e334d614
This commit is contained in:
commit
b4d85490f0
@ -99,7 +99,9 @@ class BitcoinTestFramework():
|
|||||||
|
|
||||||
PortSeed.n = self.options.port_seed
|
PortSeed.n = self.options.port_seed
|
||||||
|
|
||||||
os.environ['PATH'] = self.options.srcdir + ":" + self.options.srcdir + "/qt:" + os.environ['PATH']
|
os.environ['PATH'] = self.options.srcdir + os.pathsep + \
|
||||||
|
self.options.srcdir + os.path.sep + "qt" + os.pathsep + \
|
||||||
|
os.environ['PATH']
|
||||||
|
|
||||||
check_json_precision()
|
check_json_precision()
|
||||||
|
|
||||||
@ -148,10 +150,11 @@ class BitcoinTestFramework():
|
|||||||
self.log.info("Note: bitcoinds were not stopped and may still be running")
|
self.log.info("Note: bitcoinds were not stopped and may still be running")
|
||||||
|
|
||||||
if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED:
|
if not self.options.nocleanup and not self.options.noshutdown and success != TestStatus.FAILED:
|
||||||
self.log.info("Cleaning up")
|
self.log.info("Cleaning up {} on exit".format(self.options.tmpdir))
|
||||||
shutil.rmtree(self.options.tmpdir)
|
cleanup_tree_on_exit = True
|
||||||
else:
|
else:
|
||||||
self.log.warning("Not cleaning up dir %s" % self.options.tmpdir)
|
self.log.warning("Not cleaning up dir %s" % self.options.tmpdir)
|
||||||
|
cleanup_tree_on_exit = False
|
||||||
|
|
||||||
if success == TestStatus.PASSED:
|
if success == TestStatus.PASSED:
|
||||||
self.log.info("Tests successful")
|
self.log.info("Tests successful")
|
||||||
@ -164,6 +167,8 @@ class BitcoinTestFramework():
|
|||||||
self.log.error("Hint: Call {} '{}' to consolidate all logs".format(os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../combine_logs.py"), self.options.tmpdir))
|
self.log.error("Hint: Call {} '{}' to consolidate all logs".format(os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + "/../combine_logs.py"), self.options.tmpdir))
|
||||||
exit_code = TEST_EXIT_FAILED
|
exit_code = TEST_EXIT_FAILED
|
||||||
logging.shutdown()
|
logging.shutdown()
|
||||||
|
if cleanup_tree_on_exit:
|
||||||
|
shutil.rmtree(self.options.tmpdir)
|
||||||
sys.exit(exit_code)
|
sys.exit(exit_code)
|
||||||
|
|
||||||
# Methods to override in subclass test scripts.
|
# Methods to override in subclass test scripts.
|
||||||
|
@ -268,7 +268,7 @@ def main():
|
|||||||
if args.help:
|
if args.help:
|
||||||
# Print help for test_runner.py, then print help of the first script (with args removed) and exit.
|
# Print help for test_runner.py, then print help of the first script (with args removed) and exit.
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
subprocess.check_call([(config["environment"]["SRCDIR"] + '/test/functional/' + test_list[0].split()[0])] + ['-h'])
|
subprocess.check_call([sys.executable, os.path.join(config["environment"]["SRCDIR"], 'test', 'functional', test_list[0].split()[0]), '-h'])
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
check_script_list(config["environment"]["SRCDIR"])
|
check_script_list(config["environment"]["SRCDIR"])
|
||||||
@ -312,7 +312,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_cove
|
|||||||
if len(test_list) > 1 and jobs > 1:
|
if len(test_list) > 1 and jobs > 1:
|
||||||
# Populate cache
|
# Populate cache
|
||||||
try:
|
try:
|
||||||
subprocess.check_output([tests_dir + 'create_cache.py'] + flags + ["--tmpdir=%s/cache" % tmpdir])
|
subprocess.check_output([sys.executable, tests_dir + 'create_cache.py'] + flags + ["--tmpdir=%s/cache" % tmpdir])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
sys.stdout.buffer.write(e.output)
|
sys.stdout.buffer.write(e.output)
|
||||||
raise
|
raise
|
||||||
@ -342,7 +342,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, tmpdir, jobs=1, enable_cove
|
|||||||
print('\n============')
|
print('\n============')
|
||||||
print('{}Combined log for {}:{}'.format(BOLD[1], testdir, BOLD[0]))
|
print('{}Combined log for {}:{}'.format(BOLD[1], testdir, BOLD[0]))
|
||||||
print('============\n')
|
print('============\n')
|
||||||
combined_logs, _ = subprocess.Popen([os.path.join(tests_dir, 'combine_logs.py'), '-c', testdir], universal_newlines=True, stdout=subprocess.PIPE).communicate()
|
combined_logs, _ = subprocess.Popen([sys.executble, os.path.join(tests_dir, 'combine_logs.py'), '-c', testdir], universal_newlines=True, stdout=subprocess.PIPE).communicate()
|
||||||
print("\n".join(deque(combined_logs.splitlines(), combined_logs_len)))
|
print("\n".join(deque(combined_logs.splitlines(), combined_logs_len)))
|
||||||
|
|
||||||
print_results(test_results, max_len_name, (int(time.time() - time0)))
|
print_results(test_results, max_len_name, (int(time.time() - time0)))
|
||||||
@ -412,7 +412,7 @@ class TestHandler:
|
|||||||
tmpdir_arg = ["--tmpdir={}".format(testdir)]
|
tmpdir_arg = ["--tmpdir={}".format(testdir)]
|
||||||
self.jobs.append((t,
|
self.jobs.append((t,
|
||||||
time.time(),
|
time.time(),
|
||||||
subprocess.Popen([self.tests_dir + test_argv[0]] + test_argv[1:] + self.flags + portseed_arg + tmpdir_arg,
|
subprocess.Popen([sys.executable, self.tests_dir + test_argv[0]] + test_argv[1:] + self.flags + portseed_arg + tmpdir_arg,
|
||||||
universal_newlines=True,
|
universal_newlines=True,
|
||||||
stdout=log_stdout,
|
stdout=log_stdout,
|
||||||
stderr=log_stderr),
|
stderr=log_stderr),
|
||||||
|
@ -44,7 +44,7 @@ def main():
|
|||||||
# Add the format/level to the logger
|
# Add the format/level to the logger
|
||||||
logging.basicConfig(format=formatter, level=level)
|
logging.basicConfig(format=formatter, level=level)
|
||||||
|
|
||||||
bctester(os.path.join(env_conf["SRCDIR"], "test/util/data"), "bitcoin-util-test.json", env_conf)
|
bctester(os.path.join(env_conf["SRCDIR"], "test", "util", "data"), "bitcoin-util-test.json", env_conf)
|
||||||
|
|
||||||
def bctester(testDir, input_basename, buildenv):
|
def bctester(testDir, input_basename, buildenv):
|
||||||
""" Loads and parses the input file, runs all tests and reports results"""
|
""" Loads and parses the input file, runs all tests and reports results"""
|
||||||
|
Loading…
Reference in New Issue
Block a user