-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fsharp projects change tracking (#72)
* Added imported project files modifications check * Added some tests + refactoring * Added test for fsharp dependency tracking before implementation * Fixed issue when multiple projects share same directory * Added F# project loading hack * Handle working directory change during tests execution * close #72
- Loading branch information
1 parent
9b1d69d
commit 0cd8f96
Showing
10 changed files
with
204 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/Incrementalist.Tests/Dependencies/FSharpProjectsTrackingSpecs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Incrementalist.Cmd.Commands; | ||
using Incrementalist.ProjectSystem; | ||
using Incrementalist.ProjectSystem.Cmds; | ||
using Incrementalist.Tests.Helpers; | ||
using Microsoft.Build.Locator; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.MSBuild; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Incrementalist.Tests.Dependencies | ||
{ | ||
public class FSharpProjectsTrackingSpecs : IDisposable | ||
{ | ||
private readonly ITestOutputHelper _outputHelper; | ||
public DisposableRepository Repository { get; } | ||
|
||
public FSharpProjectsTrackingSpecs(ITestOutputHelper outputHelper) | ||
{ | ||
_outputHelper = outputHelper; | ||
Repository = new DisposableRepository(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
Repository?.Dispose(); | ||
} | ||
|
||
[Fact] | ||
public async Task FSharpProjectDiff_should_be_tracked() | ||
{ | ||
var sample = ProjectSampleGenerator.GetFSharpSolutionSample("FSharpSolution.sln"); | ||
var solutionFullPath = sample.SolutionFile.GetFullPath(Repository.BasePath); | ||
var fsharpProjectFullPath = sample.FSharpProjectFile.GetFullPath(Repository.BasePath); | ||
var csharpProjectFullPath = sample.CSharpProjectFile.GetFullPath(Repository.BasePath); | ||
|
||
Repository | ||
.WriteFile(sample.SolutionFile) | ||
.WriteFile(sample.CSharpProjectFile) | ||
.WriteFile(sample.FSharpProjectFile) | ||
.Commit("Created new solution with fsharp and csharp projects") | ||
.CreateBranch("foo") | ||
.CheckoutBranch("foo") | ||
.WriteFile(sample.CSharpProjectFile.Name, sample.CSharpProjectFile.Content + " ") | ||
.WriteFile(sample.FSharpProjectFile.Name, sample.FSharpProjectFile.Content + " ") | ||
.Commit("Updated both project files"); | ||
|
||
var logger = new TestOutputLogger(_outputHelper); | ||
var settings = new BuildSettings("master", solutionFullPath, Repository.BasePath); | ||
var workspace = SetupMsBuildWorkspace(); | ||
var emitTask = new EmitDependencyGraphTask(settings, workspace, logger); | ||
var affectedFiles = (await emitTask.Run()).ToList(); | ||
|
||
affectedFiles.Select(f => f.Key).Should().HaveCount(2).And.Subject.Should().BeEquivalentTo(fsharpProjectFullPath, csharpProjectFullPath); | ||
} | ||
|
||
private static MSBuildWorkspace SetupMsBuildWorkspace() | ||
{ | ||
// Locate and register the default instance of MSBuild installed on this machine. | ||
MSBuildLocator.RegisterDefaults(); | ||
|
||
return MSBuildWorkspace.Create(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/Incrementalist.Tests/Samples/FSharpSampleSolution/CSharpProject.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
7 changes: 7 additions & 0 deletions
7
src/Incrementalist.Tests/Samples/FSharpSampleSolution/FSharpProject.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
</PropertyGroup> | ||
|
||
</Project> |
22 changes: 22 additions & 0 deletions
22
src/Incrementalist.Tests/Samples/FSharpSampleSolution/Solution.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpProject", "FSharpProject.fsproj", "{50FA647B-BAE4-4DF5-99CA-934B8227E236}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpProject", "CSharpProject.csproj", "{5FEC8D4E-75A8-4730-A57D-8258B2CD971C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{50FA647B-BAE4-4DF5-99CA-934B8227E236}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{50FA647B-BAE4-4DF5-99CA-934B8227E236}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{50FA647B-BAE4-4DF5-99CA-934B8227E236}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{50FA647B-BAE4-4DF5-99CA-934B8227E236}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{5FEC8D4E-75A8-4730-A57D-8258B2CD971C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5FEC8D4E-75A8-4730-A57D-8258B2CD971C}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5FEC8D4E-75A8-4730-A57D-8258B2CD971C}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5FEC8D4E-75A8-4730-A57D-8258B2CD971C}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters