public static ExecResults Cmd(string fileName, string arguments, string workingDirectory) { using (Process process = new Process()) { var result = new ExecResults(); process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.StartInfo.CreateNoWindow = true; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.FileName = fileName; process.StartInfo.Arguments = arguments; process.StartInfo.WorkingDirectory = workingDirectory; TestContext.Progress.WriteLine($"Running {process.StartInfo.FileName} {process.StartInfo.Arguments} (in {process.StartInfo.WorkingDirectory})"); using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false)) using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false)) { process.OutputDataReceived += (sender, eventArgs) => { if (eventArgs.Data == null) { outputWaitHandle.Set(); } else { result.Output.Add(eventArgs.Data); TestContext.Progress.WriteLine($"INFO: {eventArgs.Data}"); } }; process.ErrorDataReceived += (sender, eventArgs) => { if (eventArgs.Data == null) { outputWaitHandle.Set(); } else { result.Errors.Add(eventArgs.Data); TestContext.Progress.WriteLine($"ERROR: {eventArgs.Data}"); } }; process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); TestContext.Progress.WriteLine($"Process exited with code {process.ExitCode}"); result.ExitCode = process.ExitCode; result.ExitCode.Should().Be(0); return(result); } } }
public override void cleanup() { base.cleanup(); // Cleanup and remove current wait condition waitCondition = null; // Cleanup and remove the event manager if (eventManager != null) { eventManager.Cleanup(); eventManager = null; } graphicsProxy = null; execResults = null; status = null; commands = null; }
public BasicRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) : base(specification, hostManager, peer, statics) { eventManager = new EventManager(this); graphicsProxy = new GraphicsProxy(); // dummy execResults = new ExecResults(null, null, null, null, null, false, false, false); setSetCallCount(0); setGetCallCount(0); var sharedBuffer = new byte[10 * 1024 * 100]; execJavaBuffer = new DirectByteBuffer(sharedBuffer); execNetBuffer = ByteBuffer.wrap(sharedBuffer); rbSerializerN = new RbSerializerN(); this.peer.setupBuffer(execJavaBuffer); }
private void DeserializeResults() { execNetBuffer.position(0); execNetBuffer.limit(execJavaBuffer.limit()); execResults = (ExecResults)rbSerializerN.deserialize(execNetBuffer); }