-
Notifications
You must be signed in to change notification settings - Fork 830
Integration tests for F# #14690
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
Merged
Merged
Integration tests for F# #14690
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
39c0f36
Trying things out
psfinaki 1a1872a
up
psfinaki 0b35954
Update CreateProjectTests.cs
psfinaki bfdd353
Update Build.ps1
psfinaki 35c9e22
Up
psfinaki 2c70c2a
up
psfinaki d890455
up
psfinaki 242d729
up
psfinaki 2838e82
Up
psfinaki 80cd6df
Merge branch 'main' into psfinaki/integration-tests
psfinaki 96cebc2
trying running separately
psfinaki b3c9658
Merge branch 'psfinaki/integration-tests' of https://github.com/psfin…
psfinaki 04e901e
Merge branch 'main' into psfinaki/integration-tests
psfinaki 3159938
Update FSharp.Editor.sln
psfinaki 5c544d1
Merge branch 'psfinaki/integration-tests' of https://github.com/psfin…
psfinaki 9cf1826
Update BuildProjectTests.cs
psfinaki 718a50e
Merge branch 'main' into psfinaki/integration-tests
KevinRansom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
14 changes: 14 additions & 0 deletions
14
vsintegration/tests/FSharp.Editor.IntegrationTests/AbstractIntegrationTest.cs
This file contains hidden or 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,14 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using Microsoft.VisualStudio.Extensibility.Testing; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.CodeAnalysis.Testing | ||
| { | ||
| [IdeSettings(MinVersion = VisualStudioVersion.VS2022)] | ||
| public abstract class AbstractIntegrationTest : AbstractIdeIntegrationTest | ||
| { | ||
| } | ||
| } |
69 changes: 69 additions & 0 deletions
69
vsintegration/tests/FSharp.Editor.IntegrationTests/BuildProjectTests.cs
This file contains hidden or 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,69 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using Microsoft.CodeAnalysis.Testing; | ||
| using Microsoft.VisualStudio.Extensibility.Testing; | ||
| using Microsoft.VisualStudio.Shell.Interop; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
|
|
||
| namespace FSharp.Editor.IntegrationTests; | ||
|
|
||
| public class BuildProjectTests : AbstractIntegrationTest | ||
| { | ||
| [IdeFact] | ||
| public async Task SuccessfulBuild_Async() | ||
| { | ||
| var token = HangMitigatingCancellationToken; | ||
| var template = WellKnownProjectTemplates.FSharpNetCoreClassLibrary; | ||
| var solutionExplorer = TestServices.SolutionExplorer; | ||
| var editor = TestServices.Editor; | ||
| var code = """ | ||
| module Test | ||
|
|
||
| let answer = 42 | ||
| """; | ||
|
|
||
| var expectedBuildSummary = "========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped =========="; | ||
|
|
||
| await solutionExplorer.CreateSolutionAsync(nameof(BuildProjectTests), token); | ||
| await solutionExplorer.AddProjectAsync("Library", template, token); | ||
| await solutionExplorer.RestoreNuGetPackagesAsync(token); | ||
| await editor.SetTextAsync(code, token); | ||
|
|
||
| var actualBuildSummary = await solutionExplorer.BuildSolutionAsync(token); | ||
|
|
||
| Assert.Contains(expectedBuildSummary, actualBuildSummary); | ||
| } | ||
|
|
||
| [IdeFact] | ||
| public async Task FailedBuild_Async() | ||
| { | ||
| var token = HangMitigatingCancellationToken; | ||
| var template = WellKnownProjectTemplates.FSharpNetCoreClassLibrary; | ||
| var solutionExplorer = TestServices.SolutionExplorer; | ||
| var editor = TestServices.Editor; | ||
| var errorList = TestServices.ErrorList; | ||
| var code = """ | ||
| module Test | ||
|
|
||
| let answer = | ||
| """; | ||
|
|
||
| var expectedBuildSummary = "========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="; | ||
| var expectedError = "(Compiler) Library.fs(3, 1): error FS0010: Incomplete structured construct at or before this point in binding"; | ||
|
|
||
| await solutionExplorer.CreateSolutionAsync(nameof(BuildProjectTests), token); | ||
| await solutionExplorer.AddProjectAsync("Library", template, token); | ||
| await solutionExplorer.RestoreNuGetPackagesAsync(token); | ||
| await editor.SetTextAsync(code, token); | ||
|
|
||
| var actualBuildSummary = await solutionExplorer.BuildSolutionAsync(token); | ||
| Assert.Contains(expectedBuildSummary, actualBuildSummary); | ||
|
|
||
| await errorList.ShowBuildErrorsAsync(token); | ||
| var errors = await errorList.GetBuildErrorsAsync(__VSERRORCATEGORY.EC_ERROR, token); | ||
| Assert.Contains(expectedError, errors); | ||
| } | ||
| } |
88 changes: 88 additions & 0 deletions
88
vsintegration/tests/FSharp.Editor.IntegrationTests/CreateProjectTests.cs
This file contains hidden or 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,88 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using Microsoft.CodeAnalysis.Testing; | ||
| using Microsoft.VisualStudio.Extensibility.Testing; | ||
| using System.Threading.Tasks; | ||
| using Xunit; | ||
|
|
||
| namespace FSharp.Editor.IntegrationTests; | ||
|
|
||
| public class CreateProjectTests : AbstractIntegrationTest | ||
| { | ||
| [IdeFact] | ||
| public async Task ClassLibrary_Async() | ||
| { | ||
| var token = HangMitigatingCancellationToken; | ||
| var template = WellKnownProjectTemplates.FSharpNetCoreClassLibrary; | ||
| var solutionExplorer = TestServices.SolutionExplorer; | ||
| var editor = TestServices.Editor; | ||
|
|
||
| var expectedCode = """ | ||
| namespace Library | ||
|
|
||
| module Say = | ||
| let hello name = | ||
| printfn "Hello %s" name | ||
|
|
||
| """; | ||
|
|
||
| await solutionExplorer.CreateSolutionAsync(nameof(CreateProjectTests), token); | ||
| await solutionExplorer.AddProjectAsync("Library", template, token); | ||
|
|
||
| var actualCode = await editor.GetTextAsync(token); | ||
|
|
||
| Assert.Equal(expectedCode, actualCode); | ||
| } | ||
|
|
||
| [IdeFact] | ||
| public async Task ConsoleApp_Async() | ||
| { | ||
| var token = HangMitigatingCancellationToken; | ||
| var template = WellKnownProjectTemplates.FSharpNetCoreConsoleApplication; | ||
| var solutionExplorer = TestServices.SolutionExplorer; | ||
| var editor = TestServices.Editor; | ||
|
|
||
| var expectedCode = """ | ||
| // For more information see https://aka.ms/fsharp-console-apps | ||
| printfn "Hello from F#" | ||
|
|
||
| """; | ||
|
|
||
| await solutionExplorer.CreateSolutionAsync(nameof(CreateProjectTests), token); | ||
| await solutionExplorer.AddProjectAsync("ConsoleApp", template, token); | ||
|
|
||
| var actualCode = await editor.GetTextAsync(token); | ||
|
|
||
| Assert.Equal(expectedCode, actualCode); | ||
| } | ||
|
|
||
| [IdeFact] | ||
| public async Task XUnitTestProject_Async() | ||
| { | ||
| var token = HangMitigatingCancellationToken; | ||
| var template = WellKnownProjectTemplates.FSharpNetCoreXUnitTest; | ||
| var solutionExplorer = TestServices.SolutionExplorer; | ||
| var editor = TestServices.Editor; | ||
|
|
||
| var expectedCode = """ | ||
| module Tests | ||
|
|
||
| open System | ||
| open Xunit | ||
|
|
||
| [<Fact>] | ||
| let ``My test`` () = | ||
| Assert.True(true) | ||
|
|
||
| """; | ||
|
|
||
| await solutionExplorer.CreateSolutionAsync(nameof(CreateProjectTests), token); | ||
| await solutionExplorer.AddProjectAsync("ConsoleApp", template, token); | ||
|
|
||
| var actualCode = await editor.GetTextAsync(token); | ||
|
|
||
| Assert.Equal(expectedCode, actualCode); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
vsintegration/tests/FSharp.Editor.IntegrationTests/FSharp.Editor.IntegrationTests.csproj
This file contains hidden or 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,32 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net472</TargetFramework> | ||
| <LangVersion>preview</LangVersion> | ||
| <Nullable>enable</Nullable> | ||
| <UnitTestType>xunit</UnitTestType> | ||
| <IsPackable>false</IsPackable> | ||
| <GenerateProgramFile>false</GenerateProgramFile> | ||
| <AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Remove="xunit.runner.json" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Content Include="xunit.runner.json"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </Content> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.VisualStudio.Editor" Version="$(MicrosoftVisualStudioEditorVersion)" /> | ||
| <PackageReference Include="Microsoft.VisualStudio.Extensibility.Testing.Xunit" Version="$(MicrosoftVisualStudioExtensibilityTestingSourceGeneratorVersion)" /> | ||
| <PackageReference Include="Microsoft.VisualStudio.Extensibility.Testing.SourceGenerator" Version="$(MicrosoftVisualStudioExtensibilityTestingSourceGeneratorVersion)" /> | ||
| <PackageReference Include="Microsoft.VisualStudio.Language.Intellisense" Version="$(MicrosoftVisualStudioLanguageIntellisenseVersion)" /> | ||
| <PackageReference Include="NuGet.SolutionRestoreManager.Interop" Version="$(NuGetSolutionRestoreManagerInteropVersion)" /> | ||
| <PackageReference Include="Nullable" Version="1.3.0" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.