Skip to content

Commit

Permalink
Update dotnet test protocol messages (#43226)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariam-abdulla committed Sep 9, 2024
1 parent 918e835 commit 8d10b56
Show file tree
Hide file tree
Showing 27 changed files with 927 additions and 655 deletions.
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 @@ -35,7 +35,7 @@ internal static class SessionEventTypes
internal const byte TestSessionEnd = 1;
}

internal static class HandshakeInfoPropertyNames
internal static class HandshakeMessagePropertyNames
{
internal const byte PID = 0;
internal const byte Architecture = 1;
Expand Down
33 changes: 18 additions & 15 deletions src/Cli/dotnet/commands/dotnet-test/CustomEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.DotNet.Tools.Test;

namespace Microsoft.DotNet.Cli
{
internal class HandshakeInfoArgs : EventArgs
internal class HandshakeArgs : EventArgs
{
public HandshakeInfo handshakeInfo { get; set; }
public Handshake Handshake { get; set; }
}

internal class HelpEventArgs : EventArgs
{
public CommandLineOptionMessages CommandLineOptionMessages { get; set; }
public string ModulePath { get; set; }

public CommandLineOption[] CommandLineOptions { get; set; }
}

internal class DiscoveredTestEventArgs : EventArgs
{
public DiscoveredTestMessage DiscoveredTestMessage { get; set; }
}
public string ExecutionId { get; set; }

internal class SuccessfulTestResultEventArgs : EventArgs
{
public SuccessfulTestResultMessage SuccessfulTestResultMessage { get; set; }
public DiscoveredTest[] DiscoveredTests { get; set; }
}

internal class FailedTestResultEventArgs : EventArgs
internal class TestResultEventArgs : EventArgs
{
public FailedTestResultMessage FailedTestResultMessage { get; set; }
public string ExecutionId { get; set; }

public SuccessfulTestResult[] SuccessfulTestResults { get; set; }

public FailedTestResult[] FailedTestResults { get; set; }
}

internal class FileArtifactInfoEventArgs : EventArgs
internal class FileArtifactEventArgs : EventArgs
{
public FileArtifactInfo FileArtifactInfo { get; set; }
public string ExecutionId { get; set; }

public FileArtifact[] FileArtifacts { get; set; }
}

internal class SessionEventArgs : EventArgs
{
public TestSessionEvent SessionEvent { get; set; }
public TestSession SessionEvent { get; set; }
}

internal class ErrorEventArgs : EventArgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.DotNet.Tools.Test
{
internal sealed record CommandLineOptionMessage(string? Name, string? Description, bool? IsHidden, bool? IsBuiltIn) : IRequest;
internal sealed record CommandLineOptionMessage(string? Name, string? Description, bool? IsHidden, bool? IsBuiltIn);

internal sealed record CommandLineOptionMessages(string? ModulePath, CommandLineOptionMessage[]? CommandLineOptionMessageList) : IRequest;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@

namespace Microsoft.DotNet.Tools.Test
{
internal sealed record DiscoveredTestMessage(string? Uid, string? DisplayName, string? ExecutionId) : IRequest;
internal sealed record DiscoveredTestMessage(string? Uid, string? DisplayName);

internal sealed record DiscoveredTestMessages(string? ExecutionId, DiscoveredTestMessage[] DiscoveredMessages) : IRequest;
}

This file was deleted.

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

#nullable enable

namespace Microsoft.DotNet.Tools.Test
{
internal sealed record FileArtifactMessage(string? FullPath, string? DisplayName, string? Description, string? TestUid, string? TestDisplayName, string? SessionUid);

internal sealed record FileArtifactMessages(string? ExecutionId, FileArtifactMessage[] FileArtifacts) : IRequest;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

namespace Microsoft.DotNet.Tools.Test
{
internal sealed record HandshakeInfo(Dictionary<byte, string>? Properties) : IRequest, IResponse;
internal sealed record HandshakeMessage(Dictionary<byte, string>? Properties) : IRequest, IResponse;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

namespace Microsoft.DotNet.Tools.Test;

internal sealed record Module(string? DLLPath, string? ProjectPath, string? TargetFramework) : IRequest;
internal sealed record ModuleMessage(string? DLLPath, string? ProjectPath, string? TargetFramework) : IRequest;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

namespace Microsoft.DotNet.Tools.Test
{
internal sealed record SuccessfulTestResultMessage(string? Uid, string? DisplayName, byte? State, string? Reason, string? SessionUid, string? ExecutionId) : IRequest;
internal sealed record SuccessfulTestResultMessage(string? Uid, string? DisplayName, byte? State, string? Reason, string? SessionUid);

internal sealed record FailedTestResultMessage(string? Uid, string? DisplayName, byte? State, string? Reason, string? ErrorMessage, string? ErrorStackTrace, string? SessionUid, string? ExecutionId) : IRequest;
internal sealed record FailedTestResultMessage(string? Uid, string? DisplayName, byte? State, string? Reason, string? ErrorMessage, string? ErrorStackTrace, string? SessionUid);

internal sealed record TestResultMessages(string? ExecutionId, SuccessfulTestResultMessage[] SuccessfulTestMessages, FailedTestResultMessage[] FailedTestMessages) : IRequest;
}
40 changes: 26 additions & 14 deletions src/Cli/dotnet/commands/dotnet-test/IPC/ObjectFieldIds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,66 +43,78 @@ internal static class ModuleFieldsId
public const int MessagesSerializerId = 4;
}

internal static class DiscoveredTestMessageFieldsId
internal static class DiscoveredTestMessagesFieldsId
{
public const int MessagesSerializerId = 5;

public const ushort ExecutionId = 1;
public const ushort DiscoveredTestMessageList = 2;
}

internal static class DiscoveredTestMessageFieldsId
{
public const ushort Uid = 1;
public const ushort DisplayName = 2;
public const ushort ExecutionId = 3;
}


internal static class SuccessfulTestResultMessageFieldsId
internal static class TestResultMessagesFieldsId
{
public const int MessagesSerializerId = 6;

public const ushort ExecutionId = 1;
public const ushort SuccessfulTestMessageList = 2;
public const ushort FailedTestMessageList = 3;
}

internal static class SuccessfulTestResultMessageFieldsId
{
public const ushort Uid = 1;
public const ushort DisplayName = 2;
public const ushort State = 3;
public const ushort Reason = 4;
public const ushort SessionUid = 5;
public const ushort ExecutionId = 6;
}

internal static class FailedTestResultMessageFieldsId
{
public const int MessagesSerializerId = 7;

public const ushort Uid = 1;
public const ushort DisplayName = 2;
public const ushort State = 3;
public const ushort Reason = 4;
public const ushort ErrorMessage = 5;
public const ushort ErrorStackTrace = 6;
public const ushort SessionUid = 7;
public const ushort ExecutionId = 8;
}

internal static class FileArtifactInfoFieldsId
internal static class FileArtifactMessagesFieldsId
{
public const int MessagesSerializerId = 8;
public const int MessagesSerializerId = 7;

public const ushort ExecutionId = 1;
public const ushort FileArtifactMessageList = 2;
}

internal static class FileArtifactMessageFieldsId
{
public const ushort FullPath = 1;
public const ushort DisplayName = 2;
public const ushort Description = 3;
public const ushort TestUid = 4;
public const ushort TestDisplayName = 5;
public const ushort SessionUid = 6;
public const ushort ExecutionId = 7;
}

internal static class TestSessionEventFieldsId
{
public const int MessagesSerializerId = 9;
public const int MessagesSerializerId = 8;

public const ushort SessionType = 1;
public const ushort SessionUid = 2;
public const ushort ExecutionId = 3;
}

internal static class HandshakeInfoFieldsId
internal static class HandshakeMessageFieldsId
{
public const int MessagesSerializerId = 10;
public const int MessagesSerializerId = 9;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ namespace Microsoft.DotNet.Tools.Test
|---CommandLineOptionMessageList[0] FieldCount---| 2 bytes
|---CommandLineOptionMessageList[0] Name Id---| (2 bytes)
|---CommandLineOptionMessageList[0] Name Size---| (4 bytes)
|---CommandLineOptionMessageList[0] Name Value---| (n bytes)
|---CommandLineOptionMessageList[0].Name Id---| (2 bytes)
|---CommandLineOptionMessageList[0].Name Size---| (4 bytes)
|---CommandLineOptionMessageList[0].Name Value---| (n bytes)
|---CommandLineOptionMessageList[1] Description Id---| (2 bytes)
|---CommandLineOptionMessageList[1] Description Size---| (4 bytes)
|---CommandLineOptionMessageList[1] Description Value---| (n bytes)
|---CommandLineOptionMessageList[0].Description Id---| (2 bytes)
|---CommandLineOptionMessageList[0].Description Size---| (4 bytes)
|---CommandLineOptionMessageList[0].Description Value---| (n bytes)
|---CommandLineOptionMessageList[3] IsHidden Id---| (2 bytes)
|---CommandLineOptionMessageList[3] IsHidden Size---| (4 bytes)
|---CommandLineOptionMessageList[3] IsHidden Value---| (1 byte)
|---CommandLineOptionMessageList[0].IsHidden Id---| (2 bytes)
|---CommandLineOptionMessageList[0].IsHidden Size---| (4 bytes)
|---CommandLineOptionMessageList[0].IsHidden Value---| (1 byte)
|---CommandLineOptionMessageList[4] IsBuiltIn Id---| (2 bytes)
|---CommandLineOptionMessageList[4] IsBuiltIn Size---| (4 bytes)
|---CommandLineOptionMessageList[4] IsBuiltIn Value---| (1 byte)
|---CommandLineOptionMessageList[0].IsBuiltIn Id---| (2 bytes)
|---CommandLineOptionMessageList[0].IsBuiltIn Size---| (4 bytes)
|---CommandLineOptionMessageList[0].IsBuiltIn Value---| (1 byte)
*/

internal sealed class CommandLineOptionMessagesSerializer : BaseSerializer, INamedPipeSerializer
Expand Down Expand Up @@ -167,11 +167,12 @@ private static void WriteCommandLineOptionMessagesPayload(Stream stream, Command

private static ushort GetFieldCount(CommandLineOptionMessages commandLineOptionMessages) =>
(ushort)((commandLineOptionMessages.ModulePath is null ? 0 : 1) +
(commandLineOptionMessages is null ? 0 : 1));
(commandLineOptionMessages.CommandLineOptionMessageList is null ? 0 : 1));

private static ushort GetFieldCount(CommandLineOptionMessage commandLineOptionMessage) =>
(ushort)((commandLineOptionMessage.Name is null ? 0 : 1) +
(commandLineOptionMessage.Description is null ? 0 : 1) +
2);
(commandLineOptionMessage.IsHidden is null ? 0 : 1) +
(commandLineOptionMessage.IsBuiltIn is null ? 0 : 1));
}
}

This file was deleted.

Loading

0 comments on commit 8d10b56

Please sign in to comment.