mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-14 06:50:56 +02:00
qa: Fix dormant bug caused by multiple --tmpdir
We would only modify the parent process' first --tmpdir arg. Now we tack on an additional --tmpdir after the parent's arguments. Also simplifies the code. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -36,15 +36,11 @@ class FeatureFrameworkStartupFailures(BitcoinTestFramework):
|
|||||||
# Launches a child test process that runs this same file, but instantiates
|
# Launches a child test process that runs this same file, but instantiates
|
||||||
# a child test. Verifies that it raises only the expected exception, once.
|
# a child test. Verifies that it raises only the expected exception, once.
|
||||||
def _verify_startup_failure(self, test, internal_args, expected_exception):
|
def _verify_startup_failure(self, test, internal_args, expected_exception):
|
||||||
# Inherit args from parent, only modifying tmpdir so children don't fail
|
# Inherit sys.argv from parent, only overriding tmpdir to a subdirectory
|
||||||
# as a cause of colliding with the parent dir.
|
# so children don't fail due to colliding with the parent dir.
|
||||||
parent_args = sys.argv.copy()
|
|
||||||
assert self.options.tmpdir, "Framework should always set tmpdir."
|
assert self.options.tmpdir, "Framework should always set tmpdir."
|
||||||
i, path = next(((i, m[1]) for i, arg in enumerate(parent_args) if (m := re.match(r'--tm(?:p(?:d(?:ir?)?)?)?=(.+)', arg))),
|
|
||||||
(len(parent_args), self.options.tmpdir))
|
|
||||||
subdir = md5(expected_exception.encode('utf-8')).hexdigest()[:8]
|
subdir = md5(expected_exception.encode('utf-8')).hexdigest()[:8]
|
||||||
parent_args[i:i + 1] = [f"--tmpdir={path}/{subdir}"]
|
args = [sys.executable] + sys.argv + [f"--tmpdir={self.options.tmpdir}/{subdir}", f"--internal_test={test.__name__}"] + internal_args
|
||||||
args = [sys.executable] + parent_args + [f"--internal_test={test.__name__}"] + internal_args
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# The subprocess encoding argument gives different results for e.output
|
# The subprocess encoding argument gives different results for e.output
|
||||||
|
Reference in New Issue
Block a user