Skip to content

Fixed FCS netcore tests #4180

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 1 commit into from
Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
/tests/fcs/
/fcs/.paket/Paket.Restore.targets
msbuild.binlog
/fcs/FSharp.Compiler.Service.netstandard/*.fs
/fcs/FSharp.Compiler.Service.netstandard/*.fsi
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.0</TargetFramework>
<DefineConstants>$(DefineConstants);DOTNETCORE;FX_ATLEAST_45;FX_ATLEAST_PORTABLE;FX_NO_RUNTIMEENVIRONMENT;FX_RESHAPED_REFLECTION;TODO_REWORK_ASSEMBLY_LOAD;</DefineConstants>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DefineConstants>$(DefineConstants);DOTNETCORE</DefineConstants>
<DefineConstants>$(DefineConstants);FX_ATLEAST_45</DefineConstants>
<DefineConstants>$(DefineConstants);FX_ATLEAST_PORTABLE</DefineConstants>
<DefineConstants>$(DefineConstants);FX_NO_RUNTIMEENVIRONMENT</DefineConstants>
<DefineConstants>$(DefineConstants);FX_RESHAPED_REFLECTION</DefineConstants>
<DefineConstants>$(DefineConstants);NO_EXTENSIONTYPING</DefineConstants>
<DefineConstants>$(DefineConstants);TODO_REWORK_ASSEMBLY_LOAD</DefineConstants>
<NoWarn>$(NoWarn);44;</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<DelaySign>true</DelaySign>
Expand Down Expand Up @@ -36,25 +42,21 @@
<!--<Compile Include="../service/ProjectAnalysisTests.fs">
<Link>ProjectAnalysisTests.fs</Link>
</Compile>-->
<Compile Include="../../tests/service/Program.fs">
<Link>Program.fs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
<PackageReference Include="NUnitLite" Version="3.6.1" />
<PackageReference Include="NUnit" Version="3.6.1" />
<PackageReference Include="FSharp.Core" Version="4.1.*" PrivateAssets="All" />
<PackageReference Include="System.Runtime" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.4.1" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="Dotnet.ProjInfo" Version="0.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="Dotnet.ProjInfo" Version="0.9.0" />
</ItemGroup>
<Target Name="PrecompileScript" BeforeTargets="BeforeBuild">
<Exec Command="dotnet restore &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6/Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj&quot;" />
<Exec Command="dotnet build &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6/Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj&quot;" />
<Exec Command="dotnet restore &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj&quot;" />
<Exec Command="dotnet build &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj&quot;" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<DebugType>portable</DebugType>
<!-- <DebugType>portable</DebugType> -->
</PropertyGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Sample_NETCoreSDK_FSharp_Library_netstandard2_0

type Class1() =
member this.X = "F#"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Library1.fs" />
</ItemGroup>
</Project>
7 changes: 4 additions & 3 deletions tests/service/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ let readRefs (folder : string) (projectFile: string) =
let exitCode = p.ExitCode
exitCode, ()

let projFilePath = Path.Combine(folder, projectFile)
let runCmd exePath args = runProcess folder exePath (args |> String.concat " ")
let msbuildExec = Dotnet.ProjInfo.Inspect.dotnetMsbuild runCmd
let result = Dotnet.ProjInfo.Inspect.getProjectInfo ignore msbuildExec Dotnet.ProjInfo.Inspect.getFscArgs [] projectFile
let result = Dotnet.ProjInfo.Inspect.getProjectInfo ignore msbuildExec Dotnet.ProjInfo.Inspect.getFscArgs [] projFilePath
match result with
| Ok(Dotnet.ProjInfo.Inspect.GetResult.FscArgs x) ->
x
Expand Down Expand Up @@ -101,8 +102,8 @@ let fsCoreDefaultReference() =

let mkStandardProjectReferences () =
#if DOTNETCORE
let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj"
let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6")
let file = "Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj"
let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0")
readRefs projDir file
#else
[ yield sysLib "mscorlib"
Expand Down
12 changes: 2 additions & 10 deletions tests/service/EditorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,12 @@ open Microsoft.FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Service.Tests.Common

let stringMethods =
#if DOTNETCORE
["Chars"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals";
"GetHashCode"; "GetType"; "IndexOf";
"IndexOfAny"; "Insert"; "LastIndexOf"; "LastIndexOfAny";
"Length"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split";
"StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant";
"ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"]
#else
["Chars"; "Clone"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals";
"GetEnumerator"; "GetHashCode"; "GetType"; "GetTypeCode"; "IndexOf";
"IndexOfAny"; "Insert"; "IsNormalized"; "LastIndexOf"; "LastIndexOfAny";
"Length"; "Normalize"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split";
"StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant";
"ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"]
#endif

let input =
"""
Expand Down Expand Up @@ -582,7 +573,8 @@ let test3 = System.Text.RegularExpressions.RegexOptions.Compiled
|> Array.choose(fun s -> match s.Symbol with :? FSharpEntity as e when e.IsEnum -> Some e | _ -> None)
|> Array.distinct
|> Array.map(fun e -> (e.DisplayName, e.FSharpFields
|> Seq.map(fun f -> f.Name, f.LiteralValue )
|> Seq.sortBy (fun f -> match f.LiteralValue with None -> -1 | Some x -> unbox x)
|> Seq.map (fun f -> f.Name, f.LiteralValue)
|> Seq.toList))

enums |> shouldEqual
Expand Down
9 changes: 4 additions & 5 deletions tests/service/PerfTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,15 @@ let ``Test request for parse and check doesn't check whole project`` () =
let pE, tE = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
(pE - pD) |> shouldEqual 0
(tE - tD) |> shouldEqual 1
(backgroundParseCount.Value <= 8) |> shouldEqual true // but note, the project does not get reparsed
(backgroundCheckCount.Value <= 8) |> shouldEqual true // only two extra typechecks of files
(backgroundParseCount.Value <= 9) |> shouldEqual true // but note, the project does not get reparsed
(backgroundCheckCount.Value <= 9) |> shouldEqual true // only two extra typechecks of files

// A subsequent ParseAndCheck of identical source code doesn't do any more anything
let checkResults2 = checker.ParseAndCheckFileInProject(Project1.fileNames.[7], 0, Project1.fileSources2.[7], Project1.options) |> Async.RunSynchronously
let pF, tF = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
(pF - pE) |> shouldEqual 0 // note, no new parse of the file
(tF - tE) |> shouldEqual 0 // note, no new typecheck of the file
(backgroundParseCount.Value <= 8) |> shouldEqual true // but note, the project does not get reparsed
(backgroundCheckCount.Value <= 8) |> shouldEqual true // only two extra typechecks of files

(backgroundParseCount.Value <= 9) |> shouldEqual true // but note, the project does not get reparsed
(backgroundCheckCount.Value <= 9) |> shouldEqual true // only two extra typechecks of files
()

10 changes: 1 addition & 9 deletions tests/service/Program.fs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
open System
open System.IO
open System.Reflection
open NUnitLite
open NUnit.Common

type private TypeInThisAssembly = class end

[<EntryPoint>]
let main argv =
printfn "Dotnet Core NUnit Tests..."
let writer = new ExtendedTextWrapper(Console.Out)
let runner = new AutoRun(typeof<TypeInThisAssembly>.GetTypeInfo().Assembly)
runner.Execute(argv, writer, Console.In)
0