Skip to content

Commit f1798d1

Browse files
committed
Merge pull request #6777 from KevinH-MS/EETestFailFast
Always "fail fast" in EE unit tests...
2 parents 573094f + cad07f4 commit f1798d1

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ExpressionCompilerTestBase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public abstract class ExpressionCompilerTestBase : CSharpTestBase, IDisposable
2828

2929
internal static readonly ImmutableArray<Alias> NoAliases = ImmutableArray<Alias>.Empty;
3030

31+
protected ExpressionCompilerTestBase()
32+
{
33+
// We never want to swallow Exceptions (generate a non-fatal Watson) when running tests.
34+
ExpressionEvaluatorFatalError.IsFailFastEnabled = true;
35+
}
36+
3137
public override void Dispose()
3238
{
3339
base.Dispose();

src/ExpressionEvaluator/Core/Source/ExpressionCompiler/ExpressionEvaluatorFatalError.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal static class ExpressionEvaluatorFatalError
1616
{
1717
private const string RegistryKey = @"Software\Microsoft\ExpressionEvaluator";
1818
private const string RegistryValue = "EnableFailFast";
19-
private static readonly bool s_isFailFastEnabled;
19+
internal static bool IsFailFastEnabled;
2020

2121
static ExpressionEvaluatorFatalError()
2222
{
@@ -41,7 +41,7 @@ static ExpressionEvaluatorFatalError()
4141
var value = getValueMethod.Invoke(eeKey, new object[] { RegistryValue });
4242
if ((value != null) && (value is int))
4343
{
44-
s_isFailFastEnabled = ((int)value == 1);
44+
IsFailFastEnabled = ((int)value == 1);
4545
}
4646
}
4747
}
@@ -57,7 +57,7 @@ static ExpressionEvaluatorFatalError()
5757

5858
internal static bool CrashIfFailFastEnabled(Exception exception)
5959
{
60-
if (!s_isFailFastEnabled)
60+
if (!IsFailFastEnabled)
6161
{
6262
return false;
6363
}

src/ExpressionEvaluator/Core/Source/ExpressionCompiler/FrameDecoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void GetNameWithGenericTypeArguments(
104104
}
105105
onSuccess(method);
106106
}
107-
catch (Exception e) when (ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
107+
catch (Exception e)
108108
{
109109
onFailure(e);
110110
}
@@ -173,7 +173,7 @@ private void GetFrameName(
173173
builder?.Free();
174174
completionRoutine(new DkmGetFrameNameAsyncResult(frameName));
175175
}
176-
catch (Exception e) when (ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
176+
catch (Exception e)
177177
{
178178
completionRoutine(DkmGetFrameNameAsyncResult.CreateErrorResult(e));
179179
}

src/ExpressionEvaluator/Core/Source/ResultProvider/ResultProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ private static void EvaluateDebuggerDisplayStringAndContinue(
637637
{
638638
onCompleted(result);
639639
}
640-
catch (Exception e) when (ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
640+
catch (Exception e)
641641
{
642642
onException(e);
643643
}
@@ -901,7 +901,7 @@ internal void Execute()
901901
{
902902
completionRoutine();
903903
}
904-
catch (Exception e) when (ExpressionEvaluatorFatalError.ReportNonFatalException(e, DkmComponentManager.ReportCurrentNonFatalException))
904+
catch (Exception e)
905905
{
906906
_onException(e);
907907
}

src/ExpressionEvaluator/Core/Test/ResultProvider/ResultProviderTestBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ public abstract class ResultProviderTestBase
2323

2424
internal readonly DkmInspectionContext DefaultInspectionContext;
2525

26-
internal ResultProviderTestBase(ResultProvider resultProvider, DkmInspectionContext defaultInspectionContext)
26+
protected ResultProviderTestBase(ResultProvider resultProvider, DkmInspectionContext defaultInspectionContext)
2727
{
2828
_formatter = resultProvider.Formatter;
2929
_resultProvider = resultProvider;
3030
this.DefaultInspectionContext = defaultInspectionContext;
31+
32+
// We never want to swallow Exceptions (generate a non-fatal Watson) when running tests.
33+
ExpressionEvaluatorFatalError.IsFailFastEnabled = true;
3134
}
3235

3336
internal DkmClrValue CreateDkmClrValue(

src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/ExpressionCompilerTestBase.vb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests
2929

3030
Friend Shared ReadOnly NoAliases As ImmutableArray(Of [Alias]) = ImmutableArray(Of [Alias]).Empty
3131

32+
Protected Sub New()
33+
' We never want to swallow Exceptions (generate a non-fatal Watson) when running tests.
34+
ExpressionEvaluatorFatalError.IsFailFastEnabled = True
35+
End Sub
36+
3237
Public Overrides Sub Dispose()
3338
MyBase.Dispose()
3439

0 commit comments

Comments
 (0)