@@ -33,7 +33,7 @@ function Invoke-ScriptAnalyzer {
3333 $scriptAnalyzer = New-Object " Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer"
3434 $scriptAnalyzer.Initialize (
3535 $runspace ,
36- $outputWriter ,
36+ $testOutputWriter ,
3737 $CustomizedRulePath ,
3838 $IncludeRule ,
3939 $ExcludeRule ,
@@ -54,27 +54,32 @@ public class PesterTestOutputWriter : IOutputWriter
5454{
5555 private PSHost psHost;
5656
57+ public string MostRecentWarningMessage { get; private set; }
58+
5759 public static PesterTestOutputWriter Create(PSHost psHost)
5860 {
59- PesterTestOutputWriter outputWriter = new PesterTestOutputWriter();
60- outputWriter .psHost = psHost;
61- return outputWriter ;
61+ PesterTestOutputWriter testOutputWriter = new PesterTestOutputWriter();
62+ testOutputWriter .psHost = psHost;
63+ return testOutputWriter ;
6264 }
6365
64- // NOTE: We don't implement any Write methods to prevent console spew
65-
6666 public void WriteError(ErrorRecord error)
6767 {
68+ // We don't write errors to avoid misleading
69+ // error messages in test output
6870 }
6971
7072 public void WriteWarning(string message)
7173 {
72- // Some tests look for warning messages, so write those out
7374 psHost.UI.WriteWarningLine(message);
75+
76+ this.MostRecentWarningMessage = message;
7477 }
7578
7679 public void WriteVerbose(string message)
7780 {
81+ // We don't write verbose output to avoid lots
82+ // of unnecessary messages in test output
7883 }
7984
8085 public void WriteDebug(string message)
@@ -92,9 +97,9 @@ public class PesterTestOutputWriter : IOutputWriter
9297}
9398"@ - ReferencedAssemblies " Microsoft.Windows.PowerShell.ScriptAnalyzer" - ErrorAction SilentlyContinue
9499
95- if ($outputWriter -eq $null )
100+ if ($testOutputWriter -eq $null )
96101{
97- $outputWriter = [PesterTestOutputWriter ]::Create($Host );
102+ $testOutputWriter = [PesterTestOutputWriter ]::Create($Host );
98103}
99104
100105# Create a fresh runspace to pass into the ScriptAnalyzer class
0 commit comments