Skip to content
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
8 changes: 4 additions & 4 deletions KnownExtensions.cake
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public static class KnownExtensions
public static ExtensionSpecifier VSProjectLoader = new ExtensionSpecifier(
"NUnit.Extension.VSProjectLoader", "nunit-extension-vs-project-loader", "3.9.0");
public static ExtensionSpecifier NUnitV2ResultWriter = new ExtensionSpecifier(
"NUnit.Extension.NUnitV2ResultWriter", "nunit-extension-nunit-v2-result-writer", "4.0.0-dev.14");
"NUnit.Extension.NUnitV2ResultWriter", "nunit-extension-nunit-v2-result-writer", "4.0.0-beta.1");
public static ExtensionSpecifier TeamCityEventListener = new ExtensionSpecifier(
"NUnit.Extension.TeamCityEventListener", "nunit-extension-teamcity-event-listener", "1.0.9");
public static ExtensionSpecifier Net462PluggableAgent = new ExtensionSpecifier(
"NUnit.Extension.Net462PluggableAgent", "nunit-extension-net462-pluggable-agent", "4.1.0-alpha.5");
"NUnit.Extension.Net462PluggableAgent", "nunit-extension-net462-pluggable-agent", "4.1.1");
public static ExtensionSpecifier Net80PluggableAgent = new ExtensionSpecifier(
"NUnit.Extension.Net80PluggableAgent", "nunit-extension-net80-pluggable-agent", "4.1.0-alpha.6");
"NUnit.Extension.Net80PluggableAgent", "nunit-extension-net80-pluggable-agent", "4.1.1");
public static ExtensionSpecifier Net90PluggableAgent = new ExtensionSpecifier(
"NUnit.Extension.Net90PluggableAgent", "nunit-extension-net90-pluggable-agent", "4.1.0-alpha.4");
"NUnit.Extension.Net90PluggableAgent", "nunit-extension-net90-pluggable-agent", "4.1.0");

private static ExtensionSpecifier[] BundledAgents =>
[
Expand Down
13 changes: 11 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Load the recipe
#load nuget:?package=NUnit.Cake.Recipe&version=2.0.0-beta.1
#load nuget:?package=NUnit.Cake.Recipe&version=2.0.0-beta.3
// Comment out above line and uncomment below for local tests of recipe changes
//#load ../NUnit.Cake.Recipe/recipe/*.cake
//#load ../NUnit.Cake.Recipe/src/NUnit.Cake.Recipe/content/*.cake

// Load additional cake files
#load package-tests.cake
Expand Down Expand Up @@ -210,6 +210,15 @@ BuildSettings.Packages.AddRange(new PackageDefinition[] {
NUnitConsoleNuGetPackage
});

Task("BuildPackages")
.Description("Just build packages, without installing or running package tests")
.IsDependentOn("Build")
.Does(() =>
{
foreach (var package in BuildSettings.Packages)
package.BuildPackage();
});

//////////////////////////////////////////////////////////////////////
// CONSOLE PACKAGE TEST RUNNER
//////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ NetCoreRunnerTests.Add(new PackageTest(1, "ListResolutionStatistics_Run")
// Description = "Run NUnit project with mock-assembly.dll built for .NET 4.6.2 and 6.0",
// Arguments = "../../MixedTests.nunit --config=Release",
// ExpectedResult = new MockAssemblyExpectedResult("net-4.6.2", "net-6.0"),
// ExtensionsNeeded = new[] { Extensions.NUnitProjectLoader }
// ExtensionsNeeded = new[] { KnownExtensions.NUnitProjectLoader }
//});

//NetCoreRunnerTests.Add(new PackageTest(1, "NUnitProjectTest")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ public string Load(string testAssemblyPath, IDictionary<string, object> settings
/// <param name="listener">An ITestEventHandler that receives progress notices</param>
/// <param name="filter">A filter that controls which tests are executed</param>
/// <returns>An Xml string representing the result</returns>
public string Run(ITestEventListener? listener, string filter) => _api.Run(listener, filter);
public string Run(ITestEventListener? listener, string filter) =>
_api.Run(listener is not null ? new EventInterceptor(listener) : null, filter);

/// <summary>
/// Executes the tests in an assembly asynchronously.
Expand Down
3 changes: 2 additions & 1 deletion src/NUnitEngine/nunit.engine.api/TestPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public void AddSubPackage(TestPackage subPackage)
SubPackages.Add(subPackage);

foreach (var setting in Settings)
subPackage.AddSetting(setting);
if (!subPackage.Settings.HasSetting(setting.Name))
subPackage.AddSetting(setting);
}

