@@ -36,22 +36,24 @@ def setup_network(self):
3636 # Launches a child test process that runs this same file, but instantiates
3737 # a child test. Verifies that it raises only the expected exception, once.
3838 def _verify_startup_failure (self , test , internal_args , expected_exception ):
39+ name = test .__name__
40+ def format_child_output (output ):
41+ return f"\n <{ name } OUTPUT BEGIN>\n { output .strip ()} \n <{ name } OUTPUT END>\n "
42+
3943 # Inherit sys.argv from parent, only overriding tmpdir to a subdirectory
4044 # so children don't fail due to colliding with the parent dir.
4145 assert self .options .tmpdir , "Framework should always set tmpdir."
4246 subdir = md5 (expected_exception .encode ('utf-8' )).hexdigest ()[:8 ]
43- args = [sys .executable ] + sys .argv + [f"--tmpdir={ self .options .tmpdir } /{ subdir } " , f"--internal_test={ test . __name__ } " ] + internal_args
47+ args = [sys .executable ] + sys .argv + [f"--tmpdir={ self .options .tmpdir } /{ subdir } " , f"--internal_test={ name } " ] + internal_args
4448
4549 try :
4650 output = subprocess .run (args , timeout = 60 * self .options .timeout_factor ,
4751 stdout = subprocess .PIPE , stderr = subprocess .STDOUT , text = True ).stdout
4852 except subprocess .TimeoutExpired as e :
49- print ("Unexpected child process timeout!\n "
50- "WARNING: Timeouts like this halt execution of TestNode logic, "
51- "meaning dangling bitcoind processes are to be expected.\n "
52- f"<CHILD OUTPUT BEGIN>\n { e .output .decode ("utf-8" )} \n <CHILD OUTPUT END>" ,
53- file = sys .stderr )
54- raise
53+ sys .exit ("Unexpected child process timeout!\n "
54+ "WARNING: Timeouts like this halt execution of TestNode logic, "
55+ "meaning dangling bitcoind processes are to be expected.\n " +
56+ (format_child_output (e .output .decode ("utf-8" )) if e .output else "<EMPTY OUTPUT>" ))
5557
5658 errors = []
5759 if (n := output .count ("Traceback" )) != 1 :
@@ -61,13 +63,17 @@ def _verify_startup_failure(self, test, internal_args, expected_exception):
6163 if (n := output .count ("Test failed. Test logging available at" )) != 1 :
6264 errors .append (f"Found { n } /1 test failure output messages." )
6365
64- assert not errors , f"Child test didn't contain (only) expected errors:\n { linesep .join (errors )} \n <CHILD OUTPUT BEGIN>\n { output } \n <CHILD OUTPUT END>\n "
66+ assert not errors , (f"Child test did NOT contain (only) expected errors:\n { linesep .join (errors )} \n " +
67+ format_child_output (output ))
68+
69+ self .log .debug ("Child test did contain (only) expected errors:\n " +
70+ format_child_output (output ))
6571
6672 def run_test (self ):
6773 self .log .info ("Verifying _verify_startup_failure() functionality (self-check)." )
6874 assert_raises_message (
6975 AssertionError ,
70- ( "Child test didn't contain (only) expected errors:\n "
76+ ( "Child test did NOT contain (only) expected errors:\n "
7177 f"Found 0/1 tracebacks - expecting exactly one with no knock-on exceptions.{ linesep } "
7278 f"Found 0/1 occurrences of the specific exception: NonExistentError{ linesep } "
7379 "Found 0/1 test failure output messages." ),
0 commit comments