Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Microsoft.Testing.Extensions.Hosting;
using Microsoft.Testing.Platform.Builder;
using Microsoft.Testing.Platform.Services;
using Microsoft.Testing.Platform.TestHost;

namespace Microsoft.Testing.Extensions;
Expand All @@ -18,5 +19,8 @@ public static class HotReloadExtensions
/// <param name="builder">The test application builder.</param>
public static void AddHotReloadProvider(this ITestApplicationBuilder builder)
=> ((TestHostManager)builder.TestHost).AddTestFrameworkInvoker(serviceProvider =>
new HotReloadTestHostTestFrameworkInvoker(serviceProvider));
new HotReloadTestHostTestFrameworkInvoker(
serviceProvider.GetEnvironment(),
serviceProvider.GetRuntimeFeature(),
serviceProvider));
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
{
private readonly bool _isHotReloadEnabled;

public HotReloadTestHostTestFrameworkInvoker(IServiceProvider serviceProvider)
public HotReloadTestHostTestFrameworkInvoker(IEnvironment environment, IRuntimeFeature runtimeFeature, IServiceProvider serviceProvider)
: base(serviceProvider)
{
_isHotReloadEnabled = IsHotReloadEnabled(serviceProvider.GetEnvironment());
_isHotReloadEnabled = IsHotReloadEnabled(environment);
if (_isHotReloadEnabled)
{
((SystemRuntimeFeature)serviceProvider.GetRuntimeFeature()).EnableHotReload();
((SystemRuntimeFeature)runtimeFeature).EnableHotReload();
}

Check failure on line 24 in src/Platform/Microsoft.Testing.Extensions.HotReload/HotReloadTestHostTestFrameworkInvoker.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/Platform/Microsoft.Testing.Extensions.HotReload/HotReloadTestHostTestFrameworkInvoker.cs#L24

src/Platform/Microsoft.Testing.Extensions.HotReload/HotReloadTestHostTestFrameworkInvoker.cs(24,10): error SA1513: (NETCORE_ENGINEERING_TELEMETRY=Build) Closing brace should be followed by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1513.md)
// IServiceProvider is kept for the base class and for lazy retrieval of services in ExecuteRequestAsync.
// Services like IOutputDevice, IConsole, IPlatformOutputDevice, and IMessageBus are not available yet during
// construction and must be retrieved later during test execution.
}

