Skip to content

Commit

Permalink
Merge pull request #145 from TestCentric/issue-142b
Browse files Browse the repository at this point in the history
Fix error in stoping under .NET Framework
  • Loading branch information
CharliePoole authored Aug 31, 2023
2 parents c111e66 + 3fb094e commit b486b70
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 14 deletions.
6 changes: 3 additions & 3 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ var EnginePackage = new NuGetPackage(
},
tests: packageTests,
preloadedExtensions: new [] {
new PackageReference("NUnit.Extension.Net462PluggableAgent", "2.1.0-dev00011"),
new PackageReference("NUnit.Extension.Net60PluggableAgent", "2.1.0-dev00019"),
new PackageReference("NUnit.Extension.Net70PluggableAgent", "2.1.0-dev00010") }
new PackageReference("NUnit.Extension.Net462PluggableAgent", "2.1.0-dev00013"),
new PackageReference("NUnit.Extension.Net60PluggableAgent", "2.1.0-dev00022"),
new PackageReference("NUnit.Extension.Net70PluggableAgent", "2.1.0-dev00012") }
);

var EngineCorePackage = new NuGetPackage(
Expand Down
25 changes: 22 additions & 3 deletions src/TestEngine/testcentric.engine.core/Agents/RemoteTestAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,41 @@ public RemoteTestAgent(Guid agentId)

public int ProcessId => System.Diagnostics.Process.GetCurrentProcess().Id;


/// <summary>
/// Starts the agent, performing any required initialization
/// </summary>
/// <returns><c>true</c> if the agent was started successfully.</returns>
public override bool Start()
{
Guard.OperationValid(Transport != null, "Transport must be set before calling Start().");
log.Debug("Starting");
return Transport.Start();
}

#if NETFRAMEWORK
// For remoting, the agent stops the transport, but for TCP the transport is stopped directly
/// <summary>
/// Stop the agent, releasing any resources
/// </summary>
/// <remarks>
/// Using the Remoting transport, the agent stops the transport. Using TCP
/// transport, the transport stops the agent.
/// </remarks>
public override void Stop()
{
log.Debug("Stopping");
#if NETFRAMEWORK
// For remoting, the agent stops the transport, but for TCP the transport is stopped directly
Transport.Stop();
}
#endif
StopSignal.Set();
}


/// <summary>
/// Creates a test runner for a TestPackage
/// </summary>
/// <param name="package">The TestPackage for which a runner is to be created</param>
/// <returns>An ITestEngineRunner</returns>
public override ITestEngineRunner CreateRunner(TestPackage package)
{
Console.WriteLine("Creating the runner");
Expand Down
4 changes: 3 additions & 1 deletion src/TestEngine/testcentric.engine.core/Agents/TestAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public virtual void Stop()
}

/// <summary>
/// Creates a test runner
/// Creates a test runner for a TestPackage
/// </summary>
/// <param name="package">The TestPackage for which a runner is to be created</param>
/// <returns>An ITestEngineRunner</returns>
public abstract ITestEngineRunner CreateRunner(TestPackage package);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public TestAgentRemotingTransport(RemoteTestAgent agent, string agencyUrl)

public TestAgent Agent { get; }

#region ITestAgent Implementation

public Guid Id => Agent.Id;

public bool Start()
Expand Down Expand Up @@ -99,11 +101,7 @@ public ITestEngineRunner CreateRunner(TestPackage package)
return this;
}

public void Dispose()
{
Agent.Dispose();
_runner.Dispose();
}
#endregion

#region ITestEngineRunner Implementation

Expand Down Expand Up @@ -185,6 +183,12 @@ public void ForcedStop()
_runner?.ForcedStop();
}

public void Dispose()
{
Agent.Dispose();
_runner.Dispose();
}

#endregion

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public bool Start()

public void Stop()
{
Agent.StopSignal.Set();
Agent.Stop();
}

public ITestEngineRunner CreateRunner(TestPackage package)
Expand Down
4 changes: 3 additions & 1 deletion src/TestEngine/testcentric.engine.core/ITestAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ public interface ITestAgent
void Stop();

/// <summary>
/// Creates a test runner
/// Creates a test runner for a TestPackage
/// </summary>
/// <param name="package">The TestPackage for which a runner is to be created</param>
/// <returns>An ITestEngineRunner</returns>
ITestEngineRunner CreateRunner(TestPackage package);
}
}

0 comments on commit b486b70

Please sign in to comment.