Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov authored and NikolayPianikov committed Dec 14, 2018
1 parent aa791b9 commit 9bf33f8
Show file tree
Hide file tree
Showing 12 changed files with 332 additions and 421 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,4 @@ images
MockAssemblyResult.xml
PortabilityAnalysis*.html
tools/nuget.exe
tools/
13 changes: 8 additions & 5 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.9.0
#tool nuget:?package=NUnit.Extension.TeamCityEventListener&version=1.0.5
#tool nuget:?package=NUnit.ConsoleRunner&version=3.8.0
#tool nuget:?package=NUnit.Extension.TeamCityEventListener&version=1.0.4

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
Expand All @@ -21,9 +21,12 @@ var binaries = Argument("binaries", (string)null);
// SET PACKAGE VERSION
//////////////////////////////////////////////////////////////////////

var version = "1.0.6";
var version = "1.0.6-beta2";
var modifier = "";
var versionsOfNunitCore = new [] {Tuple.Create("3.4.1", "3.4.1"), Tuple.Create("3.5", "3.5"), Tuple.Create("3.6", "3.6.1"), Tuple.Create("3.9", "3.8"), Tuple.Create("", "")};

// Tuple(NUnit.Console version, NUnit version)
var versionsOfNunitCore = new [] {Tuple.Create("3.4.1", "3.4.1"), Tuple.Create("3.5", "3.5"), Tuple.Create("3.6", "3.6.1"), Tuple.Create("3.9", "3.8")};
// var versionsOfNunitCore = new [] {Tuple.Create("3.4.1", "3.4.1"), Tuple.Create("3.5", "3.5"), Tuple.Create("3.6", "3.6.1"), Tuple.Create("3.9", "3.8"), Tuple.Create("", "")};

var integrationTestsCategories = new List<string>();

Expand Down Expand Up @@ -80,7 +83,7 @@ if (binaries != null)
// Files
var SOLUTION_FILE = PROJECT_DIR + "teamcity-event-listener.sln";
var TEST_SOLUTION_FILE = PROJECT_DIR + "teamcity-event-listener-tests.sln";
var NUNIT3_CONSOLE = TOOLS_DIR + "NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe";
var NUNIT3_CONSOLE = TOOLS_DIR + "NUnit.ConsoleRunner.3.8.0/tools/nunit3-console.exe";
var TEST_ASSEMBLY = BIN_DIR + "teamcity-event-listener.tests.dll";
var INTEGRATION_TEST_ASSEMBLY = BIN_DIR + "nunit.integration.tests.dll";

Expand Down
77 changes: 52 additions & 25 deletions src/nunit.integration.tests/Dsl/EnvironmentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,73 +36,95 @@ public void CopyReference(string directoryName, string referenceFileName)

public IEnumerable<string> EnumerateNUnitAssemblies(string nunitBasePath, TargetDotNetFrameworkVersion frameworkVersion)
{
yield return GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "nunit.framework.dll");
var file = GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "NUnit.System.Linq.dll");
if (file != null)
if (nunitBasePath == null) throw new ArgumentNullException(nameof(nunitBasePath));
if (GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "nunit.framework.dll", out var path))
{
yield return file;
yield return path;
}

if (GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "NUnit.System.Linq.dll", out path))
{
yield return path;
}
}

public IEnumerable<string> EnumerateNUnitReferences(string nunitBasePath, TargetDotNetFrameworkVersion frameworkVersion)
{
yield return GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "nunit.framework.dll");
if (nunitBasePath == null) throw new ArgumentNullException(nameof(nunitBasePath));
if (GetNUnitFrameworkPath(nunitBasePath, frameworkVersion, "nunit.framework.dll", out var path))
{
yield return path;
}
}

private string GetNUnitFrameworkPath(string nunitBasePath, TargetDotNetFrameworkVersion frameworkVersion, string fileName)
private bool GetNUnitFrameworkPath(string nunitBasePath, TargetDotNetFrameworkVersion frameworkVersion, string fileName, out string path)
{
string pathPattern;
if (nunitBasePath == null) throw new ArgumentNullException(nameof(nunitBasePath));
if (fileName == null) throw new ArgumentNullException(nameof(fileName));
var pathPatterns = new List<string>();
switch (frameworkVersion)
{
case TargetDotNetFrameworkVersion.Version45:
pathPattern = "net*4*5";
pathPatterns.Add("net*4*5");
pathPatterns.Add("net45");
break;

case TargetDotNetFrameworkVersion.Version40:
pathPattern = "net*4*0";
pathPatterns.Add("net*4*0");
pathPatterns.Add("net40");
break;

case TargetDotNetFrameworkVersion.Version20:
pathPattern = "net*2*0";
pathPatterns.Add("net*2*0");
pathPatterns.Add("net20");
break;

default:
throw new NotSupportedException(frameworkVersion.ToString());
}

return FindFolder(nunitBasePath, pathPattern, fileName);
foreach (var pathPattern in pathPatterns)
{
if (TryFindFolder(nunitBasePath, pathPattern, fileName, out path))
{
return true;
}
}

path = default(string);
return false;
}

