コード例 #1
0
    def _getFreeTextBody(self):
        if self.binaryFile and \
               (self.newResult() or self.missingResult()):
            message = "Binary file, not showing any preview. " + \
                      "Edit the configuration entry 'binary_file' and re-run if you suspect that this file contains only text.\n"
            return self.previewGenerator.getWrappedLine(message)
        elif self.newResult():
            return self.previewGenerator.getPreview(open(self.tmpCmpFile))
        elif self.missingResult():
            return self.previewGenerator.getPreview(open(self.stdCmpFile))

        try:
            stdFileSize = os.path.getsize(self.stdCmpFile)
            tmpFileSize = os.path.getsize(self.tmpCmpFile)
            if self.textDiffToolMaxSize >= 0 and \
                   (stdFileSize > self.textDiffToolMaxSize or \
                    tmpFileSize > self.textDiffToolMaxSize):
                message = "The result files were too large to compare - " + str(stdFileSize) + " and " + \
                          str(tmpFileSize) + " bytes, compared to the limit of " + str(self.textDiffToolMaxSize) + \
                          " bytes. Adjust the configuration entry 'max_file_size' for the tool '" + self.textDiffTool + \
                          "' and re-run to see the difference in this text view.\n"
                return self.previewGenerator.getWrappedLine(message)

            cmdArgs = plugins.splitcmd(self.textDiffTool) + [ self.stdCmpFile, self.tmpCmpFile ]
            proc = subprocess.Popen(cmdArgs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
            return self.previewGenerator.getPreview(proc.stdout)
        except OSError, e:
            self.diag.info("No diff report: full exception printout\n" + plugins.getExceptionString())
            return "No difference report could be created: could not find textual difference tool '" + self.textDiffTool + "'\n" + \
                   "(" + str(e) + ")"
コード例 #2
0
ファイル: fileviewers.py プロジェクト: haddyclipk/ICS
 def processFile(self, file, properties, errors):
     if file:
         try:
             prop = plugins.FileProperties(file)
             properties.append(prop)
         except Exception, e:
             errors.append(plugins.getExceptionString())
コード例 #3
0
        self.setActionSequence(self.appRunner.actionSequence)

    def setActionSequence(self, actionSequence):
        self.actionSequence = []
        # Copy the action sequence, so we can edit it and mark progress
        for action in actionSequence:
            self.actionSequence.append(action)

    def handleExceptions(self, method, *args):
        try:
            method(*args)
            return True
        except plugins.TextTestError, e:
            self.failTest(str(e))
        except:
            exceptionText = plugins.getExceptionString()
            plugins.printWarning("Caught exception while running " + repr(self.test) +
                                 " changing state to UNRUNNABLE :\n" + exceptionText.rstrip(), stdout=True)
            self.failTest(exceptionText)
        return False
    
    def failTest(self, excString):
        execHosts = self.test.state.executionHosts
        failState = plugins.Unrunnable(freeText=excString, briefText="TEXTTEST EXCEPTION", executionHosts=execHosts)
        self.test.changeState(failState)

    def performActions(self, previousTestRunner):
        tearDownSuites, setUpSuites = self.findSuitesToChange(previousTestRunner)
        for suite in tearDownSuites:
            self.handleExceptions(previousTestRunner.appRunner.tearDownSuite, suite)
        for suite in setUpSuites:
コード例 #4
0
 def _getIntvActionConfig(self, module):
     try:
         exec "from " + module + " import InteractiveActionConfig"
         return InteractiveActionConfig() #@UndefinedVariable
     except ImportError:
         self.diag.info("Rejected GUI configuration from module " + repr(module) + "\n" + plugins.getExceptionString())
         self.rejectedModules.append(module) # Make sure we don't try and import it again
         if module == "default_gui": # pragma: no cover - only to aid debugging default_gui
             raise