Skip to content

Commit

Permalink
Revert "Experiment: replace Microsoft.TestPlatform.ObjectModel NUGet …
Browse files Browse the repository at this point in the history
…reference with AssemblyHelper for one of its types"

This reverts commit 36a4029.
  • Loading branch information
bradwilson committed Oct 15, 2023
1 parent 36a4029 commit 3761c16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
27 changes: 11 additions & 16 deletions src/xunit.runner.visualstudio/VsTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System.Threading;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Xunit.Abstractions;
using Xunit.Internal;
Expand Down Expand Up @@ -229,11 +228,8 @@ void DiscoverTests<TVisitor>(
RemotingUtility.CleanUpRegisteredChannels();

var internalDiagnosticsMessageSink = DiagnosticMessageSink.ForInternalDiagnostics(logger, runSettings.InternalDiagnosticMessages ?? false);
var wrappedInternalDiagnosticsMessageSink = MessageSinkAdapter.Wrap(internalDiagnosticsMessageSink);

using var _1 = AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), wrappedInternalDiagnosticsMessageSink);
using var _2 = AssemblyHelper.SubscribeResolveForAssembly(typeof(ITestRuntimeProvider), wrappedInternalDiagnosticsMessageSink);

using var _ = AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), MessageSinkAdapter.Wrap(internalDiagnosticsMessageSink));
foreach (var assemblyFileNameCanBeWithoutAbsolutePath in sources)
{
var assembly = new XunitProjectAssembly { AssemblyFilename = GetAssemblyFileName(assemblyFileNameCanBeWithoutAbsolutePath) };
Expand Down Expand Up @@ -389,18 +385,17 @@ void RunTests(
var reporter = GetRunnerReporter(logger, runSettings, runInfos.Select(ari => ari.Assembly.AssemblyFilename).ToList());
using var reporterMessageHandler = MessageSinkWithTypesAdapter.Wrap(reporter.CreateMessageHandler(new VisualStudioRunnerLogger(logger)));
using var internalDiagnosticsMessageSink = DiagnosticMessageSink.ForInternalDiagnostics(logger, runSettings.InternalDiagnosticMessages ?? false);
var wrappedInternalDiagnosticsMessageSink = MessageSinkAdapter.Wrap(internalDiagnosticsMessageSink);

using var _1 = AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), wrappedInternalDiagnosticsMessageSink);
using var _2 = AssemblyHelper.SubscribeResolveForAssembly(typeof(ITestRuntimeProvider), wrappedInternalDiagnosticsMessageSink);

if (parallelizeAssemblies)
runInfos
.Select(runInfo => RunTestsInAssemblyAsync(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo))
.ToList()
.ForEach(@event => @event.WaitOne());
else
runInfos.ForEach(runInfo => RunTestsInAssembly(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo));
using (AssemblyHelper.SubscribeResolveForAssembly(typeof(VsTestRunner), MessageSinkAdapter.Wrap(internalDiagnosticsMessageSink)))
{
if (parallelizeAssemblies)
runInfos
.Select(runInfo => RunTestsInAssemblyAsync(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo))
.ToList()
.ForEach(@event => @event.WaitOne());
else
runInfos.ForEach(runInfo => RunTestsInAssembly(runContext, frameworkHandle, logger, testPlatformContext, runSettings, reporterMessageHandler, runInfo));
}
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<repository type="git" url="https://github.com/xunit/visualstudio.xunit" commit="$GitCommitId$" />
<developmentDependency>true</developmentDependency>
<dependencies>
<group targetFramework="net462" />
<group targetFramework="net462">
<dependency id="Microsoft.TestPlatform.ObjectModel" version="$MicrosoftTestPlatformObjectModelVersion$" />
</group>
<group targetFramework="net6.0" />
</dependencies>
<frameworkAssemblies>
Expand Down

0 comments on commit 3761c16

Please sign in to comment.