Skip to content
Merged
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 @@ -2,6 +2,8 @@
Microsoft.Testing.Platform.OutputDevice.FormattedTextOutputDeviceData.Padding.get -> int?
Microsoft.Testing.Platform.OutputDevice.FormattedTextOutputDeviceData.Padding.init -> void
[TPEXP]Microsoft.Testing.Platform.Capabilities.TestFramework.TestFrameworkCapabilitiesExtensions
[TPEXP]Microsoft.Testing.Platform.Requests.IExecuteRequestCompletionNotifier
[TPEXP]Microsoft.Testing.Platform.Requests.IExecuteRequestCompletionNotifier.Complete() -> void
[TPEXP]Microsoft.Testing.Platform.Services.IClientInfo
[TPEXP]Microsoft.Testing.Platform.Services.IClientInfo.Id.get -> string!
[TPEXP]Microsoft.Testing.Platform.Services.IClientInfo.Version.get -> string!
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Diagnostics.CodeAnalysis;

namespace Microsoft.Testing.Platform.Requests;

[Experimental("TPEXP", UrlFormat = "https://aka.ms/testingplatform/diagnostics#{0}")]
public interface IExecuteRequestCompletionNotifier
{
void Complete();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.Testing.Platform.Requests;

internal sealed class SemaphoreSlimRequestCompleteNotifier : IExecuteRequestCompletionNotifier
{
private readonly SemaphoreSlim _semaphore;

public SemaphoreSlimRequestCompleteNotifier(SemaphoreSlim semaphore)
{
_semaphore = semaphore;
}

public void Complete()
=> _semaphore.Release();
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task ExecuteAsync(ITestFramework testFramework, ClientInfo client,
public virtual async Task ExecuteRequestAsync(ITestFramework testFramework, TestExecutionRequest request, IMessageBus messageBus, CancellationToken cancellationToken)
{
using SemaphoreSlim requestSemaphore = new(0, 1);
await testFramework.ExecuteRequestAsync(new(request, messageBus, requestSemaphore, cancellationToken));
await testFramework.ExecuteRequestAsync(new(request, messageBus, new SemaphoreSlimRequestCompleteNotifier(requestSemaphore), cancellationToken));
await requestSemaphore.WaitAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#pragma warning disable RS0016 // Add public types and members to the declared API

using System.Diagnostics.CodeAnalysis;

using Microsoft.Testing.Platform.Messages;
using Microsoft.Testing.Platform.Requests;

Expand All @@ -14,14 +18,15 @@ namespace Microsoft.Testing.Platform.Extensions.TestFramework;
/// </remarks>
public sealed class ExecuteRequestContext
{
private readonly SemaphoreSlim _semaphore;
private readonly IExecuteRequestCompletionNotifier _executeRequestCompletionNotifier;

internal ExecuteRequestContext(IRequest request, IMessageBus messageBus, SemaphoreSlim semaphore,
[Experimental("TPEXP", UrlFormat = "https://aka.ms/testingplatform/diagnostics#{0}")]
public ExecuteRequestContext(IRequest request, IMessageBus messageBus, IExecuteRequestCompletionNotifier executeRequestCompletionNotifier,
CancellationToken cancellationToken)
{
Request = request;
MessageBus = messageBus;
_semaphore = semaphore;
_executeRequestCompletionNotifier = executeRequestCompletionNotifier;
CancellationToken = cancellationToken;
}

Expand All @@ -44,5 +49,5 @@ internal ExecuteRequestContext(IRequest request, IMessageBus messageBus, Semapho
/// Completes the execution request.
/// </summary>
public void Complete()
=> _semaphore.Release();
=> _executeRequestCompletionNotifier.Complete();
}