本文整理匯總了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));
}