|
9 | 9 | using Microsoft.VisualStudio.TestPlatform.CoreUtilities;
|
10 | 10 | using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities;
|
11 | 11 | using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions;
|
| 12 | +using Microsoft.VisualStudio.TestPlatform.Utilities; |
12 | 13 |
|
13 | 14 | namespace Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
14 | 15 |
|
@@ -92,6 +93,8 @@ public RunConfiguration() : base(Constants.RunConfigurationSettingsName)
|
92 | 93 | _shouldCollectSourceInformation = false;
|
93 | 94 | TargetDevice = null;
|
94 | 95 | ExecutionThreadApartmentState = Constants.DefaultExecutionThreadApartmentState;
|
| 96 | + CaptureStandardOutput = !FeatureFlag.Instance.IsSet(FeatureFlag.VSTEST_DISABLE_STANDARD_OUTPUT_CAPTURING); |
| 97 | + ForwardStandardOutput = !FeatureFlag.Instance.IsSet(FeatureFlag.VSTEST_DISABLE_STANDARD_OUTPUT_FORWARDING); |
95 | 98 | }
|
96 | 99 |
|
97 | 100 | /// <summary>
|
@@ -431,10 +434,27 @@ public bool ResultsDirectorySet
|
431 | 434 | /// </summary>
|
432 | 435 | public string? TestCaseFilter { get; private set; }
|
433 | 436 |
|
| 437 | + /// <summary> |
434 | 438 | /// Path to dotnet executable to be used to invoke testhost.dll. Specifying this will skip looking up testhost.exe and will force usage of the testhost.dll.
|
435 | 439 | /// </summary>
|
436 | 440 | public string? DotnetHostPath { get; private set; }
|
437 | 441 |
|
| 442 | + /// <summary> |
| 443 | + /// When true, we capture standard output of child processes. When false the standard output is not captured and it will end up in command line. |
| 444 | + /// This makes the output visible to the user when running in vstest.console in-process. Such setup makes the behavior the same as in 17.6.3 and earlier. |
| 445 | + /// |
| 446 | + /// The recommended way is to use this with ForwardStandardOutput=true to forward output as informational messages so the output is always visible in console and VS, |
| 447 | + /// unless the logging level is set to Warning or higher. |
| 448 | + /// |
| 449 | + /// Lastly this can be used with ForwardStandardOutput=false, to suppress the output in console, which is behavior of 17.7.0 till now. |
| 450 | + /// </summary> |
| 451 | + public bool CaptureStandardOutput { get; private set; } |
| 452 | + |
| 453 | + /// <summary> |
| 454 | + /// Forward captured standard output of testhost as Informational test messages. Default is true. Needs CaptureStandardOutput to be true. |
| 455 | + /// </summary> |
| 456 | + public bool ForwardStandardOutput { get; private set; } |
| 457 | + |
438 | 458 | /// <inheritdoc/>
|
439 | 459 | public override XmlElement ToXml()
|
440 | 460 | {
|
@@ -550,6 +570,14 @@ public override XmlElement ToXml()
|
550 | 570 | root.AppendChild(treatAsError);
|
551 | 571 | }
|
552 | 572 |
|
| 573 | + XmlElement captureStandardOutput = doc.CreateElement(nameof(CaptureStandardOutput)); |
| 574 | + captureStandardOutput.InnerXml = CaptureStandardOutput.ToString(); |
| 575 | + root.AppendChild(captureStandardOutput); |
| 576 | + |
| 577 | + XmlElement forwardStandardOutput = doc.CreateElement(nameof(ForwardStandardOutput)); |
| 578 | + forwardStandardOutput.InnerXml = ForwardStandardOutput.ToString(); |
| 579 | + root.AppendChild(forwardStandardOutput); |
| 580 | + |
553 | 581 | return root;
|
554 | 582 | }
|
555 | 583 |
|
@@ -907,6 +935,35 @@ public static RunConfiguration FromXml(XmlReader reader)
|
907 | 935 | case "TargetFrameworkTestHostDemultiplexer":
|
908 | 936 | reader.Skip();
|
909 | 937 | break;
|
| 938 | + |
| 939 | + case "CaptureStandardOutput": |
| 940 | + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); |
| 941 | + string captureStandardOutputStr = reader.ReadElementContentAsString(); |
| 942 | + |
| 943 | + bool bCaptureStandardOutput; |
| 944 | + if (!bool.TryParse(captureStandardOutputStr, out bCaptureStandardOutput)) |
| 945 | + { |
| 946 | + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, |
| 947 | + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, bCaptureStandardOutput, elementName)); |
| 948 | + } |
| 949 | + |
| 950 | + runConfiguration.CaptureStandardOutput = bCaptureStandardOutput; |
| 951 | + break; |
| 952 | + |
| 953 | + case "ForwardStandardOutput": |
| 954 | + XmlRunSettingsUtilities.ThrowOnHasAttributes(reader); |
| 955 | + string forwardStandardOutputStr = reader.ReadElementContentAsString(); |
| 956 | + |
| 957 | + bool bForwardStandardOutput; |
| 958 | + if (!bool.TryParse(forwardStandardOutputStr, out bForwardStandardOutput)) |
| 959 | + { |
| 960 | + throw new SettingsException(string.Format(CultureInfo.CurrentCulture, |
| 961 | + Resources.Resources.InvalidSettingsIncorrectValue, Constants.RunConfigurationSettingsName, bForwardStandardOutput, elementName)); |
| 962 | + } |
| 963 | + |
| 964 | + runConfiguration.ForwardStandardOutput = bForwardStandardOutput; |
| 965 | + break; |
| 966 | + |
910 | 967 | default:
|
911 | 968 | // Ignore a runsettings element that we don't understand. It could occur in the case
|
912 | 969 | // the test runner is of a newer version, but the test host is of an earlier version.
|
|
0 commit comments