Skip to content

Commit

Permalink
Move shared types from core to api assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Jan 1, 2025
1 parent f317ba4 commit 45a4ad7
Show file tree
Hide file tree
Showing 36 changed files with 144 additions and 54 deletions.
14 changes: 7 additions & 7 deletions NUnitConsole.sln
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit-agent-net60", "src\NU
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit-agent-net462", "src\NUnitEngine\agents\nunit-agent-net462\nunit-agent-net462.csproj", "{E4041712-A1F1-479D-A7F7-89F491066163}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit-agent-net462-x86", "src\NUnitEngine\agents\nunit-agent-net462-x86\nunit-agent-net462-x86.csproj", "{D4AE483A-D4E1-4892-AF87-3607FBA8755F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit-agent-net70", "src\NUnitEngine\agents\nunit-agent-net70\nunit-agent-net70.csproj", "{1343AB32-5FB0-408B-9BAC-B1483414D5D5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit4-console", "src\NUnitConsole\nunit4-console\nunit4-console.csproj", "{E1F5F8D3-4AC4-4BB0-9438-2BF41768B473}"
Expand Down Expand Up @@ -138,6 +136,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfTest", "src\TestData\wpf
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfApp", "src\TestData\WpfApp\WpfApp.csproj", "{93D182B7-2F63-4661-BB32-94F1716CF03F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit-agent-net462-x86", "src\NUnitEngine\agents\nunit-agent-net462-x86\nunit-agent-net462-x86.csproj", "{13A3360D-DD36-456B-80BD-E0A6BA15706F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -184,10 +184,6 @@ Global
{E4041712-A1F1-479D-A7F7-89F491066163}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4041712-A1F1-479D-A7F7-89F491066163}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E4041712-A1F1-479D-A7F7-89F491066163}.Release|Any CPU.Build.0 = Release|Any CPU
{D4AE483A-D4E1-4892-AF87-3607FBA8755F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D4AE483A-D4E1-4892-AF87-3607FBA8755F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D4AE483A-D4E1-4892-AF87-3607FBA8755F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D4AE483A-D4E1-4892-AF87-3607FBA8755F}.Release|Any CPU.Build.0 = Release|Any CPU
{1343AB32-5FB0-408B-9BAC-B1483414D5D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1343AB32-5FB0-408B-9BAC-B1483414D5D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1343AB32-5FB0-408B-9BAC-B1483414D5D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -240,6 +236,10 @@ Global
{93D182B7-2F63-4661-BB32-94F1716CF03F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{93D182B7-2F63-4661-BB32-94F1716CF03F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{93D182B7-2F63-4661-BB32-94F1716CF03F}.Release|Any CPU.Build.0 = Release|Any CPU
{13A3360D-DD36-456B-80BD-E0A6BA15706F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13A3360D-DD36-456B-80BD-E0A6BA15706F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13A3360D-DD36-456B-80BD-E0A6BA15706F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13A3360D-DD36-456B-80BD-E0A6BA15706F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -262,7 +262,6 @@ Global
{1704B7B2-5AD3-44EA-AB26-445C4E4E2C54} = {31B45C4C-206F-4F31-9CC6-33BF11DFEE39}
{D5CC541C-95B7-4CB4-AADD-660FDCC281B8} = {1704B7B2-5AD3-44EA-AB26-445C4E4E2C54}
{E4041712-A1F1-479D-A7F7-89F491066163} = {1704B7B2-5AD3-44EA-AB26-445C4E4E2C54}
{D4AE483A-D4E1-4892-AF87-3607FBA8755F} = {1704B7B2-5AD3-44EA-AB26-445C4E4E2C54}
{1343AB32-5FB0-408B-9BAC-B1483414D5D5} = {1704B7B2-5AD3-44EA-AB26-445C4E4E2C54}
{E1F5F8D3-4AC4-4BB0-9438-2BF41768B473} = {576DB1E6-C5EC-4FEF-A826-EC19D8BEE572}
{0D6B575A-93B4-4944-B4C0-68CDD413B904} = {576DB1E6-C5EC-4FEF-A826-EC19D8BEE572}
Expand All @@ -279,6 +278,7 @@ Global
{48DF1E40-93BA-436A-B460-5D1130316ADA} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{2F9D8932-2186-464F-BED6-7D7979C8FFA6} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{93D182B7-2F63-4661-BB32-94F1716CF03F} = {37D508B2-91E0-4B32-869B-DFF9E68EA213}
{13A3360D-DD36-456B-80BD-E0A6BA15706F} = {1704B7B2-5AD3-44EA-AB26-445C4E4E2C54}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D8E4FC26-5422-4C51-8BBC-D1AC0A578711}
Expand Down
12 changes: 6 additions & 6 deletions package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ StandardRunnerTests.Add(new PackageTest(

AddToBothLists(new PackageTest(
1, "Net60WPFTest", "Run test using WPF under .NET 6.0",
"testdata/net6.0-windows/WpfTest.dll --trace=Debug",
"testdata/net6.0-windows/WpfTest.dll",
new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-6.0") } }));

AddToBothLists(new PackageTest(
1, "Net80WPFTest", "Run test using WPF under .NET 8.0",
"testdata/net8.0-windows/WpfTest.dll --trace=Debug",
"testdata/net8.0-windows/WpfTest.dll",
new ExpectedResult("Passed") { Assemblies = new[] { new ExpectedAssemblyResult("WpfTest.dll", "netcore-8.0") } }));

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -265,7 +265,7 @@ StandardRunnerTests.Add(new PackageTest(
//StandardRunnerTests.Add(new PackageTest(
// 1, "VSProjectLoaderTest_Solution",
// "Run mock-assembly using the .sln file",
// "../../src/TestData/TestData.sln --config=Release --trace=Debug",
// "../../src/TestData/TestData.sln --config=Release",
// new ExpectedResult("Failed")
// {
// Total = 37 * 5,
Expand Down Expand Up @@ -337,7 +337,7 @@ StandardRunnerTests.Add(new PackageTest(
StandardRunnerTests.Add(new PackageTest(
1, "InvalidTestNameTest_Net462",
"Ensure we handle invalid test names correctly under .NET 4.6.2",
"testdata/net462/InvalidTestNames.dll --trace:Debug",
"testdata/net462/InvalidTestNames.dll",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
Expand All @@ -349,7 +349,7 @@ StandardRunnerTests.Add(new PackageTest(
AddToBothLists(new PackageTest(
1, "InvalidTestNameTest_Net60",
"Ensure we handle invalid test names correctly under .NET 6.0",
"testdata/net6.0/InvalidTestNames.dll --trace:Debug",
"testdata/net6.0/InvalidTestNames.dll",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
Expand All @@ -361,7 +361,7 @@ AddToBothLists(new PackageTest(
AddToBothLists(new PackageTest(
1, "InvalidTestNameTest_Net80",
"Ensure we handle invalid test names correctly under .NET 8.0",
"testdata/net8.0/InvalidTestNames.dll --trace:Debug",
"testdata/net8.0/InvalidTestNames.dll",
new ExpectedResult("Passed")
{
Assemblies = new ExpectedAssemblyResult[]
Expand Down
1 change: 1 addition & 0 deletions src/NUnitConsole/nunit4-console/ConsoleRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using NUnit.Engine.Extensibility;
using System.Runtime.InteropServices;
using System.Text;
using NUnit.Engine.Services;

namespace NUnit.ConsoleRunner
{
Expand Down
1 change: 0 additions & 1 deletion src/NUnitConsole/nunit4-console/nunit4-console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\NUnitEngine\nunit.engine.core\EnginePackageSettings.cs" Link="EnginePackageSettings.cs" />
<Compile Include="..\..\NUnitEngine\nunit.engine.core\Internal\ExceptionHelper.cs" Link="Utilities\ExceptionHelper.cs" />
<Content Include="..\..\..\nunit.ico" Link="nunit.ico" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/NUnitConsole/nunit4-netcore-console/ConsoleRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using NUnit.Engine.Extensibility;
using System.Runtime.InteropServices;
using System.Text;
using NUnit.Engine.Services;

namespace NUnit.ConsoleRunner
{
Expand Down
16 changes: 0 additions & 16 deletions src/NUnitEngine/agents/AgentExitCodes.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\AgentExitCodes.cs" Link="AgentExitCodes.cs" />
<Compile Include="..\Program.cs" Link="Program.cs" />
<Compile Include="..\..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>
Expand All @@ -49,9 +48,9 @@
</ItemGroup>

<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(ConsoleDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(ConsoleDestination)" Importance="High" />
<Message Text="Copied @(AgentFiles-&gt;Count()) files to $(ConsoleDestination)" Importance="High" />
<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(EngineDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(EngineDestination)" Importance="High" />
<Message Text="Copied @(AgentFiles-&gt;Count()) files to $(EngineDestination)" Importance="High" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\AgentExitCodes.cs" Link="AgentExitCodes.cs" />
<Compile Include="..\Program.cs" Link="Program.cs" />
<Compile Include="..\..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>
Expand All @@ -48,9 +47,9 @@
</ItemGroup>

<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(ConsoleDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(ConsoleDestination)" Importance="High" />
<Message Text="Copied @(AgentFiles-&gt;Count()) files to $(ConsoleDestination)" Importance="High" />
<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(EngineDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(EngineDestination)" Importance="High" />
<Message Text="Copied @(AgentFiles-&gt;Count()) files to $(EngineDestination)" Importance="High" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\AgentExitCodes.cs" Link="AgentExitCodes.cs" />
<Compile Include="..\Program.cs" Link="Program.cs" />
<Compile Include="..\..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\AgentExitCodes.cs" Link="AgentExitCodes.cs" />
<Compile Include="..\Program.cs" Link="Program.cs" />
<Compile Include="..\..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\AgentExitCodes.cs" Link="AgentExitCodes.cs" />
<Compile Include="..\Program.cs" Link="Program.cs" />
<Compile Include="..\..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\AgentExitCodes.cs" Link="AgentExitCodes.cs" />
<Compile Include="..\Program.cs" Link="Program.cs" />
<Compile Include="..\..\nunit.engine.core\Internal\ExceptionHelper.cs" Link="ExceptionHelper.cs" />
</ItemGroup>
Expand All @@ -50,9 +49,9 @@
</ItemGroup>

<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(ConsoleDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(ConsoleDestination)" Importance="High" />
<Message Text="Copied @(AgentFiles-&gt;Count()) files to $(ConsoleDestination)" Importance="High" />
<Copy SourceFiles="@(AgentFiles)" DestinationFiles="$(EngineDestination)%(FileName)%(Extension)" />
<Message Text="Copied @(AgentFiles->Count()) files to $(EngineDestination)" Importance="High" />
<Message Text="Copied @(AgentFiles-&gt;Count()) files to $(EngineDestination)" Importance="High" />
</Target>

</Project>
49 changes: 49 additions & 0 deletions src/NUnitEngine/nunit.engine.api/Agents/AgentExitCodes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Charlie Poole, Rob Prouse and Contributors. MIT License - see LICENSE.txt

namespace NUnit.Common
{
/// <summary>
/// Exit codes returned by all agents from test runs. A value
/// greater than zero indicates the number of test failures.
/// </summary>
public static class AgentExitCodes
{
/// <summary>
/// Tests ran without failure.
/// </summary>
public const int OK = 0;

/// <summary>
/// The process that created the agent terminated.
/// </summary>
public const int PARENT_PROCESS_TERMINATED = -1;

/// <summary>
/// Could no start a remote agent.
/// </summary>
public const int FAILED_TO_START_REMOTE_AGENT = -2;

/// <summary>
/// Security violation trying to launch the debugger.
/// </summary>
public const int DEBUGGER_SECURITY_VIOLATION = -3;

/// <summary>
/// Debugger is not available on current platform.
/// </summary>
public const int DEBUGGER_NOT_IMPLEMENTED = -4;

/// <summary>
/// Unable to locate the process that created the agent.
/// </summary>
public const int UNABLE_TO_LOCATE_AGENCY = -5;

/// <summary>
/// An unexpected exception terminated execution
/// </summary>
public const int UNEXPECTED_EXCEPTION = -100;

/// <summary></summary>
public const int STACK_OVERFLOW_EXCEPTION = -1073741571;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,37 @@ public class AsyncTestEngineResult : ITestRun
private readonly ManualResetEvent _waitHandle = new ManualResetEvent(false);

/// <summary>
/// Get the result of this run.
/// Get the result of this test run.
/// </summary>
/// <exception cref="InvalidOperationException">Cannot retrieve Result from an incomplete or cancelled TestRun.</exception>
public TestEngineResult EngineResult
{
get
{
Guard.OperationValid(_result != null, "Cannot retrieve Result from an incomplete or cancelled TestRun.");
if (_result == null)
throw new InvalidOperationException("Cannot retrieve Result from an incomplete or cancelled TestRun.");

return _result;
}
}

/// <summary>
/// Get a handle for use in waiting for the test run to complete.
/// </summary>
public EventWaitHandle WaitHandle
{
get { return _waitHandle; }
}

/// <summary>
/// Set the result of a completed test run.
/// </summary>
public void SetResult(TestEngineResult result)
{
Guard.ArgumentNotNull(result, "result");
Guard.OperationValid(_result == null, "Cannot set the Result of an TestRun more than once");
if (result == null) throw new ArgumentNullException(nameof (result));

if (_result != null)
throw new InvalidOperationException("Cannot set the Result of a TestRun more than once");

_result = result;
_waitHandle.Set();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@

namespace NUnit.Engine.Communication.Messages
{
/// <summary>
///
/// </summary>
[Serializable]
public class CommandMessage : TestEngineMessage
{
/// <summary>
///
/// </summary>
/// <param name="commandName"></param>
/// <param name="arguments"></param>
public CommandMessage(string commandName, params object[] arguments)
{
CommandName = commandName;
Arguments = arguments;
}

/// <summary>
///
/// </summary>
public string CommandName { get; }

/// <summary>
///
/// </summary>
public object[] Arguments { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@

namespace NUnit.Engine.Communication.Messages
{
/// <summary>
///
/// </summary>
[Serializable]
public class CommandReturnMessage : TestEngineMessage
{
/// <summary>
///
/// </summary>
/// <param name="returnValue"></param>
public CommandReturnMessage(object returnValue)
{
ReturnValue = returnValue;
}

/// <summary>
///
/// </summary>
public object ReturnValue { get; }
}
}
Loading

0 comments on commit 45a4ad7

Please sign in to comment.