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

Lightweight .NET Standard version of the Engine #205

Merged
merged 30 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ef452dc
.NET Standard version of the Mock Assembly
rprouse Mar 18, 2017
7873eba
Added the API classes that are needed to the .NET Standard project
rprouse Mar 18, 2017
7163824
Added empty test project for .NET Standard
rprouse Mar 18, 2017
428f9ef
Initial .NET Standard unit tests
rprouse Mar 19, 2017
a721659
.NET Standard version of the engine is compiling
rprouse Mar 21, 2017
51d56c6
Nearly all tests passing, but having trouble with the full path for t…
rprouse Mar 21, 2017
0bcc9ff
Switched Mock Assembly to the newer CSPROJ format
rprouse Mar 25, 2017
959231f
Converted the .NET Standard engine to the new csproj format
rprouse Mar 25, 2017
9326824
Created a VS2017 solution
rprouse Mar 25, 2017
89c673f
Fixing the .NET Standard unit tests
rprouse Mar 25, 2017
a4a60f7
Remove the parallel task worker pool because they are never used in .…
rprouse Mar 25, 2017
6d8c2e2
Added in the result writers
rprouse Mar 25, 2017
dbe77ec
Adding in addtional classes needed by the VS Adapter
rprouse Mar 26, 2017
eb7de68
Switched to just a .NET Core solution
rprouse Mar 30, 2017
9214f29
Build, tests and package .NET Standard from Cake
rprouse Mar 30, 2017
8f51abc
Updating Cake to work on AppVeyor
rprouse Mar 30, 2017
59276c2
Need Nuget 4.0, but latest is still 3.5
rprouse Mar 30, 2017
8441cc6
Moved the various assembly info back to the CS files from the project…
rprouse Mar 30, 2017
cbb9d72
Install .NET Core on Travis
rprouse Apr 1, 2017
e684e71
Another Travis attempt
rprouse Apr 1, 2017
56fb105
Execute permissions on Travis
rprouse Apr 1, 2017
35fe556
Don't build the .NET Standard engine on Travis
rprouse Apr 19, 2017
0c7ba4e
Another attempt at getting all Travis builds running
rprouse Apr 19, 2017
06533ce
Yet another travis attempt
rprouse Apr 19, 2017
a000037
Using the Travis setup from OmniSharp
rprouse Apr 24, 2017
4a2b088
Now building on Linux
rprouse Apr 25, 2017
f15bbe1
Remove travis msbuild update
rprouse Apr 25, 2017
90bddf0
Fixes based on code review feedback
rprouse Apr 28, 2017
5ee708f
Reverting one of the dependency changes
rprouse Apr 28, 2017
ba194ae
Update based on code review
rprouse Apr 28, 2017
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.suo
*.user
*.sln.docstates
*.project.lock.json

# Build results

Expand Down
18 changes: 11 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
language: csharp
sudo: false
mono:
- latest
- 4.2.4
os:
- linux
- osx
sudo: required
matrix:
include:
- os: linux
dist: trusty
mono: latest
- os: linux
dist: trusty
mono: 4.2.4
- os: osx
mono: latest
allow_failures:
- mono: latest
fast_finish: true

