def getSubmitCmdArgs(self, test, submissionRules): queueSystem = self.getQueueSystem(test) extraArgs = test.getEnvironment("QUEUE_SYSTEM_SUBMIT_ARGS", "") # Extra arguments to provide on submission to grid engine cmdArgs = queueSystem.getSubmitCmdArgs(submissionRules) if extraArgs: cmdArgs += plugins.splitcmd(extraArgs) return cmdArgs
def getExtraSubmitArgs(self): if not self.optionMap.has_key("reconnect"): envSetting = os.path.expandvars(self.test.getEnvironment("QUEUE_SYSTEM_SUBMIT_ARGS", "")) # Deprecated. See "queue_system_submit_args" in config file docs argStr = envSetting or self.test.getConfigValue("queue_system_submit_args") return plugins.splitcmd(argStr) else: return []
def getSubmitCmdArgs(self, test, submissionRules): queueSystem = self.getQueueSystem(test) extraArgs = submissionRules.getExtraSubmitArgs() cmdArgs = queueSystem.getSubmitCmdArgs(submissionRules) if extraArgs: cmdArgs += plugins.splitcmd(extraArgs) return cmdArgs
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) + ")"
def getFollowCommand(self, program, fileName): remoteHost = self.getRemoteHost() if remoteHost: remoteShellProgram = guiplugins.guiConfig.getValue("remote_shell_program") return [ remoteShellProgram, remoteHost, "env DISPLAY=" + self.getFullDisplay() + " " + \ program + " " + fileName ] else: return plugins.splitcmd(program) + [ fileName ]
def _performOnFile(self, diffProgram, tmpFile, comparison): stdFile = comparison.getStdFile(self.useFiltered(), self.extraPostfix()) description = diffProgram + " " + os.path.basename(stdFile) + " " + os.path.basename(tmpFile) guiplugins.guilog.info("Starting graphical difference comparison using '" + diffProgram + "':") guiplugins.guilog.info("-- original file : " + stdFile) guiplugins.guilog.info("-- current file : " + tmpFile) cmdArgs = plugins.splitcmd(diffProgram) + [ stdFile, tmpFile ] self.startViewer(cmdArgs, description=description, exitHandler=self.diffingComplete)
def getVirtualServerArgs(self, machine, app): binDir = plugins.installationDir("libexec") fullPath = os.path.join(binDir, "startXvfb.py") logDir = os.path.join(app.writeDirectory, "Xvfb") plugins.ensureDirectoryExists(logDir) python = self.findPython(machine) xvfbExtraArgs = plugins.splitcmd(app.getConfigValue("virtual_display_extra_args")) cmdArgs = [ python, "-u", fullPath, logDir ] + xvfbExtraArgs return app.getCommandArgsOn(machine, cmdArgs)
def getLocalExecuteCmdArgs(self, test, makeDirs=True): args = [] if test.app.hasAutomaticCputimeChecking(): 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") args += self.getInterpreterArgs(test, expandVars) args += test.getInterpreterOptions() args += plugins.splitcmd(test.getConfigValue("executable", expandVars=expandVars)) args += test.getCommandLineOptions() return args
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
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)): remoteHost = self.getRemoteHost() if remoteHost: remoteShellProgram = guiplugins.guiConfig.getValue("remote_shell_program") cmdArgs = [ remoteShellProgram, remoteHost, "env DISPLAY=" + self.getFullDisplay() + " " + " ".join(cmdArgs) ] return cmdArgs, descriptor, env
def getVirtualServerArgs(self, machine, app): binDir = plugins.installationDir("libexec") fullPath = os.path.join(binDir, "startXvfb.py") appTmpDir = app.getRemoteTmpDirectory()[1] if appTmpDir: logDir = os.path.join(appTmpDir, "Xvfb") app.ensureRemoteDirExists(machine, logDir) remoteXvfb = os.path.join(appTmpDir, "startXvfb.py") app.copyFileRemotely(fullPath, "localhost", remoteXvfb, machine) fullPath = remoteXvfb pythonArgs = [ "python", "-u" ] else: logDir = os.path.join(app.writeDirectory, "Xvfb") plugins.ensureDirectoryExists(logDir) pythonArgs = self.findPythonArgs(machine) xvfbExtraArgs = plugins.splitcmd(app.getConfigValue("virtual_display_extra_args")) cmdArgs = pythonArgs + [ fullPath, logDir ] + xvfbExtraArgs return app.getCommandArgsOn(machine, cmdArgs)
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 "storytext" in interpreter 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
def getInterpreterArgs(self): interpreterArg = os.getenv("TEXTTEST_DYNAMIC_GUI_INTERPRETER", "") # Alternative interpreter for the dynamic GUI : mostly useful for coverage / testing if interpreterArg: return plugins.splitcmd(interpreterArg.replace("ttpython", sys.executable)) else: # pragma: no cover - cannot test without StoryText on dynamic GUI return [ sys.executable ]
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
def getInterpreterArgs(self, test, expandVars): args = plugins.splitcmd(test.getConfigValue("interpreter", expandVars=expandVars)) 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
def getFollowCommand(self, program, fileName): localArgs = plugins.splitcmd(program) + [fileName] return self.getRemoteArgs(localArgs)
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)