示例#1
0
    def getLocalExecuteCmdArgs(self, test, postfix="", makeDirs=True):
        args = []
        if test.app.hasAutomaticCputimeChecking(
        ) and test.app.executingOnPerformanceMachine(test):
            args += self.getTimingArgs(test, makeDirs)

        # Don't expand environment if we're running on a different file system
        expandVars = test.app.getRunMachine(
        ) == "localhost" or not test.getConfigValue("remote_copy_program")
        for interpreterName, interpreter in test.getConfigValue(
                "interpreters", expandVars=expandVars).items():
            args += self.getInterpreterArgs(test, interpreter)
            args += test.getCommandLineOptions(stem=interpreterName +
                                               "_options")
            if postfix:
                args += test.getCommandLineOptions(stem=interpreterName +
                                                   "_options" + postfix)
            if os.path.basename(
                    interpreter) == "storytext" and test.app.useVirtualDisplay(
                    ):
                # Don't display storytext editor under a virtual display!
                args.append("-x")
        args += plugins.splitcmd(
            test.getConfigValue("executable", expandVars=expandVars))
        args += test.getCommandLineOptions(stem="options")
        if postfix:
            args += test.getCommandLineOptions(stem="options" + postfix)
        return args
示例#2
0
 def runDiff(self, diffProgram, stdFile, tmpFile):
     description = diffProgram + " " + os.path.basename(
         stdFile) + " " + os.path.basename(tmpFile)
     cmdArgs = plugins.splitcmd(diffProgram) + [stdFile, tmpFile]
     self.startViewer(cmdArgs,
                      description=description,
                      exitHandler=self.diffingComplete)
示例#3
0
 def getInterpreterArgs(self, test, interpreter):
     args = plugins.splitcmd(interpreter)
     if len(args) > 0 and args[
             0] == "ttpython":  # interpreted to mean "whatever python TextTest runs with"
         return [sys.executable, "-u"] + args[1:]
     else:
         return args
示例#4
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) + ")"
示例#5
0
 def getInterpreterArgs(cls, test, interpreter):
     args = plugins.splitcmd(interpreter)
     if len(args) > 0 and args[0] == "ttpython":  # interpreted to mean "whatever python TextTest runs with"
         basename = os.path.basename(sys.executable).lower()
         python = sys.executable if "python" in basename else "python"
         # 'Native launcher' on Windows, such as via Windows installer. Don't know what Python it used
         return [ python, "-u" ] + args[1:]
     else:
         return args
示例#6
0
    def getViewCommand(self, fileName, viewProgram):
        # viewProgram might have arguments baked into it...
        cmdArgs = plugins.splitcmd(viewProgram) + [fileName]
        program = cmdArgs[0]
        descriptor = " ".join([os.path.basename(program)] + cmdArgs[1:-1])
        env = self.getViewerEnvironment(cmdArgs)
        interpreter = plugins.getInterpreter(program)
        if interpreter:
            cmdArgs = [interpreter] + cmdArgs

        if guiplugins.guiConfig.getCompositeValue(
                "view_file_on_remote_machine", self.getStem(fileName)):
            cmdArgs = self.getRemoteArgs(cmdArgs)

        return cmdArgs, descriptor, env
示例#7
0
    def createDisplay(self, machine, app):
        if not self.executableExists(machine, app, "Xvfb"):
            return None, None, None, None, None
        wmExecutable = app.getConfigValue("virtual_display_wm_executable")
        if wmExecutable and not self.executableExists(machine, app,
                                                      wmExecutable):
            return None, None, None, None, None

        extraArgs = plugins.splitcmd(
            app.getConfigValue("virtual_display_extra_args"))
        xvfbCmd = self.getRemoteCmd(machine, app, "startXvfb.py", extraArgs)
        displayName, xvfbPid, xvfbOrSshProc = self.startXvfb(xvfbCmd, machine)

        wmPid, wmOrSshProc = None, None
        if wmExecutable:
            extraArgs = [wmExecutable, displayName]
            wmArgs = self.getRemoteCmd(machine, app, "startWindowManager.py",
                                       extraArgs)
            wmPid, wmOrSshProc = self.startWindowManager(wmArgs, machine)
        return displayName, xvfbPid, xvfbOrSshProc, wmPid, wmOrSshProc
示例#8
0
 def getFollowCommand(self, program, fileName):
     localArgs = plugins.splitcmd(program) + [fileName]
     return self.getRemoteArgs(localArgs)