Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 8 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,11 @@ jobs:
run: dotnet build -p:ContinuousIntegrationBuild=True --no-restore --configuration Release

- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
run: dotnet test --no-build --configuration Release --verbosity normal

- name: AOT Publish Validation
run: |
$rid = if ($env:RUNNER_OS -eq 'Windows') { 'win-x64' } else { 'linux-x64' }
dotnet publish TrxLib.AotSample/TrxLib.AotSample.csproj -r $rid -c Release --self-contained
$ext = if ($env:RUNNER_OS -eq 'Windows') { '.exe' } else { '' }
& "TrxLib.AotSample/bin/Release/net10.0/$rid/publish/TrxLib.AotSample$ext"
25 changes: 25 additions & 0 deletions TrxLib.AotSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using TrxLib;

// Write a minimal TRX to a temp file and actually parse it so the full
// XDocument path executes in the native binary.
const string minimalTrx =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<TestRun id=\"aot-smoke-run\" name=\"AOT Smoke Test\" " +
"xmlns=\"http://microsoft.com/schemas/VisualStudio/TeamTest/2010\">" +
"<Results /><TestDefinitions />" +
"</TestRun>";

var tempFile = Path.Combine(Path.GetTempPath(), $"aot-smoke-{Guid.NewGuid()}.trx");
try
{
File.WriteAllText(tempFile, minimalTrx, System.Text.Encoding.UTF8);
var result = TrxParser.Parse(new FileInfo(tempFile));
if (result.TestRunName != "AOT Smoke Test")
throw new InvalidOperationException($"Unexpected TestRunName: '{result.TestRunName}'");
Console.WriteLine("TrxLib AOT validation passed.");
}
finally
{
if (File.Exists(tempFile))
File.Delete(tempFile);
}
17 changes: 17 additions & 0 deletions TrxLib.AotSample/TrxLib.AotSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<PublishAot>true</PublishAot>
<IsPublishable>true</IsPublishable>
<IsPackable>false</IsPackable>
<!-- Suppress the "not published as AOT" info message during regular builds -->
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\TrxLib\TrxLib.csproj" />
</ItemGroup>

</Project>
34 changes: 34 additions & 0 deletions TrxLib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,54 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrxLib.AotSample", "TrxLib.AotSample\TrxLib.AotSample.csproj", "{DE43A469-7E38-4977-A886-688A387C5ED7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Debug|x64.ActiveCfg = Debug|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Debug|x64.Build.0 = Debug|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Debug|x86.ActiveCfg = Debug|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Debug|x86.Build.0 = Debug|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Release|Any CPU.Build.0 = Release|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Release|x64.ActiveCfg = Release|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Release|x64.Build.0 = Release|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Release|x86.ActiveCfg = Release|Any CPU
{A87CB29C-0A36-423F-B9B6-43053906A3CC}.Release|x86.Build.0 = Release|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Debug|x64.ActiveCfg = Debug|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Debug|x64.Build.0 = Debug|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Debug|x86.ActiveCfg = Debug|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Debug|x86.Build.0 = Debug|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Release|Any CPU.Build.0 = Release|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Release|x64.ActiveCfg = Release|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Release|x64.Build.0 = Release|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Release|x86.ActiveCfg = Release|Any CPU
{DF8F9490-887C-489E-AFE0-99518CC49ECF}.Release|x86.Build.0 = Release|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Debug|x64.ActiveCfg = Debug|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Debug|x64.Build.0 = Debug|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Debug|x86.ActiveCfg = Debug|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Debug|x86.Build.0 = Debug|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Release|Any CPU.Build.0 = Release|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Release|x64.ActiveCfg = Release|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Release|x64.Build.0 = Release|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Release|x86.ActiveCfg = Release|Any CPU
{DE43A469-7E38-4977-A886-688A387C5ED7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
55 changes: 55 additions & 0 deletions TrxLib/Counters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
namespace TrxLib;

/// <summary>
/// Represents the vstest-authoritative test run counters from the ResultSummary element.
/// </summary>
public class Counters
{
/// <summary>Gets or sets the total number of tests.</summary>
public int Total { get; set; }

/// <summary>Gets or sets the number of tests that were executed.</summary>
public int Executed { get; set; }

/// <summary>Gets or sets the number of tests that passed.</summary>
public int Passed { get; set; }

/// <summary>Gets or sets the number of tests that failed.</summary>
public int Failed { get; set; }

/// <summary>Gets or sets the number of tests that produced an error.</summary>
public int Error { get; set; }

/// <summary>Gets or sets the number of tests that timed out.</summary>
public int Timeout { get; set; }

/// <summary>Gets or sets the number of tests that were aborted.</summary>
public int Aborted { get; set; }

/// <summary>Gets or sets the number of tests that were inconclusive.</summary>
public int Inconclusive { get; set; }

/// <summary>Gets or sets the number of tests that passed but the run was aborted.</summary>
public int PassedButRunAborted { get; set; }

/// <summary>Gets or sets the number of tests that were not runnable.</summary>
public int NotRunnable { get; set; }

/// <summary>Gets or sets the number of tests that were not executed.</summary>
public int NotExecuted { get; set; }

/// <summary>Gets or sets the number of disconnected tests.</summary>
public int Disconnected { get; set; }

/// <summary>Gets or sets the number of tests that produced warnings.</summary>
public int Warning { get; set; }

/// <summary>Gets or sets the number of completed tests.</summary>
public int Completed { get; set; }

/// <summary>Gets or sets the number of tests in progress.</summary>
public int InProgress { get; set; }

/// <summary>Gets or sets the number of pending tests.</summary>
public int Pending { get; set; }
}
3 changes: 0 additions & 3 deletions TrxLib/Deployment.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Xml.Serialization;

namespace TrxLib;

/// <summary>
Expand All @@ -11,6 +9,5 @@ public class Deployment
/// <summary>
/// Gets or sets the root directory path where test run files are deployed.
/// </summary>
[XmlAttribute("runDeploymentRoot")]
public string? RunDeploymentRoot { get; set; }
}
4 changes: 0 additions & 4 deletions TrxLib/ErrorInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Xml.Serialization;

namespace TrxLib;

/// <summary>
Expand All @@ -11,13 +9,11 @@ public class ErrorInfo
/// <summary>
/// Gets or sets the error message describing why the test failed.
/// </summary>
[XmlElement("Message")]
public string? Message { get; set; }

/// <summary>
/// Gets or sets the stack trace information from the test failure.
/// Contains the call stack at the point of the exception that caused the test to fail.
/// </summary>
[XmlElement("StackTrace")]
public string? StackTrace { get; set; }
}
13 changes: 13 additions & 0 deletions TrxLib/Execution.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace TrxLib;