script:
- ./build.sh --target "Travis"
58 changes: 58 additions & 0 deletions NUnit.Engine.Netstandard.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
.travis.yml = .travis.yml
appveyor.yml = appveyor.yml
build.cake = build.cake
BUILDING.md = BUILDING.md
CHANGES.txt = CHANGES.txt
CONTRIBUTING.md = CONTRIBUTING.md
LICENSE.txt = LICENSE.txt
NOTICES.txt = NOTICES.txt
NuGet.config = NuGet.config
nunit.ico = nunit.ico
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.engine.tests.netstandard", "src\NUnitEngine\nunit.engine.tests.netstandard\nunit.engine.tests.netstandard.csproj", "{BC22F0E4-0862-4F82-A912-C9A447FECBAD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mock-assembly.netstandard", "src\NUnitEngine\mock-assembly\mock-assembly.netstandard.csproj", "{BC6C8155-2024-4F58-A006-18A15EA22A5C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.engine.netstandard", "src\NUnitEngine\nunit.engine.netstandard\nunit.engine.netstandard.csproj", "{C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Release|Any CPU.Build.0 = Release|Any CPU
{BC6C8155-2024-4F58-A006-18A15EA22A5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC6C8155-2024-4F58-A006-18A15EA22A5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC6C8155-2024-4F58-A006-18A15EA22A5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC6C8155-2024-4F58-A006-18A15EA22A5C}.Release|Any CPU.Build.0 = Release|Any CPU
{C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = src\NUnitFramework\tests\nunitlite.tests-2.0.csproj
{28B605B2-E2E9-417E-8369-49E263F1F31B} = {31B45C4C-206F-4F31-9CC6-33BF11DFEE39}
{FFF45826-991F-465B-8A03-0E1DB7E8F38C} = {31B45C4C-206F-4F31-9CC6-33BF11DFEE39}
{11640C9F-03A3-456B-848D-9B4A126F9506} = {31B45C4C-206F-4F31-9CC6-33BF11DFEE39}
EndGlobalSection
EndGlobal
138 changes: 120 additions & 18 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var ErrorDetail = new List<string>();
//////////////////////////////////////////////////////////////////////

var version = "3.7.0";
var modifier = "";
var modifier = "-alpha1";

var isAppveyor = BuildSystem.IsRunningOnAppVeyor;
var dbgSuffix = configuration == "Debug" ? "-dbg" : "";
Expand All @@ -32,6 +32,8 @@ var BIN_DIR = PROJECT_DIR + "bin/" + configuration + "/";
var IMAGE_DIR = PROJECT_DIR + "images/";

var SOLUTION_FILE = "NUnitConsole.sln";
var DOTNETCORE_SOLUTION_FILE = "NUnit.Engine.NetStandard.sln";
var DOTNETCORE_TEST_ASSEMBLY = "src/NUnitEngine/nunit.engine.tests.netstandard/bin/" + configuration + "/netcoreapp1.1/nunit.engine.tests.netstandard.dll";

// Package sources for nuget restore
var PACKAGE_SOURCE = new string[]
Expand All @@ -47,6 +49,24 @@ var NUNIT3_CONSOLE = BIN_DIR + "nunit3-console.exe";
var ENGINE_TESTS = "nunit.engine.tests.dll";
var CONSOLE_TESTS = "nunit3-console.tests.dll";

bool IsDotNetCoreInstalled = false;

//////////////////////////////////////////////////////////////////////
// SETUP AND TEARDOWN TASKS
//////////////////////////////////////////////////////////////////////
Setup(context =>
{
// Executed BEFORE the first task.
Information("Building version {0} of NUnit.", packageVersion);
IsDotNetCoreInstalled = CheckIfDotNetCoreInstalled();
});

Teardown(context =>
{
// Executed AFTER the last task.
CheckForError(ref ErrorDetail);
});

//////////////////////////////////////////////////////////////////////
// CLEAN
//////////////////////////////////////////////////////////////////////
Expand All @@ -67,10 +87,18 @@ Task("InitializeBuild")
.Description("Initializes the build")
.Does(() =>
{
NuGetRestore(SOLUTION_FILE, new NuGetRestoreSettings()
{
Source = PACKAGE_SOURCE
});
Information("Restoring NuGet packages");
NuGetRestore(SOLUTION_FILE, new NuGetRestoreSettings
{
Source = PACKAGE_SOURCE,
Verbosity = NuGetVerbosity.Detailed
});

if(IsDotNetCoreInstalled && IsRunningOnWindows())
{
Information("Restoring .NET Core packages");
DotNetCoreRestore(DOTNETCORE_SOLUTION_FILE);
}

if (BuildSystem.IsRunningOnAppVeyor)
{
Expand Down Expand Up @@ -133,6 +161,32 @@ Task("BuildEngine")
BuildProject("./src/NUnitEngine/notest-assembly/notest-assembly.csproj", configuration);
});

//////////////////////////////////////////////////////////////////////
// BUILD NETSTANDARD ENGINE
//////////////////////////////////////////////////////////////////////

Task("BuildNetStandardEngine")
.Description("Builds the .NET Standard engine")
.IsDependentOn("InitializeBuild")
.WithCriteria(IsRunningOnWindows())
.Does(() =>
{
if(IsDotNetCoreInstalled)
{
var settings = new DotNetCoreBuildSettings
{
Configuration = configuration,
EnvironmentVariables = new Dictionary<string, string>()
};
settings.EnvironmentVariables.Add("PackageVersion", packageVersion);
DotNetCoreBuild(DOTNETCORE_SOLUTION_FILE, settings);
}
else
{
Warning("Skipping .NET Standard build because .NET Core is not installed");
}
});

//////////////////////////////////////////////////////////////////////
// BUILD CONSOLE
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -204,6 +258,27 @@ Task("TestConsole")
RunTest(NUNIT3_CONSOLE, BIN_DIR, CONSOLE_TESTS, "TestConsole", ref ErrorDetail);
});

//////////////////////////////////////////////////////////////////////
// TEST NETSTANDARD ENGINE
//////////////////////////////////////////////////////////////////////

Task("TestNetStandardEngine")
.Description("Tests the .NET Standard Engine")
.IsDependentOn("BuildNetStandardEngine")
.WithCriteria(IsRunningOnWindows())
.OnError(exception => { ErrorDetail.Add(exception.Message); })
.Does(() =>
{
if(IsDotNetCoreInstalled)
{
DotNetCoreExecute(DOTNETCORE_TEST_ASSEMBLY);
}
else
{
Warning("Skipping .NET Standard tests because .NET Core is not installed");
}
});

//////////////////////////////////////////////////////////////////////
// PACKAGE
//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -337,23 +412,47 @@ Task("PackageConsole")
});

//////////////////////////////////////////////////////////////////////
// SETUP AND TEARDOWN TASKS
// PACKAGE NETSTANDARD ENGINE
//////////////////////////////////////////////////////////////////////
Setup(context =>
{
// Executed BEFORE the first task.
});

Teardown(context =>
{
// Executed AFTER the last task.
CheckForError(ref ErrorDetail);
});
Task("PackageNetStandardEngine")
.Description("Copies the .NET Standard Engine nuget package in the packages directory")
.WithCriteria(IsRunningOnWindows())
.Does(() =>
{
if(IsDotNetCoreInstalled)
{
var nuget = "nunit.engine.netstandard." + packageVersion + ".nupkg";
var src = "src/NUnitEngine/nunit.engine.netstandard/bin/" + configuration + "/" + nuget;
var dest = PACKAGE_DIR + nuget;

CreateDirectory(PACKAGE_DIR);
CopyFile(src, dest);
}
});

//////////////////////////////////////////////////////////////////////
// HELPER METHODS - GENERAL
//////////////////////////////////////////////////////////////////////

bool CheckIfDotNetCoreInstalled()
{
try
{
Information("Checking if .NET Core SDK is installed");
StartProcess("dotnet", new ProcessSettings
{
Arguments = "--version"
});
}
catch(Exception)
{
Warning(".NET Core SDK is not installed. It can be installed from https://www.microsoft.com/net/core");
return false;
}
return true;
}

void RunGitCommand(string arguments)
{
StartProcess("git", new ProcessSettings()
Expand Down Expand Up @@ -445,7 +544,8 @@ void RunTest(FilePath exePath, DirectoryPath workingDir, string arguments, strin
Task("Build")
.Description("Builds the engine and console runner")
.IsDependentOn("BuildEngine")
.IsDependentOn("BuildConsole");
.IsDependentOn("BuildConsole")
.IsDependentOn("BuildNetStandardEngine");

Task("Rebuild")
.Description("Rebuilds the engine and console runner")
Expand All @@ -455,13 +555,15 @@ Task("Rebuild")
Task("Test")
.Description("Builds and tests the engine and console runner")
.IsDependentOn("TestEngine")
.IsDependentOn("TestConsole");
.IsDependentOn("TestConsole")
.IsDependentOn("TestNetStandardEngine");

Task("Package")
.Description("Packages the engine and console runner")
.IsDependentOn("CheckForError")
.IsDependentOn("PackageEngine")
.IsDependentOn("PackageConsole");
.IsDependentOn("PackageConsole")
.IsDependentOn("PackageNetStandardEngine");

Task("Appveyor")
.Description("Builds, tests and packages on AppVeyor")
Expand Down
20 changes: 4 additions & 16 deletions src/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,10 @@
[assembly: AssemblyConfiguration(".NET 4.0 Debug")]
#elif NET_2_0
[assembly: AssemblyConfiguration(".NET 2.0 Debug")]
#elif SL_5_0
[assembly: AssemblyConfiguration("Silverlight 5.0 Debug")]
#elif SL_4_0
[assembly: AssemblyConfiguration("Silverlight 4.0 Debug")]
#elif SL_3_0
[assembly: AssemblyConfiguration("Silverlight 3.0 Debug")]
#elif NETCF_3_5
[assembly: AssemblyConfiguration("Compact Framework 3.5 Debug")]
#elif PORTABLE
[assembly: AssemblyConfiguration("Portable Debug")]
#elif NETSTANDARD1_3 || NETSTANDARD1_6 || NETCOREAPP1_0
[assembly: AssemblyConfiguration(".NET Standard Debug")]
#else
[assembly: AssemblyConfiguration("Debug")]
#endif
Expand All @@ -62,16 +56,10 @@
[assembly: AssemblyConfiguration(".NET 4.0")]
#elif NET_2_0
[assembly: AssemblyConfiguration(".NET 2.0")]
#elif SL_5_0
[assembly: AssemblyConfiguration("Silverlight 5.0")]
#elif SL_4_0
[assembly: AssemblyConfiguration("Silverlight 4.0")]
#elif SL_3_0
[assembly: AssemblyConfiguration("Silverlight 3.0")]
#elif NETCF_3_5
[assembly: AssemblyConfiguration("Compact Framework 3.5")]
#elif PORTABLE
[assembly: AssemblyConfiguration("Portable")]
#elif NETSTANDARD1_3 || NETSTANDARD1_6 || NETCOREAPP1_0
[assembly: AssemblyConfiguration(".NET Standard")]
#else
[assembly: AssemblyConfiguration("")]
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/NUnitEngine/mock-assembly/MockAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public class MockAssembly

public const int Inconclusive = MockTestFixture.Inconclusive;

#if !NETSTANDARD1_6
public static readonly string AssemblyPath = AssemblyHelper.GetAssemblyPath(typeof(MockAssembly).Assembly);
#endif
}

[TestFixture(Description="Fake Test Fixture")]
Expand Down
2 changes: 1 addition & 1 deletion src/NUnitEngine/mock-assembly/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@

[assembly: AssemblyTitle("mock-assembly")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyCulture("")]
Loading