mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-23 09:04:22 +01:00
pyln-testing: save stderr logs for checking
just for convenience's sake
This commit is contained in:
committed by
Rusty Russell
parent
d2688bbaf5
commit
0cf3e19e0b
@@ -140,6 +140,7 @@ class TailableProc(object):
|
|||||||
self.proc = None
|
self.proc = None
|
||||||
self.outputDir = outputDir
|
self.outputDir = outputDir
|
||||||
self.logsearch_start = 0
|
self.logsearch_start = 0
|
||||||
|
self.err_logs = []
|
||||||
|
|
||||||
# Should we be logging lines we read from stdout?
|
# Should we be logging lines we read from stdout?
|
||||||
self.verbose = verbose
|
self.verbose = verbose
|
||||||
@@ -210,6 +211,10 @@ class TailableProc(object):
|
|||||||
self.running = False
|
self.running = False
|
||||||
self.proc.stdout.close()
|
self.proc.stdout.close()
|
||||||
if self.proc.stderr:
|
if self.proc.stderr:
|
||||||
|
for line in iter(self.proc.stderr.readline, ''):
|
||||||
|
if len(line) == 0:
|
||||||
|
break
|
||||||
|
self.err_logs.append(line.rstrip().decode('ASCII'))
|
||||||
self.proc.stderr.close()
|
self.proc.stderr.close()
|
||||||
|
|
||||||
def is_in_log(self, regex, start=0):
|
def is_in_log(self, regex, start=0):
|
||||||
@@ -224,6 +229,18 @@ class TailableProc(object):
|
|||||||
logging.debug("Did not find '%s' in logs", regex)
|
logging.debug("Did not find '%s' in logs", regex)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def is_in_stderr(self, regex):
|
||||||
|
"""Look for `regex` in stderr."""
|
||||||
|
|
||||||
|
ex = re.compile(regex)
|
||||||
|
for l in self.err_logs:
|
||||||
|
if ex.search(l):
|
||||||
|
logging.debug("Found '%s' in stderr", regex)
|
||||||
|
return l
|
||||||
|
|
||||||
|
logging.debug("Did not find '%s' in stderr", regex)
|
||||||
|
return None
|
||||||
|
|
||||||
def wait_for_logs(self, regexs, timeout=TIMEOUT):
|
def wait_for_logs(self, regexs, timeout=TIMEOUT):
|
||||||
"""Look for `regexs` in the logs.
|
"""Look for `regexs` in the logs.
|
||||||
|
|
||||||
@@ -637,8 +654,8 @@ class LightningNode(object):
|
|||||||
info = self.rpc.getinfo()
|
info = self.rpc.getinfo()
|
||||||
return 'warning_bitcoind_sync' not in info and 'warning_lightningd_sync' not in info
|
return 'warning_bitcoind_sync' not in info and 'warning_lightningd_sync' not in info
|
||||||
|
|
||||||
def start(self, wait_for_bitcoind_sync=True):
|
def start(self, wait_for_bitcoind_sync=True, stderr=None):
|
||||||
self.daemon.start()
|
self.daemon.start(stderr=stderr)
|
||||||
# Cache `getinfo`, we'll be using it a lot
|
# Cache `getinfo`, we'll be using it a lot
|
||||||
self.info = self.rpc.getinfo()
|
self.info = self.rpc.getinfo()
|
||||||
# This shortcut is sufficient for our simple tests.
|
# This shortcut is sufficient for our simple tests.
|
||||||
|
|||||||
Reference in New Issue
Block a user