Skip to content

Commit

Permalink
Revert "Refactor GetResultOrRunClassInitialize to have clearer intent… (
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink authored Dec 10, 2024
1 parent 056912d commit 6aa7715
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/Adapter/MSTest.TestAdapter/Execution/TestClassInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public class TestClassInfo
{
private readonly Lock _testClassExecuteSyncObject = new();

private UnitTestResult? _cachedClassInitializeResult;

/// <summary>
/// Initializes a new instance of the <see cref="TestClassInfo"/> class.
/// </summary>
Expand Down Expand Up @@ -355,15 +353,10 @@ internal UnitTestResult GetResultOrRunClassInitialize(ITestContext testContext,
{
// For optimization purposes, we duplicate some of the logic of RunClassInitialize here so we don't need to start
// a thread for nothing.
if (ClassInitializeMethod is null && BaseClassInitMethods.Count == 0)
if ((ClassInitializeMethod is null && BaseClassInitMethods.Count == 0)
|| IsClassInitializeExecuted)
{
return new() { Outcome = ObjectModelUnitTestOutcome.Passed };
}

if (IsClassInitializeExecuted)
{
DebugEx.Assert(_cachedClassInitializeResult is not null, "If class init was called, we should have cached the result.");
return _cachedClassInitializeResult;
return DoRun();
}

UnitTestResult result = new(ObjectModelUnitTestOutcome.Error, "MSTest STATestClass ClassInitialize didn't complete");
Expand All @@ -378,7 +371,6 @@ internal UnitTestResult GetResultOrRunClassInitialize(ITestContext testContext,
try
{
entryPointThread.Join();
_cachedClassInitializeResult = result;
return result;
}
catch (Exception ex)
Expand All @@ -395,9 +387,7 @@ internal UnitTestResult GetResultOrRunClassInitialize(ITestContext testContext,
PlatformServiceProvider.Instance.AdapterTraceLogger.LogWarning(Resource.STAIsOnlySupportedOnWindowsWarning);
}

UnitTestResult result = DoRun();
_cachedClassInitializeResult = result;
return result;
return DoRun();
}

// Local functions
Expand Down

0 comments on commit 6aa7715

Please sign in to comment.