示例#1
0
    def processResult(self, testObj, cycle=-1, **kwargs):
        outcome = testObj.getOutcome()
        if outcome.isFailure():
            category = 'error'
        elif str(outcome) in self.includeNonFailureOutcomes:
            category = 'warning'
        else:
            return

        loc = testObj.getOutcomeLocation(
        )  # typically (pysystest.py,linenumber)
        if not loc[
                0]:  # fallback for if there was no location e.g. because it wasn't a failure
            loc = (os.path.normpath(
                os.path.join(testObj.descriptor.testDir,
                             testObj.descriptor._getTestFile())), 0
                   )  # this is a reasonable fallback
        stdoutPrint(self.format\
         .replace('@testFile@', self.escape(loc[0]))
         .replace('@testFile/@', self.escape((loc[0]).replace(os.sep,'/')))
         .replace('@testFileLine@', loc[1] or '0')
         .replace('@runLogFile@', self.escape(testObj.output+'/run.log'))
         .replace('@runLogFile/@', self.escape((testObj.output+'/run.log').replace(os.sep,'/')))
         .replace('@category@', category)
         .replace('@outcome@', str(testObj.getOutcome()))
         .replace('@outcomeReason@', self.escape(testObj.getOutcomeReason() or '(no outcome reason)'))
         .replace('@testIdAndCycle@', self.escape(testObj.descriptor.id+(' [CYCLE %02d]'%(cycle+1) if self.cycles>1 else '')))
         .replace('@json@', json.dumps(self.__jsonWriter.createTestResultDict(testObj, **kwargs)) if '@json@' in self.format else '@json@')
         )
示例#2
0
 def processResult(self,
                   testObj,
                   cycle=0,
                   testTime=0,
                   testStart=0,
                   runLogOutput=u'',
                   **kwargs):
     sys.stdout.write('sys.stdout.write-CUSTOMWRITER-processResult\n')
     stdoutPrint(b'stdoutPrint-CUSTOMWRITER-processResult')
示例#3
0
 def setup(self,
           numTests=0,
           cycles=1,
           xargs=None,
           threads=0,
           testoutdir=u'',
           runner=None,
           **kwargs):
     sys.stdout.write('sys.stdout.write-CUSTOMWRITER-setup\n')
     stdoutPrint('stdoutPrint-CUSTOMWRITER-setup')
示例#4
0
	def setup(self, numTests=0, cycles=1, xargs=None, threads=0, testoutdir=u'', runner=None, **kwargs):
		self.runid = os.path.basename(testoutdir)
		
		if runner.printLogs is None:
			# if setting was not overridden by user, default for Travis is 
			# to only print failures since otherwise the output is too long 
			# and hard to find the logs of interest
			runner.printLogs = PrintLogs.FAILURES
		
		stdoutPrint(u'travis_fold:start:PySys-%s'%self.runid.replace(' ', '-'))
		
		# enable coloring automatically, since this CI provider supports it, 
		# but must explicitly disable bright colors since it doesn't yet support that
		runner.project.formatters.stdout.color = True
		ColorLogFormatter.configureANSIEscapeCodes(bright=False)
示例#5
0
    def cleanup(self):
        try:
            thisRun = CSVPerformanceFile('\n'.join(
                self.__recordedPerformanceLines))
            thisRun.label = 'this'
            # maybe compare to previous runs - just textual
            comp = os.getenv('PYSYS_PERFORMANCE_BASELINES', '')
            if comp and thisRun.results:
                comp = comp.split(',')
                for l in comparePerformanceFiles(
                        comp + [thisRun],
                        sortby='comparison%').strip().split('\n'):
                    stdoutPrint(
                        l)  # need to keep separate for coloring to work

        finally:
            super(XpybuildPerfReporter, self).cleanup()
示例#6
0
    def outputGitHubCommand(self, cmd, value=u'', params={}):
        # syntax is: ::workflow-command parameter1={data},parameter2={data}::{command value}
        # escaping based on https://github.com/actions/toolkit/blob/master/packages/core/src/command.ts

        toprint = u'::%s%s::%s'%(cmd,
         (u' '+u','.join(u'%s=%s'%(k,v\
          .replace('%', '%25')\
          .replace('\r', '%0D')\
          .replace('\n', '%0A')\
          .replace(':', '%3A')\
          .replace(',', '%2C')
          ) for k,v in params.items())) if params else u'', value\
          .replace('%', '%25')\
          .replace('\r', '%0D')\
          .replace('\n', '%0A')
          )
        if cmd in [
                u'set-output'
        ]:  # since GitHub suppresses the actual commands written, it's useful to log this at debug
            log.debug('GitHub Actions command %s', toprint)

        stdoutPrint(toprint)
示例#7
0
    def processResult(self, testObj, cycle=-1, **kwargs):
        outcome = testObj.getOutcome()
        if outcome.isFailure():
            category = 'error'
        elif str(outcome) in self.includeNonFailureOutcomes:
            category = 'warning'
        else:
            return

        loc = testObj.getOutcomeLocation()
        if not loc[0]:
            loc = (os.path.normpath(testObj.output + '/run.log'), 0
                   )  # this is a reasonable fallback
        stdoutPrint(self.format\
         .replace('@testFile@', self.escape(loc[0]))
         .replace('@testFile/@', self.escape((loc[0]).replace(os.sep,'/')))
         .replace('@testFileLine@', loc[1] or '0')
         .replace('@runLogFile@', self.escape(testObj.output+'/run.log'))
         .replace('@runLogFile/@', self.escape((testObj.output+'/run.log').replace(os.sep,'/')))
         .replace('@category@', category)
         .replace('@outcome@', str(testObj.getOutcome()))
         .replace('@outcomeReason@', self.escape(testObj.getOutcomeReason() or '(no outcome reason)'))
         .replace('@testIdAndCycle@', self.escape(testObj.descriptor.id+(' [CYCLE %02d]'%(cycle+1) if self.cycles>1 else '')))
         )
示例#8
0
	def cleanup(self, **kwargs):
		# invoked after all tests but before summary is printed, 
		# a good place to close the folding detail section
		stdoutPrint(u'travis_fold:end:PySys-%s'%self.runid.replace(' ', '-'))
示例#9
0
 def cleanup(self, **kwargs):
     sys.stdout.write('sys.stdout.write-CUSTOMWRITER-cleanup\n')
     stdoutPrint(u'stdoutPrint-CUSTOMWRITER-cleanup')
示例#10
0
	def outputGitHubCommand(self, cmd, value=u'', params={}):
		# syntax is: ::workflow-command parameter1={data},parameter2={data}::{command value}
		stdoutPrint(u'::%s%s::%s'%(cmd, (u' '+u','.join(u'%s=%s'%(k,v) for k,v in params.items())).replace('::', '__') if params else u'', value.replace('%', '%25').replace('\n', '%0A')))