1   
  2   
  3   
  4   
  5   
  6   
  7   
  8   
  9   
 10   
 11   
 12   
 13   
 14   
 15   
 16   
 17  from unittest import TestResult 
 18  from StringIO import StringIO 
 19   
 20  from buildbot.process import buildstep 
 21  from buildbot.status.testresult import TestResult as aTestResult 
 22  from buildbot.status.results import SUCCESS, FAILURE, SKIPPED 
 23   
 25      """Observe a log that may contain subunit output. 
 26   
 27      This class extends TestResult to receive the callbacks from the subunit 
 28      parser in the most direct fashion. 
 29      """ 
 30   
 32          buildstep.LogLineObserver.__init__(self) 
 33          TestResult.__init__(self) 
 34          try: 
 35              from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET 
 36              from subunit import PROGRESS_PUSH, PROGRESS_POP 
 37          except ImportError: 
 38              raise ImportError("subunit is not importable, but is required for " 
 39                  "SubunitLogObserver support.") 
 40          self.PROGRESS_CUR = PROGRESS_CUR 
 41          self.PROGRESS_SET = PROGRESS_SET 
 42          self.PROGRESS_PUSH = PROGRESS_PUSH 
 43          self.PROGRESS_POP = PROGRESS_POP 
 44          self.warningio = StringIO() 
 45          self.protocol = TestProtocolServer(self, self.warningio) 
 46          self.skips = [] 
 47          self.seen_tags = set()  
  48   
 50          """Process a received stdout line.""" 
 51           
 52          self.protocol.lineReceived(line + '\n') 
  53   
 55          """same for stderr line.""" 
 56          self.protocol.lineReceived(line + '\n') 
  57   
 61   
 65   
 72   
 76   
 80   
 84   
 85 -    def issue(self, test, err): 
  86          """An issue - failing, erroring etc test.""" 
 87          self.addAResult(test, FAILURE, 'FAILURE', err) 
 88          self.step.setProgress('tests failed', len(self.failures) +  
 89              len(self.errors)) 
  90   
 91      expectedTests = 0 
 92      contextLevel = 0 
105   
 109   
110   
111  import buildbot.steps.subunit 
112  SubunitShellCommand = buildbot.steps.subunit.SubunitShellCommand 
113