Skip to content

Commit

Permalink
Latest dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Oct 17, 2024
1 parent 15da70f commit 8174918
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Versions.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<ILRepackVersion>2.0.34</ILRepackVersion>
<ILRepackVersion>2.0.35</ILRepackVersion>
<MicrosoftNetCoreAppRefVersion>6.0.32</MicrosoftNetCoreAppRefVersion>
<MicrosoftNetFrameworkReferenceAssembliesVersion>1.0.3</MicrosoftNetFrameworkReferenceAssembliesVersion>
<MicrosoftNetTestSdkVersion>17.11.1</MicrosoftNetTestSdkVersion>
Expand All @@ -11,8 +11,8 @@
<NSubstituteVersion>5.1.0</NSubstituteVersion>
<TunnelVisionLabsReferenceAssemblyAnnotatorVersion>1.0.0-alpha.160</TunnelVisionLabsReferenceAssemblyAnnotatorVersion>
<XunitAnalyzersVersion>1.16.0</XunitAnalyzersVersion>
<XunitV2Version>2.9.2-pre.2</XunitV2Version>
<XunitV3Version>0.5.0-pre.12</XunitV3Version>
<XunitV2Version>2.9.2</XunitV2Version>
<XunitV3Version>0.5.0-pre.26</XunitV3Version>
</PropertyGroup>

</Project>
16 changes: 15 additions & 1 deletion src/xunit.runner.visualstudio/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
using System.Diagnostics.CodeAnalysis;
using Xunit.Runner.Common;

// This is the default list of runner reporters, copied from xunit.v3.core's package

[assembly: RegisterRunnerReporter(typeof(AppVeyorReporter))]
[assembly: RegisterRunnerReporter(typeof(DefaultRunnerReporter))]
[assembly: RegisterRunnerReporter(typeof(JsonReporter))]
[assembly: RegisterRunnerReporter(typeof(QuietReporter))]
[assembly: RegisterRunnerReporter(typeof(SilentReporter))]
[assembly: RegisterRunnerReporter(typeof(TeamCityReporter))]
[assembly: RegisterRunnerReporter(typeof(VerboseReporter))]
[assembly: RegisterRunnerReporter(typeof(VstsReporter))]

// This is not targeted for assemblies in .NET Framework, but when it's seen on an assembly for code coverage
// purposes it'll still be honored, so we redefine it here and disable CS0436 at the project level so that
// the project will still build properly.

