Skip to content

Commit 86c023b

Browse files
ncaveKevinRansom
authored andcommitted
Fixed FCS netcore tests (#4180)
1 parent df20c32 commit 86c023b

File tree

9 files changed

+44
-48
lines changed

9 files changed

+44
-48
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,5 @@ tests/fsharpqa/testenv/bin/System.ValueTuple.dll
125125
/tests/fcs/
126126
/fcs/.paket/Paket.Restore.targets
127127
msbuild.binlog
128+
/fcs/FSharp.Compiler.Service.netstandard/*.fs
129+
/fcs/FSharp.Compiler.Service.netstandard/*.fsi

fcs/FSharp.Compiler.Service.Tests.netcore/FSharp.Compiler.Service.Tests.netcore.fsproj

+17-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp1.0</TargetFramework>
4-
<DefineConstants>$(DefineConstants);DOTNETCORE;FX_ATLEAST_45;FX_ATLEAST_PORTABLE;FX_NO_RUNTIMEENVIRONMENT;FX_RESHAPED_REFLECTION;TODO_REWORK_ASSEMBLY_LOAD;</DefineConstants>
3+
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<DefineConstants>$(DefineConstants);DOTNETCORE</DefineConstants>
5+
<DefineConstants>$(DefineConstants);FX_ATLEAST_45</DefineConstants>
6+
<DefineConstants>$(DefineConstants);FX_ATLEAST_PORTABLE</DefineConstants>
7+
<DefineConstants>$(DefineConstants);FX_NO_RUNTIMEENVIRONMENT</DefineConstants>
8+
<DefineConstants>$(DefineConstants);FX_RESHAPED_REFLECTION</DefineConstants>
9+
<DefineConstants>$(DefineConstants);NO_EXTENSIONTYPING</DefineConstants>
10+
<DefineConstants>$(DefineConstants);TODO_REWORK_ASSEMBLY_LOAD</DefineConstants>
511
<NoWarn>$(NoWarn);44;</NoWarn>
612
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
713
<DelaySign>true</DelaySign>
@@ -36,25 +42,21 @@
3642
<!--<Compile Include="../service/ProjectAnalysisTests.fs">
3743
<Link>ProjectAnalysisTests.fs</Link>
3844
</Compile>-->
45+
<Compile Include="../../tests/service/Program.fs">
46+
<Link>Program.fs</Link>
47+
</Compile>
3948
</ItemGroup>
4049
<ItemGroup>
4150
<ProjectReference Include="../FSharp.Compiler.Service.netstandard/FSharp.Compiler.Service.netstandard.fsproj" />
4251
</ItemGroup>
4352
<ItemGroup>
44-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
45-
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
46-
<PackageReference Include="NUnitLite" Version="3.6.1" />
47-
<PackageReference Include="NUnit" Version="3.6.1" />
48-
<PackageReference Include="FSharp.Core" Version="4.1.*" PrivateAssets="All" />
49-
<PackageReference Include="System.Runtime" Version="4.3.0" />
50-
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
51-
<PackageReference Include="System.Reflection.Metadata" Version="1.4.1" />
52-
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
53-
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
54-
<PackageReference Include="Dotnet.ProjInfo" Version="0.5.0" />
53+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
54+
<PackageReference Include="NUnit" Version="3.9.0" />
55+
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
56+
<PackageReference Include="Dotnet.ProjInfo" Version="0.9.0" />
5557
</ItemGroup>
5658
<Target Name="PrecompileScript" BeforeTargets="BeforeBuild">
57-
<Exec Command="dotnet restore &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6/Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj&quot;" />
58-
<Exec Command="dotnet build &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6/Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj&quot;" />
59+
<Exec Command="dotnet restore &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj&quot;" />
60+
<Exec Command="dotnet build &quot;$(MSBuildProjectDirectory)/../../tests/projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0/Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj&quot;" />
5961
</Target>
6062
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netstandard1.6</TargetFramework>
4-
<DebugType>portable</DebugType>
4+
<!-- <DebugType>portable</DebugType> -->
55
</PropertyGroup>
66
<ItemGroup>
77
<Compile Include="Library1.fs" />
88
</ItemGroup>
9-
<ItemGroup>
10-
<PackageReference Include="FSharp.Core" Version="4.1.*" />
11-
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
12-
</ItemGroup>
139
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace Sample_NETCoreSDK_FSharp_Library_netstandard2_0
2+
3+
type Class1() =
4+
member this.X = "F#"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>netstandard2.0</TargetFramework>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="Library1.fs" />
7+
</ItemGroup>
8+
</Project>

tests/service/Common.fs

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ let readRefs (folder : string) (projectFile: string) =
2929
let exitCode = p.ExitCode
3030
exitCode, ()
3131

32+
let projFilePath = Path.Combine(folder, projectFile)
3233
let runCmd exePath args = runProcess folder exePath (args |> String.concat " ")
3334
let msbuildExec = Dotnet.ProjInfo.Inspect.dotnetMsbuild runCmd
34-
let result = Dotnet.ProjInfo.Inspect.getProjectInfo ignore msbuildExec Dotnet.ProjInfo.Inspect.getFscArgs [] projectFile
35+
let result = Dotnet.ProjInfo.Inspect.getProjectInfo ignore msbuildExec Dotnet.ProjInfo.Inspect.getFscArgs [] projFilePath
3536
match result with
3637
| Ok(Dotnet.ProjInfo.Inspect.GetResult.FscArgs x) ->
3738
x
@@ -101,8 +102,8 @@ let fsCoreDefaultReference() =
101102

102103
let mkStandardProjectReferences () =
103104
#if DOTNETCORE
104-
let file = "Sample_NETCoreSDK_FSharp_Library_netstandard1.6.fsproj"
105-
let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard1.6")
105+
let file = "Sample_NETCoreSDK_FSharp_Library_netstandard2_0.fsproj"
106+
let projDir = Path.Combine(__SOURCE_DIRECTORY__, "../projects/Sample_NETCoreSDK_FSharp_Library_netstandard2_0")
106107
readRefs projDir file
107108
#else
108109
[ yield sysLib "mscorlib"

tests/service/EditorTests.fs

+2-10
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,12 @@ open Microsoft.FSharp.Compiler.SourceCodeServices
3636
open FSharp.Compiler.Service.Tests.Common
3737

3838
let stringMethods =
39-
#if DOTNETCORE
40-
["Chars"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals";
41-
"GetHashCode"; "GetType"; "IndexOf";
42-
"IndexOfAny"; "Insert"; "LastIndexOf"; "LastIndexOfAny";
43-
"Length"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split";
44-
"StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant";
45-
"ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"]
46-
#else
4739
["Chars"; "Clone"; "CompareTo"; "Contains"; "CopyTo"; "EndsWith"; "Equals";
4840
"GetEnumerator"; "GetHashCode"; "GetType"; "GetTypeCode"; "IndexOf";
4941
"IndexOfAny"; "Insert"; "IsNormalized"; "LastIndexOf"; "LastIndexOfAny";
5042
"Length"; "Normalize"; "PadLeft"; "PadRight"; "Remove"; "Replace"; "Split";
5143
"StartsWith"; "Substring"; "ToCharArray"; "ToLower"; "ToLowerInvariant";
5244
"ToString"; "ToUpper"; "ToUpperInvariant"; "Trim"; "TrimEnd"; "TrimStart"]
53-
#endif
5445

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

588580
enums |> shouldEqual

tests/service/PerfTests.fs

+4-5
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,15 @@ let ``Test request for parse and check doesn't check whole project`` () =
6565
let pE, tE = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
6666
(pE - pD) |> shouldEqual 0
6767
(tE - tD) |> shouldEqual 1
68-
(backgroundParseCount.Value <= 8) |> shouldEqual true // but note, the project does not get reparsed
69-
(backgroundCheckCount.Value <= 8) |> shouldEqual true // only two extra typechecks of files
68+
(backgroundParseCount.Value <= 9) |> shouldEqual true // but note, the project does not get reparsed
69+
(backgroundCheckCount.Value <= 9) |> shouldEqual true // only two extra typechecks of files
7070

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

tests/service/Program.fs

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
open System
2-
open System.IO
3-
open System.Reflection
4-
open NUnitLite
5-
open NUnit.Common
6-
7-
type private TypeInThisAssembly = class end
82

93
[<EntryPoint>]
104
let main argv =
115
printfn "Dotnet Core NUnit Tests..."
12-
let writer = new ExtendedTextWrapper(Console.Out)
13-
let runner = new AutoRun(typeof<TypeInThisAssembly>.GetTypeInfo().Assembly)
14-
runner.Execute(argv, writer, Console.In)
6+
0

0 commit comments

Comments
 (0)