private string FindFolder(string pathToFind, string searchPattern, string fileName)
private bool TryFindFolder(string pathToFind, string searchPattern, string fileName, out string path)
{
if (pathToFind == null) throw new ArgumentNullException(nameof(pathToFind));
if (searchPattern == null) throw new ArgumentNullException(nameof(searchPattern));
if (fileName == null) throw new ArgumentNullException(nameof(fileName));
foreach (var dir in Directory.GetDirectories(pathToFind, searchPattern))
{
var files = Directory.GetFiles(dir, fileName);
if (files.Length > 0)
{
return files[0];
}
path = files[0];
return true;
}
}

foreach (var dir in Directory.GetDirectories(pathToFind))
{
var file = FindFolder(dir, searchPattern, fileName);
if (file != null)
if (TryFindFolder(dir, searchPattern, fileName, out path))
{
return file;
return true;
}
}

return null;
path = default(string);
return false;
}

public void CreateDirectory(string directoryName)
{
if (directoryName == null)
{
throw new ArgumentNullException(nameof(directoryName));
}

if (directoryName == null) throw new ArgumentNullException(nameof(directoryName));
if (Directory.Exists(directoryName))
{
Directory.Delete(directoryName, true);
Expand All @@ -111,15 +133,19 @@ public void CreateDirectory(string directoryName)
Directory.CreateDirectory(directoryName);
}

public string PrepareNUnitClonsoleAndGetPath(string sandboxPath, string nunitPath)
public string PrepareNUnitConsoleAndGetPath(string sandboxPath, string nunitPath)
{
if (sandboxPath == null) throw new ArgumentNullException(nameof(sandboxPath));
if (nunitPath == null) throw new ArgumentNullException(nameof(nunitPath));
var nunitBasePath = Path.GetFullPath(Path.Combine(sandboxPath, "nunit"));
JunctionPoint.Create(nunitBasePath, nunitPath, true);
return GetConsolePath(nunitBasePath);
}

public void RemoveFileOrDirectoryFromNUnitDirectory(string fileToRemove, string nunitConsolePath)
{
if (fileToRemove == null) throw new ArgumentNullException(nameof(fileToRemove));
if (nunitConsolePath == null) throw new ArgumentNullException(nameof(nunitConsolePath));
var path = Path.Combine(nunitConsolePath, fileToRemove);
if (Directory.Exists(path))
{
Expand All @@ -134,6 +160,7 @@ public void RemoveFileOrDirectoryFromNUnitDirectory(string fileToRemove, string

private string GetConsolePath(string pathToFind)
{
if (pathToFind == null) throw new ArgumentNullException(nameof(pathToFind));
var files = Directory.GetFiles(pathToFind, "nunit3-console.exe");
if (files.Any())
{
Expand Down
6 changes: 5 additions & 1 deletion src/nunit.integration.tests/Dsl/TestAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class TestAssembly
public TestAssembly(string assemblyName)
{
Platform = Platform.AnyCpu;
_assemblyName = assemblyName;
_assemblyName = assemblyName ?? throw new ArgumentNullException(nameof(assemblyName));
}

public IEnumerable<TestClass> Classes => _classes.Values;
Expand All @@ -28,6 +28,8 @@ public TestAssembly(string assemblyName)

public TestClass GetOrCreateClass(string namespaceName, string className)
{
if (namespaceName == null) throw new ArgumentNullException(nameof(namespaceName));
if (className == null) throw new ArgumentNullException(nameof(className));
TestClass testClass;
var key = $"{namespaceName}.{className}";
if (!_classes.TryGetValue(key, out testClass))
Expand All @@ -40,11 +42,13 @@ public TestClass GetOrCreateClass(string namespaceName, string className)

public void AddReference(string assemblyName)
{
if (assemblyName == null) throw new ArgumentNullException(nameof(assemblyName));
_reference.Add(assemblyName);
}

public void AddAttribute(string attribute)
{
if (attribute == null) throw new ArgumentNullException(nameof(attribute));
_attributes.Add(attribute);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Examples:

@3.9
@teamcity
@ignore
Scenario Outline: NUnit returns exit code -5 when the test throws StackOverflow exception
Given Framework version is <frameworkVersion>
And I have added failedStackOverflow method as FailedStackOverflow to the class Foo.Tests.UnitTests1 for foo.tests
Expand All @@ -55,7 +56,7 @@ Scenario Outline: NUnit returns exit code -5 when the test throws StackOverflow
And I want to use CmdArguments type of TeamCity integration
And I have added the arg Process=<process> to NUnit console command line
When I run NUnit console
Then the exit code should be -5
Then the exit code should be negative
Examples:
| frameworkVersion | process |
# | Version45 | InProcess |
Expand All @@ -69,7 +70,7 @@ Examples:
@teamcity
@ignore
Scenario Outline: NUnit returns positive exit code when the test throws OutOfMemory exception
Given Framework version is <frameworkVersion>
Given Framework version is <frameworkVersion>
And I have added failedOutOfMemory method as FailedOutOfMemory to the class Foo.Tests.UnitTests1 for foo.tests
And I have created the folder mocks
And I have added NUnit framework references to foo.tests
Expand Down
56 changes: 29 additions & 27 deletions src/nunit.integration.tests/ExitCodeForExceptionalCases.feature.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9bf33f8

Please sign in to comment.