@@ -33,7 +33,7 @@ function Invoke-ScriptAnalyzer {
33
33
$scriptAnalyzer = New-Object " Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer"
34
34
$scriptAnalyzer.Initialize (
35
35
$runspace ,
36
- $outputWriter ,
36
+ $testOutputWriter ,
37
37
$CustomizedRulePath ,
38
38
$IncludeRule ,
39
39
$ExcludeRule ,
@@ -54,27 +54,32 @@ public class PesterTestOutputWriter : IOutputWriter
54
54
{
55
55
private PSHost psHost;
56
56
57
+ public string MostRecentWarningMessage { get; private set; }
58
+
57
59
public static PesterTestOutputWriter Create(PSHost psHost)
58
60
{
59
- PesterTestOutputWriter outputWriter = new PesterTestOutputWriter();
60
- outputWriter .psHost = psHost;
61
- return outputWriter ;
61
+ PesterTestOutputWriter testOutputWriter = new PesterTestOutputWriter();
62
+ testOutputWriter .psHost = psHost;
63
+ return testOutputWriter ;
62
64
}
63
65
64
- // NOTE: We don't implement any Write methods to prevent console spew
65
-
66
66
public void WriteError(ErrorRecord error)
67
67
{
68
+ // We don't write errors to avoid misleading
69
+ // error messages in test output
68
70
}
69
71
70
72
public void WriteWarning(string message)
71
73
{
72
- // Some tests look for warning messages, so write those out
73
74
psHost.UI.WriteWarningLine(message);
75
+
76
+ this.MostRecentWarningMessage = message;
74
77
}
75
78
76
79
public void WriteVerbose(string message)
77
80
{
81
+ // We don't write verbose output to avoid lots
82
+ // of unnecessary messages in test output
78
83
}
79
84
80
85
public void WriteDebug(string message)
@@ -92,9 +97,9 @@ public class PesterTestOutputWriter : IOutputWriter
92
97
}
93
98
"@ - ReferencedAssemblies " Microsoft.Windows.PowerShell.ScriptAnalyzer" - ErrorAction SilentlyContinue
94
99
95
- if ($outputWriter -eq $null )
100
+ if ($testOutputWriter -eq $null )
96
101
{
97
- $outputWriter = [PesterTestOutputWriter ]::Create($Host );
102
+ $testOutputWriter = [PesterTestOutputWriter ]::Create($Host );
98
103
}
99
104
100
105
# Create a fresh runspace to pass into the ScriptAnalyzer class
0 commit comments