Incremental build of test projects (#3859)

* If restore incrementality fails, clean out all lock files to re-enable incrementality.

* Incremental build of TestProjects

* Remove reduntant build of test projects

* Fix CI

* Fix list of executable tests

* Msi tests on net46

* Path Separators

* PR Feedback

* Win Diag

* Let's try a hack!

* And another!

* Mor Diag

* McHack

* Slashety slash slash

* One more hack
This commit is contained in:
Piotr Puszkiewicz 2016-07-15 00:20:23 -07:00 committed by GitHub
parent f63258ebaa
commit a477fe7253
7 changed files with 154 additions and 53 deletions

View file

@ -144,7 +144,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "compile", "compile", "{8E33
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{FF498306-2DE2-47F6-8C35-3CF0589CF2B8}"
ProjectSection(SolutionItems) = preProject
build\test\ProjectsToTest.props = build\test\ProjectsToTest.props
build\test\TestPackageProjects.props = build\test\TestPackageProjects.props
EndProjectSection
EndProject

View file

@ -164,24 +164,32 @@
InputFile="%(_DownloadAndExtractItem.DownloadFileName)"
DestinationDirectory="%(_DownloadAndExtractItem.ExtractDestintation)" />
</Target>
<Target Name="SetupRestorePackagesInputsOutputs">
<ItemGroup>
<RestorePackagesInput Include="$(RepoRoot)/src/**/project.json" />
<RestorePackagesInput Include="$(RepoRoot)/tools/**/project.json" />
</ItemGroup>
</Target>
<Target Name="RestorePackages"
DependsOnTargets="SetupRestorePackagesInputsOutputs;Init"
Inputs="@(RestorePackagesInput)"
Outputs="@(RestorePackagesInput->'%(RelativeDir)/project.lock.json')">
<CallTarget Targets="CleanSrcToolsLockFiles" />
<DotNetRestore WorkingDirectory="$(RepoRoot)/src" ToolPath="$(DotNetPath)" />
<DotNetRestore WorkingDirectory="$(RepoRoot)/tools" ToolPath="$(DotNetPath)" />
</Target>
<Target Name="CleanSrcToolsLockFiles" >
<ItemGroup>
<SrcToolsLockFiles Include="$(RepoRoot)/src/**/project.lock.json;$(RepoRoot)/tools/**/project.lock.json" />
</ItemGroup>
<Delete Files="@(SrcToolsLockFiles)" />
</Target>
<Target Name="SetupRestorePackagesInputsOutputs">
<ItemGroup>
<RestorePackagesInput Include="$(RepoRoot)/src/**/project.json" />
<RestorePackagesInput Include="$(RepoRoot)/tools/**/project.json" />
</ItemGroup>
</Target>
<Target Name="SetupZipTemplatesInputsOutputs">
<PropertyGroup>
<_DotNetNewFolder>$(RepoRoot)/src/dotnet/commands/dotnet-new</_DotNetNewFolder>

View file

@ -1,8 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="test/ProjectsToTest.props" />
<PropertyGroup>
<PathSeparator>/</PathSeparator>
<PathSeparator Condition=" '$(OSName)' == 'win' ">\</PathSeparator>
</PropertyGroup>
<Import Project="test/TestPackageProjects.targets" />
<Import Project="test/TestAssetProjects.targets" />
<Import Project="test/TestProjects.targets" />
<Target Name="Test"
DependsOnTargets="PrepareTests;
@ -21,12 +27,13 @@
<TestTaskEnvironmentVariables Include="TEST_ARTIFACTS=$(TestArtifactsEnv)" />
</ItemGroup>
<DotNetTest WorkingDirectory="$(TestDirectory)/%(ProjectsToTest.Identity)/"
<DotNetTest WorkingDirectory="%(TestProjects.ProjectDir)"
EnvironmentVariables="@(TestTaskEnvironmentVariables)"
ToolPath="$(Stage2Directory)"
Configuration="$(Configuration)"
NoBuild="True"
NoTrait="category=failing"
Xml="$(TestResultXmlDir)/%(ProjectsToTest.Identity)-testResults.xml" />
Xml="$(TestResultXmlDir)/%(TestProjects.OutputName)-testResults.xml" />
</Target>
<Target Name="PrepareTests"
@ -44,10 +51,14 @@
</Target>
<Target Name="BuildTests"
DependsOnTargets="RestoreTests;">
DependsOnTargets="RestoreTests;
SetupTestProjectData;"
Inputs="%(TestProjects.BuildInputs)"
Outputs="%(TestProjects.BuildOutput)">
<DotNetBuild Configuration="$(Configuration)"
Framework="%(TestProjects.Framework)"
ToolPath="$(DotnetUnderTest)"
WorkingDirectory="$(TestDirectory)/%(ProjectsToTest.Identity)/" />
WorkingDirectory="%(TestProjects.RelativeDir)" />
</Target>
<Target Name="RestoreTests"
@ -56,6 +67,8 @@
SetupRestoreTestsInputs;"
Inputs="@(RestoreTestsInputs)"
Outputs="@(RestoreTestsInputs->'%(RelativeDir)project.lock.json')">
<CallTarget Targets="CleanTestProjectsLockFiles"/>
<DotNetRestore FallbackSource="$(TestPackagesDir)"
ToolPath="$(DotnetUnderTest)"
WorkingDirectory="$(TestDirectory)" />
@ -80,7 +93,8 @@
<Target Name="SetupRestoreTestsInputs"
DependsOnTargets="PrepareTests;" >
<ItemGroup>
<RestoreTestsInputs Include="$(TestDirectory)/**/project.json" />
<RestoreTestsInputs Include="$(TestDirectory)/**/project.json"
Exclude="$(TestDirectory)/**/bin/**/project.json" />
</ItemGroup>
</Target>
@ -125,6 +139,13 @@
<Delete Files="@(TestAssetProjectsLockFiles)" />
</Target>
<Target Name="CleanTestProjectsLockFiles" >
<ItemGroup>
<TestProjectsLockFiles Include="$(RepoRoot)/test/**/project.lock.json" />
</ItemGroup>
<Delete Files="@(TestProjectsLockFiles)" />
</Target>
<Target Name="BuildDesktopTestAssetProjects"
Condition=" '$(IsDesktopAvailable)' == 'True' "
DependsOnTargets="RestoreDesktopTestAssetProjects">

View file

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectsToTest Include="ArgumentForwardingTests"/>
<ProjectsToTest Include="crossgen.Tests"/>
<ProjectsToTest Include="EndToEnd"/>
<ProjectsToTest Include="dotnet.Tests"/>
<ProjectsToTest Include="dotnet-build.Tests"/>
<ProjectsToTest Include="dotnet-build3.Tests"/>
<ProjectsToTest Include="dotnet-compile.Tests"/>
<ProjectsToTest Include="dotnet-compile.UnitTests"/>
<!-- TODO: https://github.com/dotnet/cli/issues/3558 /><ProjectsToTest Include="/ "dotnet-compile-fsc.Tests" />-->
<ProjectsToTest Include="dotnet-new.Tests"/>
<ProjectsToTest Include="dotnet-pack.Tests"/>
<ProjectsToTest Include="dotnet-publish.Tests"/>
<ProjectsToTest Include="dotnet-resgen.Tests"/>
<ProjectsToTest Include="dotnet-run.Tests"/>
<ProjectsToTest Include="dotnet-run.UnitTests"/>
<ProjectsToTest Include="dotnet-test.Tests"/>
<ProjectsToTest Include="dotnet-test.UnitTests"/>
<!-- TODO: https://github.com/dotnet/cli/issues/3216 /><ProjectsToTest Include="/"Kestrel.Tests" />-->
<ProjectsToTest Include="Microsoft.DotNet.Cli.Utils.Tests"/>
<ProjectsToTest Include="Microsoft.DotNet.Compiler.Common.Tests"/>
<ProjectsToTest Include="Microsoft.DotNet.ProjectModel.Tests"/>
<ProjectsToTest Include="Microsoft.DotNet.ProjectModel.Loader.Tests"/>
<ProjectsToTest Include="Microsoft.Extensions.DependencyModel.Tests"/>
<ProjectsToTest Include="Microsoft.DotNet.Configurer.UnitTests"/>
<ProjectsToTest Include="Performance"/>
<ProjectsToTest Condition="'$(DesktopAvailable)' == 'True'" Include="binding-redirects.Tests"/>
</ItemGroup>
</Project>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="SetupTestAssetProjectData"
DependsOnTargets="AssociateTestAssetInputFilesWithProject">
</Target>
@ -30,17 +30,15 @@
</Target>
<Target Name="SetupBuildTestAssetProjectInputs">
<PropertyGroup>
<PathSeparator>/</PathSeparator>
<PathSeparator Condition=" '$(OSName)' == 'win' ">\</PathSeparator>
</PropertyGroup>
<ItemGroup>
<NoAutoBuildTestAssets Include="TestAssets$(PathSeparator)TestProjects$(PathSeparator)**$(PathSeparator).noautobuild" />
<NoAutoBuildTestAssetProjects Include="%(NoAutoBuildTestAssets.RelativeDir)project.json" />
<TestAssetProjects Include="TestAssets$(PathSeparator)TestProjects$(PathSeparator)**$(PathSeparator)project.json"
<PreTestAssetProjects Include="TestAssets$(PathSeparator)TestProjects$(PathSeparator)**$(PathSeparator)project.json"/>
<TestAssetProjects Include="%(PreTestAssetProjects.RelativeDir)project.json"
Exclude="@(NoAutoBuildTestAssetProjects)"/>
<TestAssetProjects>
<BuildInputIncludeFilter>%(RelativeDir)**/*.*</BuildInputIncludeFilter>
<BuildInputExcludeFilter>%(RelativeDir)bin/**/*.*;%(RelativeDir)obj/**/*.*</BuildInputExcludeFilter>

View file

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="SetupTestProjectData"
DependsOnTargets="AssociateTestInputFilesWithProject">
</Target>
<Target Name="AssociateTestInputFilesWithProject"
DependsOnTargets="IdentifyTestInputFilesForProject;"
Outputs="%(TestProjects.ProjectPath)">
<PropertyGroup>
<CurrentProject>%(TestProjects.ProjectPath)</CurrentProject>
</PropertyGroup>
<ItemGroup>
<TestProjects Condition=" '%(ProjectPath)' == '$(CurrentProject)' ">
<BuildInputs>@(TestProjectInputs)</BuildInputs>
</TestProjects>
</ItemGroup>
</Target>
<Target Name="IdentifyTestInputFilesForProject"
DependsOnTargets="SetupBuildTestProjectInputs;"
Outputs="%(TestProjects.ProjectPath)">
<ItemGroup>
<TestProjectInputs Include="%(TestProjects.BuildInputIncludeFilter)"
Exclude="%(TestProjects.BuildInputExcludeFilter)">
<ProjectPath>%(TestProjects.ProjectPath)</ProjectPath>
</TestProjectInputs>
</ItemGroup>
</Target>
<Target Name="SetupBuildTestProjectInputs">
<ItemGroup>
<PreTestProjectsToExclude Condition=" '$(IsDesktopAvailable)' != 'True' "
Include="test/binding-redirects.Tests/project.json;" />
<PreTestProjectsToExclude Condition=" 'https://github.com/dotnet/cli/issues/3864' != 'fixed' "
Include="test$(PathSeparator)TestingAbstractions$(PathSeparator)Microsoft.Extensions.Testing.Abstractions.Tests$(PathSeparator)project.json;
test$(PathSeparator)TestingAbstractions$(PathSeparator)Microsoft.Extensions.Testing.Abstractions.UnitTests$(PathSeparator)project.json;" />
<PreTestProjectsToExclude Condition=" 'https://github.com/dotnet/cli/issues/3558' != 'fixed' "
Include="test$(PathSeparator)dotnet-compile-fsc.Tests$(PathSeparator)project.json" />
<PreTestProjectsToExclude Condition=" 'https://github.com/dotnet/cli/issues/3216' != 'fixed' "
Include="test$(PathSeparator)Kestrel.Tests$(PathSeparator)project.json" />
<PreTestProjectsToExclude Condition=" 'https://github.com/dotnet/cli/issues/3865' != 'fixed' "
Include="test$(PathSeparator)ScriptExecutorTests$(PathSeparator)project.json" />
<PreTestProjectsToExclude Condition=" 'Non-test projects in test directory' != 'consider moving elsewhere' "
Include="test$(PathSeparator)ArgumentsReflector$(PathSeparator)project.json;
test$(PathSeparator)Microsoft.DotNet.Tools.Tests.Utilities$(PathSeparator)project.json;
test$(PathSeparator)TestingAbstractions$(PathSeparator)TestAppWithFullPdbs$(PathSeparator)project.json;
test$(PathSeparator)TestingAbstractions$(PathSeparator)TestAppWithPortablePdbs$(PathSeparator)project.json" />
<PreTestProjectsToExclude Condition=" 'Executed after primary test phase.' != ' Consider moving.' "
Include="test$(PathSeparator)Installer$(PathSeparator)Microsoft.DotNet.Cli.Msi.Tests$(PathSeparator)project.json;" />
<PreTestProjectsToExclude Include="test$(PathSeparator)**$(PathSeparator)bin$(PathSeparator)**$(PathSeparator)project.json" />
<TestProjectsToExclude Include="%(PreTestProjectsToExclude.RelativeDir)project.json" />
<PreTestProjects Include="test$(PathSeparator)**$(PathSeparator)project.json;" />
<TestProjects Include="%(PreTestProjects.RelativeDir)project.json;"
Exclude="@(TestProjectsToExclude)" />
<TestProjects>
<BuildInputIncludeFilter>%(RelativeDir)**/*.*</BuildInputIncludeFilter>
<BuildInputExcludeFilter>%(RelativeDir)bin/**/*.*;%(RelativeDir)obj/**/*.*</BuildInputExcludeFilter>
<ProjectDir>$([System.IO.Directory]::GetParent(%(Identity)))</ProjectDir>
<ProjectPath>%(Identity)</ProjectPath>
<Framework>netcoreapp1.0</Framework>
</TestProjects>
<TestProjects>
<OutputName>$([System.IO.Path]::GetFileName(%(ProjectDir)))</OutputName>
</TestProjects>
<TestProjects>
<BuildOutput>$(RepoRoot)%(TestProjects.RelativeDir)bin/$(Configuration)/%(TestProjects.Framework)/%(TestProjects.OutputName).dll</BuildOutput>
</TestProjects>
<TestProjects Condition=" '%(RelativeDir)' == 'test\binding-redirects.Tests\' ">
<Framework>net451</Framework>
</TestProjects>
<TestProjects Condition=" '%(RelativeDir)' == 'test\Installer\Microsoft.DotNet.Cli.Msi.Tests\' ">
<Framework>net46</Framework>
</TestProjects>
</ItemGroup>
<Message Text="%(TestProjects.Identity) %(TestProjects.RelativeDir) %(TestProjects.Framework)" />
</Target>
</Project>

View file

@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Cli.Build
protected override string Args
{
get { return $"{GetConfiguration()} {GetXml()} {GetNoTrait()}"; }
get { return $"{GetConfiguration()} {GetNoBuild()} {GetXml()} {GetNoTrait()}"; }
}
public string Configuration { get; set; }
@ -21,6 +21,8 @@ namespace Microsoft.DotNet.Cli.Build
public string NoTrait { get; set; }
public bool NoBuild { get; set; }
private string GetConfiguration()
{
if (!string.IsNullOrEmpty(Configuration))
@ -50,5 +52,15 @@ namespace Microsoft.DotNet.Cli.Build
return null;
}
private string GetNoBuild()
{
if (NoBuild)
{
return "--no-build";
}
return null;
}
}
}