/// <summary>
Expand Down
58 changes: 28 additions & 30 deletions src/NUnitEngine/nunit.engine/Services/ProjectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;

namespace NUnit.Engine.Services
{
Expand All @@ -16,6 +17,7 @@ namespace NUnit.Engine.Services
public class ProjectService : Service, IProjectService
{
private readonly Dictionary<string, ExtensionNode> _extensionIndex = new Dictionary<string, ExtensionNode>();
private ExtensionService? _extensionService;

public bool CanLoadFrom(string path)
{
Expand Down Expand Up @@ -49,7 +51,7 @@ public void ExpandProjectPackage(TestPackage package)
IProject project = LoadFrom(path).ShouldNotBeNull("Unable to load project " + path);

string? activeConfig = package.Settings.GetValueOrDefault(SettingDefinitions.ActiveConfig);
if (activeConfig is null)
if (string.IsNullOrEmpty(activeConfig))
activeConfig = project.ActiveConfigName;
else
Guard.ArgumentValid(project.ConfigNames.Contains(activeConfig), $"Requested configuration {activeConfig} was not found", nameof(package));
Expand All @@ -58,16 +60,14 @@ public void ExpandProjectPackage(TestPackage package)

// Add info about the configurations to the project package
tempPackage.AddSetting(SettingDefinitions.ActiveConfig.WithValue(activeConfig));
tempPackage.AddSetting(SettingDefinitions.ConfigNames.WithValue(new List<string>(project.ConfigNames).ToArray()));
tempPackage.AddSetting(SettingDefinitions.ConfigNames.WithValue(string.Join(";", project.ConfigNames.ToArray())));

// The original package held overrides, so don't change them, but
// do apply any settings specified within the project itself.
foreach (var setting in tempPackage.Settings)
{
if (package.Settings.HasSetting(setting.Name)) // Don't override settings from command line
continue;

package.Settings.Add(setting);
if (!package.Settings.HasSetting(setting.Name)) // Don't override settings from command line
package.Settings.Add(setting);
}

foreach (var subPackage in tempPackage.SubPackages)
Expand All @@ -90,33 +90,14 @@ public override void StartService()

try
{
var extensionService = ServiceContext.GetService<ExtensionService>();
_extensionService = ServiceContext.GetService<ExtensionService>();

if (extensionService is null)
if (_extensionService is null)
Status = ServiceStatus.Started;
else if (extensionService.Status != ServiceStatus.Started)
else if (_extensionService.Status != ServiceStatus.Started)
Status = ServiceStatus.Error;
else
{
Status = ServiceStatus.Started;

var extensionNodes = new List<ExtensionNode>();
extensionNodes.AddRange(extensionService.GetExtensionNodes<IProjectLoader>());

foreach (var node in extensionNodes)
{
foreach (string ext in node.GetValues("FileExtension"))
{
if (ext is not null)
{
if (_extensionIndex.ContainsKey(ext))
throw new NUnitEngineException($"ProjectLoader extension {ext} is already handled by another extension.");

_extensionIndex.Add(ext, node);
}
}
}
}
}
catch
{
Expand All @@ -125,6 +106,22 @@ public override void StartService()
}
}

private List<ExtensionNode>? _projectNodes;
private List<ExtensionNode> ProjectNodes
{
get
{
if (_projectNodes is null)
{
Guard.OperationValid(_extensionService is not null, "ProjectNodes property may not be accessed before ProjectService is started");

_projectNodes = [.. _extensionService.GetExtensionNodes<IProjectLoader>()];
}

return _projectNodes;
}
}

private IProject? LoadFrom(string path)
{
if (File.Exists(path))
Expand All @@ -147,8 +144,9 @@ public override void StartService()
if (string.IsNullOrEmpty(ext))
return null;

if (_extensionIndex.TryGetValue(ext, out ExtensionNode? node))
return node;
foreach (var node in ProjectNodes)
if (node.GetValues("FileExtension").Contains(ext))
return node;

return null;
}
Expand Down
Loading