Skip to content

Commit

Permalink
housekeeping: cleanup opencover testing and test projects (reactiveui…
Browse files Browse the repository at this point in the history
  • Loading branch information
glennawatson authored Dec 27, 2018
1 parent 0fcd7a4 commit 5f68fdd
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 109 deletions.
124 changes: 55 additions & 69 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ var informationalVersion = EnvironmentVariable("GitAssemblyInformationalVersion"

// Artifacts
var artifactDirectory = "./artifacts/";
var testCoverageOutputFile = artifactDirectory + "OpenCover.xml";
var testsArtifactDirectory = artifactDirectory + "tests/";
var testCoverageOutputFile = testsArtifactDirectory + "OpenCover.xml";
var packageWhitelist = new[] { "ReactiveUI.Testing",
"ReactiveUI.Events",
"ReactiveUI.Events.WPF",
Expand Down Expand Up @@ -87,41 +88,64 @@ Setup(context =>
Information("Building version {0} of ReactiveUI.", informationalVersion);

CreateDirectory(artifactDirectory);
CreateDirectory(testsArtifactDirectory);
});

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


//////////////////////////////////////////////////////////////////////
// TASKS
// HELPER METHODS
//////////////////////////////////////////////////////////////////////

Task("BuildEventBuilder")
.Does (() =>
Action<string, string, bool, bool> Build = (solution, outputFolder, createPackage, forceUseFullDebugType) =>
{
var solution = "./src/EventBuilder.sln";
Information("Building {0} using {1}", solution, msBuildPath);

NuGetRestore(solution, new NuGetRestoreSettings() { ConfigFile = "./src/.nuget/NuGet.config" });
Information("Building {0} using {1}, createPackage = {2}", solution, msBuildPath, createPackage);

MSBuild(solution, new MSBuildSettings() {
var msBuildSettings = new MSBuildSettings() {
ToolPath = msBuildPath,
ArgumentCustomization = args => args.Append("/m")
ArgumentCustomization = args => args.Append("/m /restore")
}
.SetConfiguration("Release")
.WithProperty("TreatWarningsAsErrors", treatWarningsAsErrors.ToString())
.SetConfiguration("Release")
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false));
.SetNodeReuse(false);

if (createPackage)
{
msBuildSettings = msBuildSettings.WithProperty("PackageOutputPath", MakeAbsolute(Directory(outputFolder)).ToString().Quote()).WithTarget("build;pack");
}
else
{
msBuildSettings = msBuildSettings.WithProperty("OutputPath", MakeAbsolute(Directory(outputFolder)).ToString().Quote()).WithTarget("build");
}

if (forceUseFullDebugType)
{
msBuildSettings = msBuildSettings.WithProperty("DebugType", "full");
}

MSBuild(solution, msBuildSettings);
};

//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////

Task("BuildEventBuilder")
.Does (() =>
{
Build("./src/EventBuilder.sln", artifactDirectory + "eventbuilder", false, false);
});

Task("GenerateEvents")
.IsDependentOn("BuildEventBuilder")
.Does (() =>
{
var eventBuilder = "./src/EventBuilder/bin/Release/net461/EventBuilder.exe";
var workingDirectory = "./src/EventBuilder/bin/Release/Net461";
var workingDirectory = artifactDirectory + "eventbuilder/";
var eventBuilder = workingDirectory + "EventBuilder.exe";
var referenceAssembliesPath = vsLocation.CombineWithFilePath("./Common7/IDE/ReferenceAssemblies/Microsoft/Framework");

Information(referenceAssembliesPath.ToString());
Expand Down Expand Up @@ -186,55 +210,30 @@ Task("BuildReactiveUI")
.IsDependentOn("GenerateEvents")
.Does (() =>
{
Action<string,string> build = (solution, name) =>
{
Information("Building {0} using {1}", solution, msBuildPath);

MSBuild(solution, new MSBuildSettings() {
ToolPath = msBuildPath,
ArgumentCustomization = args => args.Append("/m /restore")
}
.WithTarget("build;pack")
.WithProperty("PackageOutputPath", MakeAbsolute(Directory(artifactDirectory)).ToString().Quote())
.WithProperty("TreatWarningsAsErrors", treatWarningsAsErrors.ToString())
.SetConfiguration("Release")
.SetVerbosity(Verbosity.Minimal)
.SetNodeReuse(false));
};

foreach(var package in packageWhitelist)
{
build("./src/" + package + "/" + package + ".csproj", package);
Build("./src/" + package + "/" + package + ".csproj", artifactDirectory, true, false);
}

build("./src/ReactiveUI.Tests/ReactiveUI.Tests.csproj", "ReactiveUI.Tests");
build("./src/ReactiveUI.LeakTests/ReactiveUI.LeakTests.csproj", "ReactiveUI.LeakTests");
build("./src/ReactiveUI.Fody.Tests/ReactiveUI.Fody.Tests.csproj", "ReactiveUI.Fody.Tests");
});

Task("RunUnitTests")
.IsDependentOn("BuildReactiveUI")
.Does(() =>
{
Action<ICakeContext> testAction = tool => {
tool.XUnit2("./src/ReactiveUI.Tests/bin/**/*.Tests.dll", new XUnit2Settings {
OutputDirectory = artifactDirectory,
XmlReport = true,
NoAppDomain = true
});
};
Action<ICakeContext, string> RunTests = (tool, projectName) => {
var testsArtifactProjectDirectory = testsArtifactDirectory + projectName + "/";
Build("./src/" + projectName + "/" + projectName + ".csproj", testsArtifactProjectDirectory, false, true);

Action<ICakeContext> testFodyAction = tool => {
tool.XUnit2("./src/ReactiveUI.Fody.Tests/bin/**/*.Tests.dll", new XUnit2Settings {
OutputDirectory = artifactDirectory,
var xunitSettings = new XUnit2Settings {
OutputDirectory = testsArtifactProjectDirectory,
XmlReport = true,
NoAppDomain = true
});
};

tool.XUnit2(testsArtifactProjectDirectory + "**/*.Tests.dll", xunitSettings);
};

OpenCover(testAction,
testCoverageOutputFile,
new OpenCoverSettings {
var openCoverSettings = new OpenCoverSettings {
ReturnTargetCodeOffset = 0,
ArgumentCustomization = args => args.Append("-mergeoutput")
}
Expand All @@ -249,26 +248,13 @@ Task("RunUnitTests")
.ExcludeByFile("*/*.g.cs")
.ExcludeByFile("*/*.g.i.cs")
.ExcludeByFile("*splat/splat*")
.ExcludeByFile("*ApprovalTests*"));
.ExcludeByFile("*ApprovalTests*");

OpenCover(testFodyAction,
testCoverageOutputFile,
new OpenCoverSettings {
ReturnTargetCodeOffset = 0,
ArgumentCustomization = args => args.Append("-mergeoutput")
}
.WithFilter("+[*]*")
.WithFilter("-[*.Testing]*")
.WithFilter("-[*.Tests*]*")
.WithFilter("-[ReactiveUI.Events]*")
.WithFilter("-[Splat*]*")
.WithFilter("-[ApprovalTests*]*")
.ExcludeByAttribute("*.ExcludeFromCodeCoverage*")
.ExcludeByFile("*/*Designer.cs")
.ExcludeByFile("*/*.g.cs")
.ExcludeByFile("*/*.g.i.cs")
.ExcludeByFile("*splat/splat*")
.ExcludeByFile("*ApprovalTests*"));
OpenCover(tool => RunTests(tool, "ReactiveUI.Tests"), testCoverageOutputFile, openCoverSettings);
OpenCover(tool => RunTests(tool, "ReactiveUI.Fody.Tests"), testCoverageOutputFile, openCoverSettings);
// TODO: seems the leak tests never worked as part of the CI, fix. For the moment just make sure it compiles.
// OpenCover(tool => RunTests(tool, "ReactiveUI.LeakTests"), testCoverageOutputFile, openCoverSettings);
Build("./src/ReactiveUI.LeakTests/ReactiveUI.LeakTests.csproj", testsArtifactDirectory + "LeakTests/", false, true);

ReportGenerator(testCoverageOutputFile, artifactDirectory);
}).ReportError(exception =>
Expand Down
35 changes: 33 additions & 2 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
<Project>
<PropertyGroup>
<NoWarn>$(NoWarn);1591;1701;1702;1705</NoWarn>
<Authors>.NET Foundation and Contributors</Authors>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)reactiveui.ruleset</CodeAnalysisRuleSet>
<Copyright>Copyright (c) .NET Foundation and Contributors</Copyright>
<PackageLicenseUrl>https://opensource.org/licenses/mit</PackageLicenseUrl>
<PackageProjectUrl>https://reactiveui.net</PackageProjectUrl>
<PackageIconUrl>https://i.imgur.com/7WDbqSy.png</PackageIconUrl>
<Owners>xpaulbettsx;ghuntley</Owners>
<Product>ReactiveUI ($(TargetFramework))</Product>
<PackageTags>mvvm;reactiveui;rx;reactive extensions;observable;LINQ;events;frp;xamarin;android;ios;mac;forms;monodroid;monotouch;xamarin.android;xamarin.ios;xamarin.forms;xamarin.mac;xamarin.tvos;wpf;net;netstandard;net461;uwp;tizen</PackageTags>
<PackageReleaseNotes>https://reactiveui.net/blog/</PackageReleaseNotes>
<RepositoryUrl>https://github.com/reactiveui/reactiveui</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<NoWarn>$(NoWarn);1591;1701;1702;1705;VSX1000</NoWarn>
<GenerateDocumentationFile Condition=" '$(Configuration)' == 'Release' ">true</GenerateDocumentationFile>
<Platform>AnyCPU</Platform>
<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>
Expand All @@ -14,16 +28,25 @@
<!-- Optional: Include PDB in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<PropertyGroup Condition="$(IsTestProject)">
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)reactiveui.tests.ruleset</CodeAnalysisRuleSet>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="LICENSE" />
</ItemGroup>

<ItemGroup Condition="$(IsTestProject)">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="Xunit.StaFact" Version="0.3.5" />
<PackageReference Include="Shouldly" Version=" 3.0.2" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="4.0.0" />
<PackageReference Include="PublicApiGenerator" Version="8.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false'">
Expand All @@ -33,5 +56,13 @@
<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)' == ''">$(MSBuildThisFileDirectory)</SolutionDir>
</PropertyGroup>
<Import Project="..\directory.build.props" />

<ItemGroup>
<PackageReference Include="stylecop.analyzers" Version="1.1.1-beta.61" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.6.2" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" Version="2.0.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
</ItemGroup>
</Project>
14 changes: 0 additions & 14 deletions src/ReactiveUI.Fody.Tests/ReactiveUI.Fody.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<IsPackable>false</IsPackable>
<DebugType>full</DebugType>
<CodeAnalysisRuleSet>..\reactiveui.tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="PublicApiGenerator" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="System.Reactive" Version="4.0.0" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ReactiveUI.Fody\ReactiveUI.Fody.csproj" ReferenceOutputAssembly="False" />
<ProjectReference Include="..\ReactiveUI.Fody.Helpers\ReactiveUI.Fody.Helpers.csproj" />
Expand Down
7 changes: 1 addition & 6 deletions src/ReactiveUI.LeakTests/ReactiveUI.LeakTests.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
<Project Sdk="MSBuild.Sdk.Extras">
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<TargetFramework>net461</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.DotMemoryUnit" Version="3.0.20171219.105559" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.console" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="Xunit.StaFact" Version="0.2.17" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ReactiveUI\ReactiveUI.csproj" />
Expand Down
17 changes: 0 additions & 17 deletions src/ReactiveUI.Tests/ReactiveUI.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,8 @@

<PropertyGroup>
<TargetFrameworks>net461</TargetFrameworks>
<IsPackable>false</IsPackable>
<DebugType>full</DebugType>
<CodeAnalysisRuleSet>..\reactiveui.tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="Xunit.StaFact" Version="0.3.5" />
<PackageReference Include="Shouldly" Version=" 3.0.2" />
<PackageReference Include="Microsoft.Reactive.Testing" Version="4.0.0" />
<PackageReference Include="PublicApiGenerator" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ReactiveUI.Blend\ReactiveUI.Blend.csproj" />
<ProjectReference Include="..\ReactiveUI.Testing\ReactiveUI.Testing.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion src/ReactiveUI/ReactiveUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'!='netstandard2.0'">
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<Compile Include="Platforms\shared\**\*.cs" />
</ItemGroup>

Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 5f68fdd

Please sign in to comment.