Skip to content

Commit

Permalink
Storing off last 10 cout and cerr results from calling checkOutput to…
Browse files Browse the repository at this point in the history
… report on failure. GH EOSIO#5199
  • Loading branch information
brianjohnson5972 committed Sep 5, 2018
1 parent 9b7ae36 commit 9da6f27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/TestHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ def shutdown(cluster, walletMgr, testSuccessful=True, killEosInstances=True, kil
if walletMgr:
walletMgr.dumpErrorDetails()
Utils.Print("== Errors see above ==")
if len(Utils.CheckOutputDeque)>0:
Utils.Print("== cout/cerr pairs from last %d calls to Utils. ==" % len(Utils.CheckOutputDeque))
for out, err in Utils.CheckOutputDeque:
Utils.Print("cout={%s}" % (out))
Utils.Print("cerr={%s}\n" % (out))
Utils.Print("== cout/cerr pairs done. ==")

if killEosInstances:
Utils.Print("Shut down the cluster.")
Expand Down
3 changes: 3 additions & 0 deletions tests/testUtils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import subprocess
import time
import os
from collections import deque
from collections import namedtuple
import inspect
import json
Expand All @@ -24,6 +25,7 @@ class Utils:
EosLauncherPath="programs/eosio-launcher/eosio-launcher"
MongoPath="mongo"
ShuttingDown=False
CheckOutputDeque=deque(maxlen=10)

@staticmethod
def Print(*args, **kwargs):
Expand Down Expand Up @@ -76,6 +78,7 @@ def checkOutput(cmd):
assert(isinstance(cmd, list))
popen=subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(output,error)=popen.communicate()
Utils.CheckOutputDeque.append((output,error))
if popen.returncode != 0:
raise subprocess.CalledProcessError(returncode=popen.returncode, cmd=cmd, output=error)
return output.decode("utf-8")
Expand Down

0 comments on commit 9da6f27

Please sign in to comment.