예제 #1
0
    def getRemoteExecuteCmdArgs(self, test, runMachine, localArgs, postfix):
        scriptFileName = test.makeTmpFileName("run_test" + postfix + ".sh", forComparison=0)
        scriptFile = open(scriptFileName, "wb")
        self.writeScriptLine(scriptFile, "#!/bin/sh")
        self.writeScriptLine(scriptFile, "")

        # Need to change working directory remotely
        tmpDir = self.getTmpDirectory(test)
        self.writeScriptLine(scriptFile, "cd " + plugins.quote(tmpDir))

        # Must set the environment remotely
        remoteTmp = test.app.getRemoteTmpDirectory()[1]
        for arg, value in self.getEnvironmentArgs(test, remoteTmp, postfix):
            # Two step export process for compatibility with CYGWIN and older versions of 'sh'
            self.writeScriptLine(scriptFile, arg + "=" + value)
            self.writeScriptLine(scriptFile, "export " + arg)
        if test.app.getConfigValue("remote_shell_program") == "ssh":
            # SSH doesn't kill remote processes, create a kill script
            self.writeScriptLine(scriptFile, 'echo "kill $$" > kill_test.sh')
        cmdString = " ".join(map(self.quoteLocalArg, localArgs))
        if remoteTmp:
            cmdString = cmdString.replace(test.app.writeDirectory, remoteTmp)
        self.writeScriptLine(scriptFile, "exec " + cmdString)
        scriptFile.close()
        os.chmod(scriptFileName, 0o775)  # make executable
        remoteTmp = test.app.getRemoteTestTmpDir(test)[1]
        if remoteTmp:
            test.app.copyFileRemotely(scriptFileName, "localhost", remoteTmp, runMachine)
            remoteScript = os.path.join(remoteTmp, os.path.basename(scriptFileName))
            return test.app.getCommandArgsOn(runMachine, [plugins.quote(remoteScript)])
        else:
            return test.app.getCommandArgsOn(runMachine, [plugins.quote(scriptFileName)])
예제 #2
0
파일: runtest.py 프로젝트: scutse/texttest
    def getEnvironmentArgs(self, test, remoteTmp, postfix):
        vars = self.getEnvironmentChanges(test, postfix)
        args = []
        localTmpDir = test.app.writeDirectory
        builtinVars = [
            "TEXTTEST_CHECKOUT", "TEXTTEST_CHECKOUT_NAME", "TEXTTEST_ROOT",
            "TEXTTEST_LOG_DIR", "TEXTTEST_SANDBOX", "TEXTTEST_SANDBOX_ROOT",
            "STORYTEXT_HOME_LOCAL"
        ]
        for var, value in vars:
            if var in builtinVars:
                continue
            if remoteTmp:
                remoteValue = value.replace(localTmpDir, remoteTmp)
            else:
                remoteValue = value

            currentValue = os.getenv(var)
            if currentValue:
                remoteValue = remoteValue.replace(currentValue,
                                                  "${" + var + "}")
                if var == "PATH" and os.name == "nt":
                    # We assume cygwin paths, make sure we use POSIX path separators
                    remoteValue = remoteValue.replace(";", ":")
            remoteValue = plugins.quote(remoteValue)
            args.append((var, remoteValue))
        return args
예제 #3
0
파일: runtest.py 프로젝트: scutse/texttest
 def killRemoteProcess(self, test, machine):
     tmpDir = self.getTmpDirectory(test)
     remoteScript = os.path.join(tmpDir, "kill_test.sh")
     test.app.runCommandOn(machine, ["sh", plugins.quote(remoteScript)])