/// <summary>
/// Represents the Execution element inside a UnitTest definition.
/// Links the test definition to its execution record and result.
/// </summary>
public class Execution
{
/// <summary>
/// Gets or sets the execution identifier.
/// </summary>
public string? Id { get; set; }
}
4 changes: 0 additions & 4 deletions TrxLib/Output.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Xml.Serialization;

namespace TrxLib;

/// <summary>
Expand All @@ -12,12 +10,10 @@ public class Output
/// Gets or sets the error information if the test failed.
/// Contains the error message and stack trace details.
/// </summary>
[XmlElement("ErrorInfo")]
public ErrorInfo? ErrorInfo { get; set; }

/// <summary>
/// Gets or sets the standard output text captured during test execution.
/// </summary>
[XmlElement("StdOut")]
public string? StdOut { get; set; }
}
23 changes: 23 additions & 0 deletions TrxLib/ResultSummary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace TrxLib;

/// <summary>
/// Represents the ResultSummary element of a TRX file, containing the overall
/// outcome and vstest-authoritative test counters for the run.
/// </summary>
public class ResultSummary
{
/// <summary>
/// Gets or sets the overall outcome of the test run (e.g., "Passed", "Failed").
/// </summary>
public string? Outcome { get; set; }

/// <summary>
/// Gets or sets the authoritative test counters computed by vstest.
/// </summary>
public Counters? Counters { get; set; }

/// <summary>
/// Gets or sets the run-level output (e.g., stdout from the test host).
/// </summary>
public Output? Output { get; set; }
}
3 changes: 0 additions & 3 deletions TrxLib/Results.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Xml.Serialization;

namespace TrxLib;

/// <summary>
Expand All @@ -11,6 +9,5 @@ public class Results
/// <summary>
/// Gets or sets the list of unit test results from the test run.
/// </summary>
[XmlElement("UnitTestResult")]
public List<UnitTestResult>? UnitTestResults { get; set; }
}
3 changes: 0 additions & 3 deletions TrxLib/TestDefinitions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Xml.Serialization;

namespace TrxLib;

/// <summary>
Expand All @@ -11,6 +9,5 @@ public class TestDefinitions
/// <summary>
/// Gets or sets the list of unit test definitions.
/// </summary>
[XmlElement("UnitTest")]
public List<UnitTest>? UnitTests { get; set; }
}
10 changes: 10 additions & 0 deletions TrxLib/TestEntries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace TrxLib;

/// <summary>
/// Represents the TestEntries element, which indexes test definitions to their execution records.
/// </summary>
public class TestEntries
{
/// <summary>Gets or sets the collection of test entry records.</summary>
public List<TestEntry>? Items { get; set; }
}
16 changes: 16 additions & 0 deletions TrxLib/TestEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace TrxLib;

/// <summary>
/// Represents a single TestEntry that links a test definition to its execution record.
/// </summary>
public class TestEntry
{
/// <summary>Gets or sets the test definition identifier.</summary>
public string? TestId { get; set; }

/// <summary>Gets or sets the execution identifier.</summary>
public string? ExecutionId { get; set; }

/// <summary>Gets or sets the test list identifier this entry belongs to.</summary>
public string? TestListId { get; set; }
}
13 changes: 13 additions & 0 deletions TrxLib/TestList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace TrxLib;

/// <summary>
/// Represents a single TestList entry used to categorize test results.
/// </summary>
public class TestList
{
/// <summary>Gets or sets the name of the test list.</summary>
public string? Name { get; set; }

/// <summary>Gets or sets the unique identifier of the test list.</summary>
public string? Id { get; set; }
}
10 changes: 10 additions & 0 deletions TrxLib/TestLists.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace TrxLib;

/// <summary>
/// Represents the TestLists element containing the list categories for a test run.
/// </summary>
public class TestLists
{
/// <summary>Gets or sets the collection of test lists.</summary>
public List<TestList>? Items { get; set; }
}
6 changes: 0 additions & 6 deletions TrxLib/TestMethod.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Xml.Serialization;

namespace TrxLib;

/// <summary>
Expand All @@ -11,24 +9,20 @@ public class TestMethod
/// <summary>
/// Gets or sets the path to the assembly containing the test method.
/// </summary>
[XmlAttribute("codeBase")]
public string? CodeBase { get; set; }

/// <summary>
/// Gets or sets the fully qualified name of the class containing the test method.
/// </summary>
[XmlAttribute("className")]
public string? ClassName { get; set; }

/// <summary>
/// Gets or sets the name of the test method.
/// </summary>
[XmlAttribute("name")]
public string? Name { get; set; }

/// <summary>
/// Gets or sets the fully qualified name of the test adapter used to run the test.
/// </summary>
[XmlAttribute("adapterTypeName")]
public string? AdapterTypeName { get; set; }
}
Loading