Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send supported protocol version to the testing platform #43003

Merged
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
2 changes: 1 addition & 1 deletion src/Cli/dotnet/commands/dotnet-test/CliConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal static class HandshakeInfoPropertyNames
internal const byte Architecture = 1;
internal const byte Framework = 2;
internal const byte OS = 3;
internal const byte ProtocolVersion = 4;
internal const byte SupportedProtocolVersions = 4;
internal const byte HostType = 5;
internal const byte ModulePath = 6;
internal const byte ExecutionId = 7;
Expand Down
19 changes: 16 additions & 3 deletions src/Cli/dotnet/commands/dotnet-test/TestApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private Task<IResponse> OnRequest(IRequest request)
{
OnHandshakeInfo(handshakeInfo);

return Task.FromResult((IResponse)CreateHandshakeInfo());
return Task.FromResult((IResponse)CreateHandshakeInfo(GetSupportedProtocolVersion(handshakeInfo)));
}
break;

Expand Down Expand Up @@ -155,14 +155,27 @@ private Task<IResponse> OnRequest(IRequest request)
return Task.FromResult((IResponse)VoidResponse.CachedInstance);
}

private static HandshakeInfo CreateHandshakeInfo() =>
private static string GetSupportedProtocolVersion(HandshakeInfo handshakeInfo)
{
handshakeInfo.Properties.TryGetValue(HandshakeInfoPropertyNames.SupportedProtocolVersions, out string protocolVersions);

string version = string.Empty;
if (protocolVersions is not null && protocolVersions.Split(";").Contains(ProtocolConstants.Version))
{
version = ProtocolConstants.Version;
}

return version;
}

private static HandshakeInfo CreateHandshakeInfo(string version) =>
new(new Dictionary<byte, string>
{
{ HandshakeInfoPropertyNames.PID, Process.GetCurrentProcess().Id.ToString() },
{ HandshakeInfoPropertyNames.Architecture, RuntimeInformation.OSArchitecture.ToString() },
{ HandshakeInfoPropertyNames.Framework, RuntimeInformation.FrameworkDescription },
{ HandshakeInfoPropertyNames.OS, RuntimeInformation.OSDescription },
{ HandshakeInfoPropertyNames.ProtocolVersion, ProtocolConstants.Version }
{ HandshakeInfoPropertyNames.SupportedProtocolVersions, version }
});

private async Task<int> StartProcess(ProcessStartInfo processStartInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ private void OnTestResultReceived(object sender, EventArgs args)
{
var successfulTestResultMessage = successfulTestResultEventArgs.SuccessfulTestResultMessage;
VSTestTrace.SafeWriteTrace(() => $"TestResultMessage: {successfulTestResultMessage.Uid}, {successfulTestResultMessage.DisplayName}, " +
$"{successfulTestResultMessage.State}, {successfulTestResultMessage.Reason}, {successfulTestResultMessage.SessionUid}");
$"{successfulTestResultMessage.State}, {successfulTestResultMessage.Reason}, {successfulTestResultMessage.SessionUid}, {successfulTestResultMessage.ExecutionId}");
}
else if (args is FailedTestResultEventArgs failedTestResultEventArgs)
{
var failedTestResultMessage = failedTestResultEventArgs.FailedTestResultMessage;
VSTestTrace.SafeWriteTrace(() => $"TestResultMessage: {failedTestResultMessage.Uid}, {failedTestResultMessage.DisplayName}, " +
$"{failedTestResultMessage.State}, {failedTestResultMessage.Reason}, {failedTestResultMessage.ErrorMessage}," +
$" {failedTestResultMessage.ErrorStackTrace}, {failedTestResultMessage.SessionUid}");
$" {failedTestResultMessage.ErrorStackTrace}, {failedTestResultMessage.SessionUid}, {failedTestResultMessage.ExecutionId}");
}
}

Expand All @@ -204,7 +204,7 @@ private void OnFileArtifactInfoReceived(object sender, FileArtifactInfoEventArgs
var fileArtifactInfo = args.FileArtifactInfo;
VSTestTrace.SafeWriteTrace(() => $"FileArtifactInfo: {fileArtifactInfo.FullPath}, {fileArtifactInfo.DisplayName}, " +
$"{fileArtifactInfo.Description}, {fileArtifactInfo.TestUid}, {fileArtifactInfo.TestDisplayName}, " +
$"{fileArtifactInfo.SessionUid}");
$"{fileArtifactInfo.SessionUid}, {fileArtifactInfo.ExecutionId}");
}

private void OnSessionEventReceived(object sender, SessionEventArgs args)
Expand All @@ -215,7 +215,7 @@ private void OnSessionEventReceived(object sender, SessionEventArgs args)
}

var sessionEvent = args.SessionEvent;
VSTestTrace.SafeWriteTrace(() => $"TestSessionEvent: {sessionEvent.SessionType}, {sessionEvent.SessionUid}");
VSTestTrace.SafeWriteTrace(() => $"TestSessionEvent: {sessionEvent.SessionType}, {sessionEvent.SessionUid}, {sessionEvent.ExecutionId}");
}

private void OnErrorReceived(object sender, ErrorEventArgs args)
Expand Down
Loading