test-fixtures: return error set, don't throw exception

Throwing an exception while killing all nodes meant that
we aren't cleaning up all the nodes properly. Instead,
collect the errors, and return them back to the upper level,
where we report them and terminate as expected.
This commit is contained in:
lisa neigut
2019-09-04 12:11:51 -05:00
committed by Rusty Russell
parent 63c80e7aa9
commit df1d92a7a2
2 changed files with 7 additions and 5 deletions

View File

@@ -967,6 +967,7 @@ class NodeFactory(object):
def killall(self, expected_successes):
"""Returns true if every node we expected to succeed actually succeeded"""
unexpected_fail = False
err_msgs = []
for i in range(len(self.nodes)):
leaks = None
# leak detection upsets VALGRIND by reading uninitialized mem.
@@ -985,9 +986,10 @@ class NodeFactory(object):
unexpected_fail = True
if leaks is not None and len(leaks) != 0:
raise Exception("Node {} has memory leaks: {}".format(
unexpected_fail = True
err_msgs.append("Node {} has memory leaks: {}".format(
self.nodes[i].daemon.lightning_dir,
json.dumps(leaks, sort_keys=True, indent=4)
))
return not unexpected_fail
return not unexpected_fail, err_msgs