本文整理汇总了C#中ThoughtWorks.CruiseControl.Core.Util.ProcessInfo.ProcessSuccessful方法的典型用法代码示例。如果您正苦于以下问题:C# ProcessInfo.ProcessSuccessful方法的具体用法?C# ProcessInfo.ProcessSuccessful怎么用?C# ProcessInfo.ProcessSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThoughtWorks.CruiseControl.Core.Util.ProcessInfo
的用法示例。
在下文中一共展示了ProcessInfo.ProcessSuccessful方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessSuccessRequiresZeroExitCode
public void ProcessSuccessRequiresZeroExitCode()
{
int[] successExitCodes = { 1, 3, 5 };
ProcessInfo info = new ProcessInfo(@"""c:\nant\nant.exe""", null, string.Format(@"""{0}""", Path.GetTempPath()));
Assert.IsTrue(info.ProcessSuccessful(0));
Assert.IsFalse(info.ProcessSuccessful(1));
Assert.IsFalse(info.ProcessSuccessful(2));
Assert.IsFalse(info.ProcessSuccessful(-1));
}
示例2: ProcessSuccessIsDeterminedBySuccessExitCodes
public void ProcessSuccessIsDeterminedBySuccessExitCodes()
{
int[] successExitCodes = { 1, 3, 5 };
ProcessInfo info = new ProcessInfo(@"""c:\nant\nant.exe""", null, string.Format(@"""{0}""", Path.GetTempPath()), ProcessPriorityClass.Normal, successExitCodes);
Assert.IsFalse(info.ProcessSuccessful(0));
Assert.IsTrue(info.ProcessSuccessful(1));
Assert.IsFalse(info.ProcessSuccessful(2));
Assert.IsTrue(info.ProcessSuccessful(3));
Assert.IsFalse(info.ProcessSuccessful(4));
Assert.IsTrue(info.ProcessSuccessful(5));
Assert.IsFalse(info.ProcessSuccessful(6));
}
示例3: RemoteExecute
public ProcessResult RemoteExecute(ProcessInfo processInfo, OnProcessOutput output)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
var filteredEnvironmentVariables = new Dictionary<string, string>();
foreach (DictionaryEntry entry in processInfo.EnvironmentVariables)
{
string name = (string)entry.Key;
string value = (string)entry.Value;
if (startInfo.EnvironmentVariables[name] == value)
continue; // skip locally defined variables
filteredEnvironmentVariables.Add(name, value);
}
StringBuilder stdoutBuilder = new StringBuilder();
StringBuilder stderrBuilder = new StringBuilder();
int exitCode = Execute(processInfo.FileName,
processInfo.Arguments,
string.IsNullOrEmpty(processInfo.WorkingDirectory) ? null : processInfo.WorkingDirectory,
filteredEnvironmentVariables,
line =>
{
stdoutBuilder.AppendLine(line);
output(new ProcessOutputEventArgs(ProcessOutputType.StandardOutput, line));
},
line =>
{
stderrBuilder.AppendLine(line);
output(new ProcessOutputEventArgs(ProcessOutputType.ErrorOutput, line));
},
TimeSpan.FromMilliseconds(processInfo.TimeOut));
return new ProcessResult(
stdoutBuilder.ToString(),
stderrBuilder.ToString(),
exitCode,
exitCode == -1,
! processInfo.ProcessSuccessful(exitCode));
}