private static bool IsHotReloadEnabled(IEnvironment environment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ internal sealed class MSBuildConsumer : IDataConsumer, ITestSessionLifetimeHandl

public MSBuildConsumer(IServiceProvider serviceProvider, ICommandLineOptions commandLineOptions)
{
_serviceProvider = serviceProvider;
_commandLineOptions = commandLineOptions;
// IServiceProvider is kept for lazy retrieval of MSBuildTestApplicationLifecycleCallbacks in OnTestSessionStartingAsync.
// MSBuildTestApplicationLifecycleCallbacks is not available yet during construction and must be retrieved later.
_serviceProvider = serviceProvider;
}

public Type[] DataTypesConsumed { get; } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ internal sealed class RetryDataConsumer : IDataConsumer, ITestSessionLifetimeHan
private RetryLifecycleCallbacks? _retryFailedTestsLifecycleCallbacks;
private int _totalTests;

public RetryDataConsumer(IServiceProvider serviceProvider)
public RetryDataConsumer(ICommandLineOptions commandLineOptions, IServiceProvider serviceProvider)
{
_commandLineOptions = commandLineOptions;
// IServiceProvider is kept for lazy retrieval of RetryLifecycleCallbacks in InitializeAsync.
// RetryLifecycleCallbacks is not available yet during construction and must be retrieved later.
_serviceProvider = serviceProvider;
_commandLineOptions = _serviceProvider.GetCommandLineOptions();
}

public Type[] DataTypesConsumed => [typeof(TestNodeUpdateMessage)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ internal sealed class RetryExecutionFilterFactory : ITestExecutionFilterFactory
private readonly ICommandLineOptions _commandLineOptions;
private RetryLifecycleCallbacks? _retryFailedTestsLifecycleCallbacks;

public RetryExecutionFilterFactory(IServiceProvider serviceProvider)
public RetryExecutionFilterFactory(ICommandLineOptions commandLineOptions, IServiceProvider serviceProvider)
{
_commandLineOptions = commandLineOptions;
// IServiceProvider is kept for lazy retrieval of RetryLifecycleCallbacks in TryCreateAsync.
// RetryLifecycleCallbacks is not available yet during construction and must be retrieved later.
_serviceProvider = serviceProvider;
_commandLineOptions = serviceProvider.GetCommandLineOptions();
}

public string Uid => nameof(RetryExecutionFilterFactory);
Expand Down
17 changes: 13 additions & 4 deletions src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
builder.CommandLine.AddProvider(() => new RetryCommandLineOptionsProvider());

builder.TestHost.AddTestHostApplicationLifetime(serviceProvider
=> new RetryLifecycleCallbacks(serviceProvider));
=> new RetryLifecycleCallbacks(
serviceProvider.GetCommandLineOptions(),

Check failure on line 28 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L28

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(28,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L28

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(28,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L28

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(28,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L28

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(28,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L28

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(28,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)
serviceProvider));

CompositeExtensionFactory<RetryDataConsumer> compositeExtensionFactory
= new(serviceProvider => new RetryDataConsumer(serviceProvider));
= new(serviceProvider => new RetryDataConsumer(
serviceProvider.GetCommandLineOptions(),

Check failure on line 33 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L33

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(33,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L33

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(33,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L33

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(33,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L33

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(33,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L33

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(33,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)
serviceProvider));
builder.TestHost.AddDataConsumer(compositeExtensionFactory);
builder.TestHost.AddTestSessionLifetimeHandle(compositeExtensionFactory);

Expand All @@ -38,8 +42,13 @@

// Net yet exposed extension points
((TestHostOrchestratorManager)testApplicationBuilder.TestHostOrchestrator)
.AddTestHostOrchestrator(serviceProvider => new RetryOrchestrator(serviceProvider));
.AddTestHostOrchestrator(serviceProvider => new RetryOrchestrator(
serviceProvider.GetCommandLineOptions(),

Check failure on line 46 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L46

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(46,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 46 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L46

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(46,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 46 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L46

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(46,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 46 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L46

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(46,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 46 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L46

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(46,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)
serviceProvider.GetFileSystem(),

Check failure on line 47 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L47

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(47,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetFileSystem' and no accessible extension method 'GetFileSystem' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 47 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L47

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(47,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetFileSystem' and no accessible extension method 'GetFileSystem' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 47 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L47

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(47,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetFileSystem' and no accessible extension method 'GetFileSystem' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 47 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L47

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(47,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetFileSystem' and no accessible extension method 'GetFileSystem' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 47 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L47

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(47,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetFileSystem' and no accessible extension method 'GetFileSystem' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)
serviceProvider));
((TestHostManager)builder.TestHost)
.AddTestExecutionFilterFactory(serviceProvider => new RetryExecutionFilterFactory(serviceProvider));
.AddTestExecutionFilterFactory(serviceProvider => new RetryExecutionFilterFactory(
serviceProvider.GetCommandLineOptions(),

Check failure on line 51 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build MacOS Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L51

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(51,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Debug)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L51

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(51,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 51 in src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs

View check run for this annotation

Azure Pipelines / microsoft.testfx (Build Linux Release)

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs#L51

src/Platform/Microsoft.Testing.Extensions.Retry/RetryExtensions.cs(51,33): error CS1061: (NETCORE_ENGINEERING_TELEMETRY=Build) 'IServiceProvider' does not contain a definition for 'GetCommandLineOptions' and no accessible extension method 'GetCommandLineOptions' accepting a first argument of type 'IServiceProvider' could be found (are you missing a using directive or an assembly reference?)
serviceProvider));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ internal sealed class RetryFailedTestsPipeServer : IDisposable
private readonly PipeNameDescription _pipeNameDescription;
private readonly string[] _failedTests;

public RetryFailedTestsPipeServer(IServiceProvider serviceProvider, string[] failedTests, ILogger logger)
public RetryFailedTestsPipeServer(
IEnvironment environment,
ILoggerFactory loggerFactory,
ITask task,
ITestApplicationCancellationTokenSource cancellationTokenSource,
string[] failedTests,
ILogger logger)
{
_pipeNameDescription = NamedPipeServer.GetPipeName(Guid.NewGuid().ToString("N"), serviceProvider.GetEnvironment());
_pipeNameDescription = NamedPipeServer.GetPipeName(Guid.NewGuid().ToString("N"), environment);
logger.LogTrace($"Retry server pipe name: '{_pipeNameDescription.Name}'");
_singleConnectionNamedPipeServer = new NamedPipeServer(_pipeNameDescription, CallbackAsync,
serviceProvider.GetEnvironment(),
serviceProvider.GetLoggerFactory().CreateLogger<RetryFailedTestsPipeServer>(),
serviceProvider.GetTask(),
serviceProvider.GetTestApplicationCancellationTokenSource().CancellationToken);
environment,
loggerFactory.CreateLogger<RetryFailedTestsPipeServer>(),
task,
cancellationTokenSource.CancellationToken);

_singleConnectionNamedPipeServer.RegisterSerializer(new VoidResponseSerializer(), typeof(VoidResponse));
_singleConnectionNamedPipeServer.RegisterSerializer(new FailedTestRequestSerializer(), typeof(FailedTestRequest));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ internal sealed class RetryLifecycleCallbacks : ITestHostApplicationLifetime, ID
private readonly IServiceProvider _serviceProvider;
private readonly ICommandLineOptions _commandLineOptions;

public RetryLifecycleCallbacks(IServiceProvider serviceProvider)
public RetryLifecycleCallbacks(ICommandLineOptions commandLineOptions, IServiceProvider serviceProvider)
{
_commandLineOptions = commandLineOptions;
// IServiceProvider is kept for lazy retrieval of ILoggerFactory in BeforeRunAsync.
// ILoggerFactory is not available yet during construction and must be retrieved later.
_serviceProvider = serviceProvider;
_commandLineOptions = _serviceProvider.GetCommandLineOptions();
}

public NamedPipeClient? Client { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ internal sealed class RetryOrchestrator : ITestHostOrchestrator, IOutputDeviceDa
private readonly ICommandLineOptions _commandLineOptions;
private readonly IFileSystem _fileSystem;

public RetryOrchestrator(IServiceProvider serviceProvider)
public RetryOrchestrator(ICommandLineOptions commandLineOptions, IFileSystem fileSystem, IServiceProvider serviceProvider)
{
_commandLineOptions = commandLineOptions;
_fileSystem = fileSystem;
// IServiceProvider is kept for lazy retrieval of services in OrchestrateTestHostExecutionAsync.
// Services like IEnvironment, ILoggerFactory, IConfiguration, ITestApplicationModuleInfo, IOutputDevice, and IProcessHandler
// are not available yet during construction and must be retrieved later.
_serviceProvider = serviceProvider;
_commandLineOptions = _serviceProvider.GetCommandLineOptions();
_fileSystem = _serviceProvider.GetFileSystem();
}

public string Uid => nameof(RetryOrchestrator);
Expand Down Expand Up @@ -165,7 +168,13 @@ public async Task<int> OrchestrateTestHostExecutionAsync(CancellationToken cance
finalArguments.Add(currentTryResultFolder);

// Prepare the pipeserver
using RetryFailedTestsPipeServer retryFailedTestsPipeServer = new(_serviceProvider, lastListOfFailedId ?? [], logger);
using RetryFailedTestsPipeServer retryFailedTestsPipeServer = new(
_serviceProvider.GetEnvironment(),
_serviceProvider.GetLoggerFactory(),
_serviceProvider.GetTask(),
_serviceProvider.GetTestApplicationCancellationTokenSource(),
lastListOfFailedId ?? [],
logger);
finalArguments.Add($"--{RetryCommandLineOptionsProvider.RetryFailedTestsPipeNameOptionName}");
finalArguments.Add(retryFailedTestsPipeServer.PipeName);

Expand Down
Loading