private void StartTestFunc(int in_idx) { m_state[(int)m_curRunMode] = State.RUNNING; RefreshState(); if (TestFunctionsToExecute[in_idx].TestFuncEntry.IsTestDisabled) { m_mainEvents.OnTestTerminated(Result.Disabled, string.Empty, false, new TimeSpan(0), "Test is disabled"); } else { StartProcess(m_projectInfo.GetExePath(), TestFunctionsToExecute[in_idx].TestFuncEntry.GetCmdString() + " " + cbxDefaultArgs.Text, m_projectInfo.SelectedProject.TargetDirPath, false); } }
/// [exec start process] public void StartProcess(string exePath, string args, string workDir, bool enableBoostParsing) { try { // Ensure executable exists if (!System.IO.File.Exists(exePath)) { WriteLine(1, "Executable not found: " + exePath); m_mainEvents.OnTestTerminated(Result.Failed, exePath, false, new TimeSpan(0), "Executable not found: " + exePath); return; } // Ensure output pane exists if (m_outputPane == null) { EnvDTE.OutputWindow ow = dte.ToolWindows.OutputWindow; m_outputPane = ow.OutputWindowPanes.Add("Run UnitTest"); } m_outputPane.Activate(); m_outputPane.Clear(); // ----- Prepare process data ----- m_process = new System.Diagnostics.Process(); m_process.StartInfo.FileName = exePath; m_process.StartInfo.WorkingDirectory = workDir; m_process.StartInfo.Arguments = args.Trim(); boostProcessOutputParser.Clear(); boostProcessOutputParser.EnableParsing = enableBoostParsing; if (m_getNotificationWhenProcessTerminates) { // Remark: Method Executor.Process_Exited will be called // from some system thread when the process has terminated. // Synchronization will be needed! m_process.Exited += new System.EventHandler(Process_Exited); m_process.EnableRaisingEvents = true; } if (m_catchStdOutAndStdErr) { m_process.StartInfo.UseShellExecute = false; m_process.StartInfo.RedirectStandardOutput = true; m_process.StartInfo.RedirectStandardError = true; m_process.StartInfo.CreateNoWindow = true; m_process.OutputDataReceived += new System.Diagnostics. DataReceivedEventHandler(boostProcessOutputParser.StandardOutputReceiver); m_process.ErrorDataReceived += new System.Diagnostics. DataReceivedEventHandler(boostProcessOutputParser.StandardErrorReceiver); } // ----- Start the new process and start redirection of output ----- m_process.Start(); if (m_catchStdOutAndStdErr) { m_process.BeginOutputReadLine(); m_process.BeginErrorReadLine(); } WriteLine(2, "Started " + m_process.StartInfo.FileName); } catch (Exception e) { string info = "EXCEPTION: Could not start executable " + exePath + " " + e.ToString(); WriteLine(1, info); m_mainEvents.OnTestTerminated(Result.Failed, exePath, false, new TimeSpan(0), info); } }