[assembly: System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[assembly: ExcludeFromCodeCoverage]

#if NETFRAMEWORK
namespace System.Diagnostics.CodeAnalysis
Expand Down
33 changes: 9 additions & 24 deletions src/xunit.runner.visualstudio/VsTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ async Task<bool> DiscoverTestsInAssembly<TVisitor>(
try
{
var diagnosticMessageSink = new DiagnosticMessageSink(logger, fileName, showDiagnostics: assembly.Configuration.DiagnosticMessagesOrDefault, showInternalDiagnostics: assembly.Configuration.InternalDiagnosticMessagesOrDefault);
var reporterMessageHandler = await GetRunnerReporter(logger, runSettings, [assembly.AssemblyFileName]).CreateMessageHandler(new VisualStudioRunnerLogger(logger), diagnosticMessageSink);
var reporterMessageHandler = await GetRunnerReporter(logger, runSettings).CreateMessageHandler(new VisualStudioRunnerLogger(logger), diagnosticMessageSink);
fileName = Path.GetFileNameWithoutExtension(assembly.AssemblyFileName);

if (!PlatformAssemblies.Contains(Path.GetFileName(assembly.AssemblyFileName)))
Expand Down Expand Up @@ -304,38 +304,23 @@ async Task<bool> DiscoverTestsInAssembly<TVisitor>(
return true;
}

public static IReadOnlyList<IRunnerReporter> GetAvailableRunnerReporters(
LoggerHelper? logger,
IReadOnlyList<string> sources)
public static IReadOnlyList<IRunnerReporter> GetAvailableRunnerReporters(LoggerHelper? logger)
{
var result = new List<IRunnerReporter>();
var folders =
sources
.Select(s => Path.GetDirectoryName(Path.GetFullPath(s)))
.WhereNotNull()
.Distinct();

var first = true;
foreach (var folder in folders)
{
result.AddRange(RunnerReporterUtility.GetAvailableRunnerReporters(folder, includeEmbeddedReporters: first, out var messages));
first = false;
var result = RegisteredRunnerReporters.Get(typeof(VsTestRunner).Assembly, out var messages);

if (logger is not null)
foreach (var message in messages)
logger.LogWarning("{0}", message);
}
if (logger is not null)
foreach (var message in messages)
logger.LogWarning("{0}", message);

return result;
}

public static IRunnerReporter GetRunnerReporter(
LoggerHelper? logger,
RunSettings runSettings,
IReadOnlyList<string> assemblyFileNames)
RunSettings runSettings)
{
var reporter = default(IRunnerReporter);
var availableReporters = new Lazy<IReadOnlyList<IRunnerReporter>>(() => GetAvailableRunnerReporters(logger, assemblyFileNames));
var availableReporters = new Lazy<IReadOnlyList<IRunnerReporter>>(() => GetAvailableRunnerReporters(logger));

try
{
Expand Down Expand Up @@ -463,7 +448,7 @@ async Task RunTests(
var parallelizeAssemblies = runInfos.All(runInfo => runInfo.Assembly.Configuration.ParallelizeAssemblyOrDefault);
var diagnosticMessages = runInfos.Any(runInfo => runInfo.Assembly.Configuration.DiagnosticMessagesOrDefault);
var internalDiagnosticMessages = runInfos.Any(runInfo => runInfo.Assembly.Configuration.InternalDiagnosticMessagesOrDefault);
var reporter = GetRunnerReporter(logger, runSettings, runInfos.Select(ari => ari.Assembly.AssemblyFileName).WhereNotNull().ToList());
var reporter = GetRunnerReporter(logger, runSettings);
var diagnosticMessageSink = new DiagnosticMessageSink(logger, showDiagnostics: diagnosticMessages, showInternalDiagnostics: internalDiagnosticMessages);
await using var reporterMessageHandler = await reporter.CreateMessageHandler(new VisualStudioRunnerLogger(logger), diagnosticMessageSink);

Expand Down
8 changes: 4 additions & 4 deletions test/test.xunit.runner.visualstudio/RunnerReporterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void WhenNotUsingAutoReporters_ChoosesDefault()
using var _ = EnvironmentHelper.NullifyEnvironmentalReporters();
var settings = new RunSettings { NoAutoReporters = true };

var runnerReporter = VsTestRunner.GetRunnerReporter(null, settings, [typeof(RunnerReporterTests).Assembly.Location]);
var runnerReporter = VsTestRunner.GetRunnerReporter(null, settings);

Assert.Equal(typeof(DefaultRunnerReporter).AssemblyQualifiedName, runnerReporter.GetType().AssemblyQualifiedName);
}
Expand All @@ -26,7 +26,7 @@ public void WhenUsingAutoReporters_DoesNotChooseDefault()
Environment.SetEnvironmentVariable("TEAMCITY_PROJECT_NAME", "foo"); // Force TeamCityReporter to surface environmentally
var settings = new RunSettings { NoAutoReporters = false };

var runnerReporter = VsTestRunner.GetRunnerReporter(null, settings, [typeof(RunnerReporterTests).Assembly.Location]);
var runnerReporter = VsTestRunner.GetRunnerReporter(null, settings);

Assert.Equal(typeof(TeamCityReporter).AssemblyQualifiedName, runnerReporter.GetType().AssemblyQualifiedName);
}
Expand All @@ -37,7 +37,7 @@ public void WhenUsingReporterSwitch_PicksThatReporter()
using var _ = EnvironmentHelper.NullifyEnvironmentalReporters();
var settings = new RunSettings { NoAutoReporters = true, ReporterSwitch = "json" };

var runnerReporter = VsTestRunner.GetRunnerReporter(null, settings, [typeof(RunnerReporterTests).Assembly.Location]);
var runnerReporter = VsTestRunner.GetRunnerReporter(null, settings);

Assert.Equal(typeof(JsonReporter).AssemblyQualifiedName, runnerReporter.GetType().AssemblyQualifiedName);
}
Expand All @@ -50,7 +50,7 @@ public void WhenRequestedReporterDoesntExist_LogsAndFallsBack()
var logger = Substitute.For<IMessageLogger>();
var loggerHelper = new LoggerHelper(logger, new Stopwatch());

var runnerReporter = VsTestRunner.GetRunnerReporter(loggerHelper, settings, [typeof(RunnerReporterTests).Assembly.Location]);
var runnerReporter = VsTestRunner.GetRunnerReporter(loggerHelper, settings);


Assert.Equal(typeof(DefaultRunnerReporter).AssemblyQualifiedName, runnerReporter.GetType().AssemblyQualifiedName);
Expand Down

0 comments on commit 8174918

Please sign in to comment.