//tester method to check if B.exe is working public static bool Tester(System.Diagnostics.Process process, string cube, bool expected) { int result; string tempCube; process.StartInfo.Arguments = cube; process.Start(); process.WaitForExit(); result = process.ExitCode; if (result == 1 && expected == true) { System.Console.WriteLine("not ok:"); tempCube = printcube(cube); System.Console.WriteLine(tempCube); System.Console.WriteLine("returned:no"); System.Console.WriteLine("expected:yes"); return true; } else if (result == 0 && expected == false) { System.Console.WriteLine("not ok:"); tempCube = printcube(cube); System.Console.WriteLine(tempCube); System.Console.WriteLine("returned:yes"); System.Console.WriteLine("expected:no"); return true; } else return false; }
public static void On(System.Diagnostics.Process process, TimeSpan forHowLong) { var timeoutInMilliseconds = Convert.ToInt32(forHowLong.TotalMilliseconds); process.WaitForExit(timeoutInMilliseconds); if (false == process.HasExited) { process.Kill(); process.WaitForExit(timeoutInMilliseconds); throw new TimeoutException( String.Format( "The process did not exit within the allowed period <{0}> " + "and it has been forcibly closed.", forHowLong ) ); } }
/// <summary> /// Запуск теста /// </summary> /// <param name="proc">Выполняемый процесс</param> /// <param name="time">Время ожидания выполнения процесса</param> /// <param name="N">Порядковый номер теста</param> public static void beginTest(ref System.Diagnostics.Process proc, int time, int N) { if (proc.WaitForExit(time)) Console.WriteLine("Тест " + N.ToString() + " пройден"); else { Console.WriteLine("Тест " + N.ToString() + " не пройден"); proc.Kill(); } }
public static void PrintProcessOutput(System.Diagnostics.Process process) { if(!process.HasExited) process.WaitForExit(); if(process.StartInfo.RedirectStandardOutput) { while(!process.StandardOutput.EndOfStream) Debug.Log(process.StandardOutput.ReadLine()); } if(process.StartInfo.RedirectStandardError) { while(!process.StandardError.EndOfStream) Debug.LogWarning(process.StandardError.ReadLine()); } }
private static bool StartProcess(SVNConfig config, System.Diagnostics.Process process, out string stdout, out string stderr) { if(config.enableDebugging) { Debug.Log(process.StartInfo.FileName + " " + process.StartInfo.Arguments); } bool result = false; try { result = process.Start(); } catch(System.Exception e) { Debug.LogError(e.Message); stdout = ""; stderr = e.Message; return false; } stdout = process.StandardOutput.ReadToEnd(); stderr = process.StandardError.ReadToEnd(); if(config.enableDebugging && stdout != "") { Debug.Log(stdout); } if(stderr != "") { Debug.LogError(stderr); } process.WaitForExit(); return result; }