Skip to content

Commit

Permalink
#30 Error message "File type is not supported" when uses .nunit confi…
Browse files Browse the repository at this point in the history
…guration file - ensure thar TestPackage is expanded before usage
  • Loading branch information
Nikolay Pianikov authored and Nikolay Pianikov committed Sep 5, 2016
1 parent d31ebef commit 0f5c037
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
29 changes: 27 additions & 2 deletions src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

using System;
using System.ComponentModel;
using System.IO;
using NUnit.Engine.Services;

namespace NUnit.Engine.Runners
Expand All @@ -39,9 +40,9 @@ public abstract class AbstractTestRunner : ITestEngineRunner
public AbstractTestRunner(IServiceLocator services, TestPackage package)
{
Services = services;
TestPackage = package;
TestRunnerFactory = Services.GetService<ITestRunnerFactory>();
ProjectService = Services.GetService<IProjectService>();
TestPackage = package;
}

#region Properties
Expand All @@ -58,7 +59,29 @@ public AbstractTestRunner(IServiceLocator services, TestPackage package)
/// <summary>
/// The TestPackage for which this is the runner
/// </summary>
protected TestPackage TestPackage { get; set; }
protected TestPackage TestPackage
{
get
{
return _testPackage;
}

set
{
_testPackage = value;

if (IsProjectPackage(_testPackage) && _testPackage.SubPackages.Count == 0)
{
// Some files in the top level package may be projects.
// Expand them so that they contain subprojects for
// each contained assembly.
if (File.Exists(TestPackage.FullName) && ProjectService.CanLoadFrom(TestPackage.FullName))
{
ProjectService.ExpandProjectPackage(_testPackage);
}
}
}
}

/// <summary>
/// The result of the last call to LoadPackage
Expand Down Expand Up @@ -227,6 +250,8 @@ public void Dispose()

protected bool _disposed = false;

private TestPackage _testPackage;

protected virtual void Dispose(bool disposing)
{
if (!_disposed)
Expand Down
16 changes: 0 additions & 16 deletions src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ private void LoadPackage()
// in case the client runner missed them.
ValidatePackageSettings();

// Some files in the top level package may be projects.
// Expand them so that they contain subprojects for
// each contained assembly.
ExpandProjects();

// Use SelectRuntimeFramework for its side effects.
// Info will be left behind in the package about
// each contained assembly, which will subsequently
Expand All @@ -236,17 +231,6 @@ private void LoadPackage()
LoadResult = _engineRunner.Load().Aggregate(TEST_RUN_ELEMENT, TestPackage.Name, TestPackage.FullName);
}

private void ExpandProjects()
{
foreach (var package in TestPackage.SubPackages)
{
string packageName = package.FullName;

if (File.Exists(packageName) && _projectService.CanLoadFrom(packageName))
_projectService.ExpandProjectPackage(package);
}
}

// Any Errors thrown from this method indicate that the client
// runner is putting invalid values into the package.
private void ValidatePackageSettings()
Expand Down

0 comments on commit 0f5c037

Please sign in to comment.