def testStart(self, sName, sCaller): """ Starts a new test, may be nested. """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp(); self._xmlWrite([ '<Test timestamp="%s" name="%s">' % (sTsIso, self._xmlEscAttr(sName),), ]); self.atTests.append((sName, self.cErrors, self.fTimedOut)); self.fTimedOut = False; return self.log(1, '%-50s: TESTING' % (self._testGetFullName()), sCaller, sTsPrf);
def testValue(self, sName, sValue, sUnit, sCaller): """ Reports a benchmark value or something simiarlly useful. """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp() self._xmlWrite([ '<Value timestamp="%s" name="%s" unit="%s" value="%s"/>' % (sTsIso, self._xmlEscAttr(sName), self._xmlEscAttr(sUnit), self._xmlEscAttr(sValue)), ]) return self.log(0, ' %-48s: %12s %s' % (sName, sValue, sUnit), sCaller, sTsPrf)
def testFailure(self, sDetails, sCaller): """ Reports a failure. """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp() self.cErrors = self.cErrors + 1 self._xmlWrite([ '<FailureDetails timestamp="%s" text="%s"/>' % ( sTsIso, self._xmlEscAttr(sDetails), ), ]) return self.log(0, sDetails, sCaller, sTsPrf)
def testStart(self, sName, sCaller): """ Starts a new test, may be nested. """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp() self._xmlWrite([ '<Test timestamp="%s" name="%s">' % ( sTsIso, self._xmlEscAttr(sName), ), ]) self.atTests.append((sName, self.cErrors, self.fTimedOut)) self.fTimedOut = False return self.log(1, '%-50s: TESTING' % (self._testGetFullName()), sCaller, sTsPrf)
def testDone(self, fSkipped, sCaller): """ Marks the current test as DONE, pops it and maks the next test on the stack current. Returns (name, errors). """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp() sFullName = self._testGetFullName() # safe pop if len(self.atTests) <= 0: self.log(0, 'testDone on empty test stack!', sCaller, sTsPrf) return ('internal error', 0) fTimedOut = self.fTimedOut sName, cErrorsStart, self.fTimedOut = self.atTests.pop() # log + xml. cErrors = self.cErrors - cErrorsStart if cErrors == 0: if fSkipped is not True: self._xmlWrite( [' <Passed timestamp="%s"/>' % (sTsIso, ), '</Test>'], ) self.log(1, '** %-50s: PASSED' % (sFullName, ), sCaller, sTsPrf) else: self._xmlWrite( [' <Skipped timestamp="%s"/>' % (sTsIso, ), '</Test>']) self.log(1, '** %-50s: SKIPPED' % (sFullName, ), sCaller, sTsPrf) elif fTimedOut: self._xmlWrite([ ' <TimedOut timestamp="%s" errors="%d"/>' % (sTsIso, cErrors), '</Test>' ]) self.log(0, '** %-50s: TIMED-OUT - %d errors' % (sFullName, cErrors), sCaller, sTsPrf) else: self._xmlWrite([ ' <Failed timestamp="%s" errors="%d"/>' % (sTsIso, cErrors), '</Test>' ]) self.log(0, '** %-50s: FAILED - %d errors' % (sFullName, cErrors), sCaller, sTsPrf) # Flush buffers when reaching the last test. if len(self.atTests) == 0: self.xmlFlush(fRetry=True) return (sName, cErrors)
def testDone(self, fSkipped, sCaller): """ Marks the current test as DONE, pops it and maks the next test on the stack current. Returns (name, errors). """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp(); sFullName = self._testGetFullName(); # safe pop if len(self.atTests) <= 0: self.log(0, 'testDone on empty test stack!', sCaller, sTsPrf); return ('internal error', 0); fTimedOut = self.fTimedOut; sName, cErrorsStart, self.fTimedOut = self.atTests.pop(); # log + xml. cErrors = self.cErrors - cErrorsStart; if cErrors == 0: if fSkipped is not True: self._xmlWrite([ ' <Passed timestamp="%s"/>' % (sTsIso,), '</Test>' ],); self.log(1, '%-50s: PASSED' % (sFullName,), sCaller, sTsPrf); else: self._xmlWrite([ ' <Skipped timestamp="%s"/>' % (sTsIso,), '</Test>' ]); self.log(1, '%-50s: SKIPPED' % (sFullName,), sCaller, sTsPrf); elif fTimedOut: self._xmlWrite([ ' <TimedOut timestamp="%s" errors="%d"/>' % (sTsIso, cErrors), '</Test>' ]); self.log(0, '%-50s: TIMED-OUT - %d errors' % (sFullName, cErrors), sCaller, sTsPrf); else: self._xmlWrite([ ' <Failed timestamp="%s" errors="%d"/>' % (sTsIso, cErrors), '</Test>' ]); self.log(0, '%-50s: FAILED - %d errors' % (sFullName, cErrors), sCaller, sTsPrf); # Flush buffers when reaching the last test. if len(self.atTests) == 0: self.xmlFlush(fRetry = True); return (sName, cErrors);
def testFailure(self, sDetails, sCaller): """ Reports a failure. """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp(); self.cErrors = self.cErrors + 1; self._xmlWrite([ '<FailureDetails timestamp="%s" text="%s"/>' % (sTsIso, self._xmlEscAttr(sDetails),), ]); return self.log(0, sDetails, sCaller, sTsPrf);
def testValue(self, sName, sValue, sUnit, sCaller): """ Reports a benchmark value or something simiarlly useful. """ (sTsPrf, sTsIso) = utils.getTimePrefixAndIsoTimestamp(); self._xmlWrite([ '<Value timestamp="%s" name="%s" unit="%s" value="%s"/>' % (sTsIso, self._xmlEscAttr(sName), self._xmlEscAttr(sUnit), self._xmlEscAttr(sValue)), ]); return self.log(0, ' %-48s: %12s %s' % (sName, sValue, sUnit), sCaller, sTsPrf);