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

Remove all services from engine.core #1140

Merged
merged 6 commits into from
Feb 14, 2022
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
4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ Task("CreateZipImage")
var addinsDir = frameworkDir + "addins/";
CleanDirectory(addinsDir);

foreach (var packageDir in System.IO.Directory.GetDirectories(EXTENSIONS_DIR))
CopyPackageContents(packageDir, addinsDir);
//foreach (var packageDir in System.IO.Directory.GetDirectories(EXTENSIONS_DIR))
// CopyPackageContents(packageDir, addinsDir);
}
});

Expand Down
17 changes: 1 addition & 16 deletions src/NUnitEngine/nunit-agent/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using NUnit.Engine;
using NUnit.Engine.Agents;
using NUnit.Engine.Internal;
using NUnit.Engine.Services;

namespace NUnit.Agent
{
Expand Down Expand Up @@ -79,22 +78,8 @@ public static void Main(string[] args)
log.Info($"Running .NET 2.0 agent under {RuntimeFramework.CurrentFramework.DisplayName}");
#endif

// Create CoreEngine
var engine = new CoreEngine
{
WorkDirectory = workDirectory,
InternalTraceLevel = traceLevel
};

// Custom Service Initialization
engine.Services.Add(new ExtensionService());

// Initialize Services
log.Info("Initializing Services");
engine.InitializeServices();

log.Info("Starting RemoteTestAgent");
Agent = new RemoteTestAgent(engine.Services, AgentId);
Agent = new RemoteTestAgent(AgentId);
Agent.Transport =
#if NETFRAMEWORK
new Engine.Communication.Transports.Remoting.TestAgentRemotingTransport(Agent, AgencyUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void Initialize()
string.Empty,
false).ReturnsForAnyArgs(_driver);

_directTestRunner = new EmptyDirectTestRunner(new ServiceContext(), new TestPackage("mock-assembly.dll"));
_directTestRunner = new EmptyDirectTestRunner(new TestPackage("mock-assembly.dll"));
_directTestRunner.DriverService = driverService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ namespace NUnit.Engine.Tests.Runners.Fakes
{
internal class EmptyDirectTestRunner : Engine.Runners.DirectTestRunner
{
public EmptyDirectTestRunner(IServiceLocator services, TestPackage package) : base(services, package)
public EmptyDirectTestRunner(TestPackage package) : base(package)
{
TestDomain = AppDomain.CurrentDomain;
}

public new void LoadPackage()
public new void Load()
{
base.LoadPackage();
base.Load();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@

namespace NUnit.Engine.Runners.Tests
{
// TODO: This class now only tests those runners used by agents,
// defined in nunit.engine.core. We should create an equivalent
// test class in nunit.engine to handler the engine runners.

// Temporarily commenting out Process tests due to
// intermittent errors, probably due to the test
// fixture rather than the engine.
[TestFixture(typeof(LocalTestRunner))]
#if NETFRAMEWORK
[TestFixture(typeof(TestDomainRunner))]
//[TestFixture(typeof(ProcessRunner))]
[TestFixture(typeof(MultipleTestDomainRunner), 1)]
[TestFixture(typeof(MultipleTestDomainRunner), 3)]
#endif
//[TestFixture(typeof(MultipleTestProcessRunner), 1)]
//[TestFixture(typeof(MultipleTestProcessRunner), 3)]
//[Platform(Exclude = "Mono", Reason = "Currently causing long delays or hangs under Mono")]
public class TestEngineRunnerTests<TRunner> where TRunner : AbstractTestRunner
{
protected TestPackage _package;
protected ServiceContext _services;
protected TRunner _runner;

// Number of copies of mock-assembly to use in package
Expand All @@ -44,11 +45,6 @@ public TestEngineRunnerTests(int numAssemblies)
[SetUp]
public void Initialize()
{
// Add all services needed by any of our TestEngineRunners
_services = new ServiceContext();
_services.Add(new Services.ExtensionService());
_services.ServiceManager.StartServices();

var mockAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "mock-assembly.dll");

var assemblies = new List<string>();
Expand All @@ -59,18 +55,15 @@ public void Initialize()

_package = new TestPackage(assemblies);

// HACK: Depends on the fact that all TestEngineRunners support this constructor
_runner = (TRunner)Activator.CreateInstance(typeof(TRunner), _services, _package);
// HACK: Depends on the fact that all the runners we are testing here support this constructor
_runner = (TRunner)Activator.CreateInstance(typeof(TRunner), _package);
}

[TearDown]
public void Cleanup()
{
if (_runner != null)
_runner.Dispose();

if (_services != null)
_services.ServiceManager.Dispose();
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace NUnit.Engine.Services.Tests
[TestFixture]
public class DriverServiceTests
{
private DriverService _driverService;
private DriverFactory _driverService;

[SetUp]
public void CreateDriverFactory()
{
_driverService = new DriverService();
_driverService = new DriverFactory();
}

#if NET5_0_OR_GREATER
Expand Down
Loading