private List <string> RunTestExecutableWithNewFramework(string executable, string workingDir, IDictionary <string, string> envVars, CommandLineGenerator.Args arguments, IProcessExecutor executor, StreamingStandardOutputTestResultParser streamingParser) { string pathExtension = _settings.GetPathExtension(executable); bool printTestOutput = _settings.PrintTestOutput && !_settings.ParallelTestExecution; if (printTestOutput) { _logger.LogInfo(String.Format(Resources.OutputOfCommandMessage, _threadName, executable, arguments.CommandLine)); } Action <string> reportOutputAction = line => { try { if (!_canceled) { streamingParser.ReportLine(line); } if (printTestOutput) { _logger.LogInfo(line); } } catch (TestRunCanceledException e) { _logger.DebugInfo(String.Format(Resources.ExecutionCancelled, _threadName, e.InnerException?.Message ?? e.Message)); Cancel(); } }; _processExecutor = executor; _processExecutor.ExecuteCommandBlocking( executable, arguments.CommandLine, workingDir, envVars, pathExtension, reportOutputAction); streamingParser.Flush(); if (printTestOutput) { _logger.LogInfo(String.Format(Resources.EndOfOutputMessage, _threadName)); } var consoleOutput = new List <string>(); new TestDurationSerializer().UpdateTestDurations(streamingParser.TestResults); _logger.DebugInfo(String.Format(Resources.ReportedResultsToVS, _threadName, streamingParser.TestResults.Count, executable)); foreach (TestResult result in streamingParser.TestResults) { if (!_schedulingAnalyzer.AddActualDuration(result.TestCase, (int)result.Duration.TotalMilliseconds)) { _logger.LogWarning(String.Format(Resources.AlreadyInAnalyzer, _threadName, result.TestCase.FullyQualifiedName)); } } return(consoleOutput); }
private List <string> RunTestExecutableWithNewFramework(string executable, string workingDir, CommandLineGenerator.Args arguments, IProcessExecutor executor, StreamingStandardOutputTestResultParser streamingParser) { string pathExtension = _settings.GetPathExtension(executable); bool printTestOutput = _settings.PrintTestOutput && !_settings.ParallelTestExecution; if (printTestOutput) { _logger.LogInfo( $"{_threadName}>>>>>>>>>>>>>>> Output of command '" + executable + " " + arguments.CommandLine + "'"); } Action <string> reportOutputAction = line => { try { if (!_canceled) { streamingParser.ReportLine(line); } if (printTestOutput) { _logger.LogInfo(line); } } catch (TestRunCanceledException e) { _logger.DebugInfo($"{_threadName}Execution has been canceled: {e.InnerException?.Message ?? e.Message}"); Cancel(); } }; _processExecutor = executor; _processExecutor.ExecuteCommandBlocking( executable, arguments.CommandLine, workingDir, pathExtension, reportOutputAction); streamingParser.Flush(); if (printTestOutput) { _logger.LogInfo($"{_threadName}<<<<<<<<<<<<<<< End of Output"); } var consoleOutput = new List <string>(); new TestDurationSerializer().UpdateTestDurations(streamingParser.TestResults); _logger.DebugInfo( $"{_threadName}Reported {streamingParser.TestResults.Count} test results to VS during test execution, executable: '{executable}'"); foreach (TestResult result in streamingParser.TestResults) { if (!_schedulingAnalyzer.AddActualDuration(result.TestCase, (int)result.Duration.TotalMilliseconds)) { _logger.LogWarning($"{_threadName}TestCase already in analyzer: {result.TestCase.FullyQualifiedName}"); } } return(consoleOutput); }
private List <string> RunTestExecutable(string executable, string workingDir, CommandLineGenerator.Args arguments, bool isBeingDebugged, IDebuggedProcessExecutorFactory processExecutorFactory, StreamingStandardOutputTestResultParser streamingParser) { string pathExtension = _settings.GetPathExtension(executable); bool isTestOutputAvailable = !isBeingDebugged || _settings.DebuggerKind > DebuggerKind.VsTestFramework; bool printTestOutput = _settings.PrintTestOutput && !_settings.ParallelTestExecution && isTestOutputAvailable; void OnNewOutputLine(string line) { try { if (!_canceled) { streamingParser.ReportLine(line); } } catch (TestRunCanceledException e) { _logger.DebugInfo($"{_threadName}Execution has been canceled: {e.InnerException?.Message ?? e.Message}"); Cancel(); } } _processExecutor = isBeingDebugged ? _settings.DebuggerKind == DebuggerKind.VsTestFramework ? processExecutorFactory.CreateFrameworkDebuggingExecutor(printTestOutput, _logger) : processExecutorFactory.CreateNativeDebuggingExecutor( _settings.DebuggerKind == DebuggerKind.Native ? DebuggerEngine.Native : DebuggerEngine.ManagedAndNative, printTestOutput, _logger) : processExecutorFactory.CreateExecutor(printTestOutput, _logger); int exitCode = _processExecutor.ExecuteCommandBlocking( executable, arguments.CommandLine, workingDir, pathExtension, isTestOutputAvailable ? (Action <string>)OnNewOutputLine : null); streamingParser.Flush(); ExecutableResults.Add(new ExecutableResult(executable, exitCode, streamingParser.ExitCodeOutput, streamingParser.ExitCodeSkip)); var consoleOutput = new List <string>(); new TestDurationSerializer().UpdateTestDurations(streamingParser.TestResults); _logger.DebugInfo( $"{_threadName}Reported {streamingParser.TestResults.Count} test results to VS during test execution, executable: '{executable}'"); foreach (TestResult result in streamingParser.TestResults) { if (!_schedulingAnalyzer.AddActualDuration(result.TestCase, (int)result.Duration.TotalMilliseconds)) { _logger.DebugWarning($"{_threadName}TestCase already in analyzer: {result.TestCase.FullyQualifiedName}"); } } return(consoleOutput); }