Skip to content

Commit da2d7f0

Browse files
committed
Fixed CompilerAssert for non-windows; Updated README
1 parent 79846a4 commit da2d7f0

8 files changed

Lines changed: 111 additions & 46 deletions

File tree

FSharp.sln

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "DependencyManager", "src\fs
5454
EndProject
5555
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.ComponentTests", "tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj", "{FAC5A3BF-C0D6-437A-868A-E962AA00B418}"
5656
EndProject
57+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fsharpqa", "fsharpqa", "{292C4F92-A313-4CAF-9552-731F39C6C21F}"
58+
EndProject
59+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testenv", "testenv", "{FF76050A-415A-4FB4-A0E5-13CBF38D83E0}"
60+
EndProject
61+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{07482B5E-4980-4285-B732-820F15870284}"
62+
EndProject
63+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PEVerify", "tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj", "{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}"
64+
EndProject
5765
Global
5866
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5967
Debug|Any CPU = Debug|Any CPU
@@ -292,6 +300,18 @@ Global
292300
{FAC5A3BF-C0D6-437A-868A-E962AA00B418}.Release|Any CPU.Build.0 = Release|Any CPU
293301
{FAC5A3BF-C0D6-437A-868A-E962AA00B418}.Release|x86.ActiveCfg = Release|Any CPU
294302
{FAC5A3BF-C0D6-437A-868A-E962AA00B418}.Release|x86.Build.0 = Release|Any CPU
303+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
304+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Debug|Any CPU.Build.0 = Debug|Any CPU
305+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Debug|x86.ActiveCfg = Debug|Any CPU
306+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Debug|x86.Build.0 = Debug|Any CPU
307+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Proto|Any CPU.ActiveCfg = Debug|Any CPU
308+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Proto|Any CPU.Build.0 = Debug|Any CPU
309+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Proto|x86.ActiveCfg = Debug|Any CPU
310+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Proto|x86.Build.0 = Debug|Any CPU
311+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Release|Any CPU.ActiveCfg = Release|Any CPU
312+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Release|Any CPU.Build.0 = Release|Any CPU
313+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Release|x86.ActiveCfg = Release|Any CPU
314+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20}.Release|x86.Build.0 = Release|Any CPU
295315
EndGlobalSection
296316
GlobalSection(SolutionProperties) = preSolution
297317
HideSolutionNode = FALSE
@@ -315,6 +335,10 @@ Global
315335
{4FEDF286-0252-4EBC-9E75-879CCA3B85DC} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
316336
{B5A043F8-6D7F-4D4E-B8AD-5880070180B6} = {3881429D-A97A-49EB-B7AE-A82BA5FE9C77}
317337
{FAC5A3BF-C0D6-437A-868A-E962AA00B418} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
338+
{292C4F92-A313-4CAF-9552-731F39C6C21F} = {CFE3259A-2D30-4EB0-80D5-E8B5F3D01449}
339+
{FF76050A-415A-4FB4-A0E5-13CBF38D83E0} = {292C4F92-A313-4CAF-9552-731F39C6C21F}
340+
{07482B5E-4980-4285-B732-820F15870284} = {FF76050A-415A-4FB4-A0E5-13CBF38D83E0}
341+
{25568CD2-E654-4C8F-BE5B-59BABFC5BD20} = {07482B5E-4980-4285-B732-820F15870284}
318342
EndGlobalSection
319343
GlobalSection(ExtensibilityGlobals) = postSolution
320344
SolutionGuid = {BD5177C7-1380-40E7-94D2-7768E1A8B1B8}

tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
<PropertyGroup>
66
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
77
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.0</TargetFrameworks>
8+
<ReferenceVsAssemblies>true</ReferenceVsAssemblies>
89
<OutputType>Library</OutputType>
910
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
11+
<Optimize>false</Optimize>
12+
<Tailcalls>false</Tailcalls>
1013
<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
1114
<UnitTestType>xunit</UnitTestType>
12-
<NoWarn>$(NoWarn);3186;1104</NoWarn>
15+
<NoWarn>$(NoWarn);3186;1104;FS0988</NoWarn>
1316
</PropertyGroup>
1417

1518
<ItemGroup>

tests/FSharp.Test.Utilities/CompilerAssert.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ let main argv = 0"""
125125
File.WriteAllText(programFsFileName, programFs)
126126

127127
let pInfo = ProcessStartInfo ()
128-
129128
pInfo.FileName <- config.DotNetExe
130129
pInfo.Arguments <- "build"
131130
pInfo.WorkingDirectory <- projectDirectory
@@ -147,7 +146,7 @@ let main argv = 0"""
147146
cleanUp <- false
148147
printfn "%s" output
149148
printfn "%s" errors
150-
raise (new Exception (sprintf "An error occured getting netcoreapp references: %A" e))
149+
raise (new Exception (sprintf "An error occurred getting netcoreapp references: %A" e))
151150
finally
152151
if cleanUp then
153152
try Directory.Delete(projectDirectory) with | _ -> ()

tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
55
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.0</TargetFrameworks>
6-
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
6+
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
77
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81</AssetTargetFallback>
88
<ReferenceVsAssemblies>true</ReferenceVsAssemblies>
99
<OutputType>Library</OutputType>

tests/FSharp.Test.Utilities/TestFramework.fs

Lines changed: 77 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -142,41 +142,72 @@ type TestConfig =
142142
DotNetExe: string
143143
DefaultPlatform: string}
144144

145+
#if NETCOREAPP
146+
open System.Runtime.InteropServices
147+
#endif
145148

146-
module WindowsPlatform =
147-
let Is64BitOperatingSystem envVars =
148-
// On Windows PROCESSOR_ARCHITECTURE has the value AMD64 on 64 bit Intel Machines
149-
let value =
150-
let find s = envVars |> Map.tryFind s
151-
[| "PROCESSOR_ARCHITECTURE" |] |> Seq.tryPick (fun s -> find s) |> function None -> "" | Some x -> x
152-
value = "AMD64"
149+
let getOperatingSystem () =
150+
#if NETCOREAPP
151+
let isPlatform p = RuntimeInformation.IsOSPlatform(p)
152+
if isPlatform OSPlatform.Windows then "win"
153+
elif isPlatform OSPlatform.Linux then "linux"
154+
elif isPlatform OSPlatform.OSX then "osx"
155+
else "unknown"
156+
#else
157+
"win"
158+
#endif
153159

154-
type FSLibPaths =
160+
module DotnetPlatform =
161+
let Is64BitOperatingSystem envVars =
162+
match getOperatingSystem () with
163+
| "win" ->
164+
// On Windows PROCESSOR_ARCHITECTURE has the value AMD64 on 64 bit Intel Machines
165+
let value =
166+
let find s = envVars |> Map.tryFind s
167+
[| "PROCESSOR_ARCHITECTURE" |] |> Seq.tryPick (fun s -> find s) |> function None -> "" | Some x -> x
168+
value = "AMD64"
169+
| _ -> System.Environment.Is64BitOperatingSystem // As an alternative for netstandard1.4+: System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture
170+
171+
type FSLibPaths =
155172
{ FSCOREDLLPATH : string }
156173

157-
let requireFile nm =
158-
if Commands.fileExists __SOURCE_DIRECTORY__ nm |> Option.isSome then nm else failwith (sprintf "couldn't find %s. Running 'build test' once might solve this issue" nm)
159-
160-
let packagesDir =
161-
match Environment.GetEnvironmentVariable("NUGET_PACKAGES") with
162-
| null -> Environment.GetEnvironmentVariable("USERPROFILE") ++ ".nuget" ++ "packages"
163-
| path -> path
174+
let getPackagesDir () =
175+
let p = match Environment.GetEnvironmentVariable("NUGET_PACKAGES") with
176+
| null ->
177+
match Environment.GetEnvironmentVariable("USERPROFILE") with
178+
| null -> Environment.GetEnvironmentVariable("HOME")
179+
| p -> p
180+
| path -> path
181+
p ++ ".nuget" ++ "packages"
182+
183+
let requireFile dir path =
184+
// Linux filesystems are (in most cases) case-sensitive.
185+
// However when nuget packages are installed to $HOME/.nuget/packages, it seems they are lowercased
186+
let fullPath = (dir ++ path)
187+
match Commands.fileExists __SOURCE_DIRECTORY__ fullPath with
188+
| Some p -> p
189+
| None ->
190+
let fullPathLower = (dir ++ path.ToLower())
191+
match Commands.fileExists __SOURCE_DIRECTORY__ fullPathLower with
192+
| Some p -> p
193+
| None -> failwith (sprintf "Couldn't find \"%s\" on the following paths: \"%s\", \"%s\". Running 'build test' once might solve this issue" path fullPath fullPathLower)
164194

165195
let config configurationName envVars =
166-
167196
let SCRIPT_ROOT = __SOURCE_DIRECTORY__
168197
#if NET472
169198
let fscArchitecture = "net472"
170199
let fsiArchitecture = "net472"
171200
let fsharpCoreArchitecture = "net45"
172201
let fsharpBuildArchitecture = "net472"
173202
let fsharpCompilerInteractiveSettingsArchitecture = "net472"
203+
let peverifyArchitecture = "net472"
174204
#else
175205
let fscArchitecture = "netcoreapp3.0"
176206
let fsiArchitecture = "netcoreapp3.0"
177207
let fsharpCoreArchitecture = "netstandard2.0"
178208
let fsharpBuildArchitecture = "netcoreapp3.0"
179209
let fsharpCompilerInteractiveSettingsArchitecture = "netstandard2.0"
210+
let peverifyArchitecture = "netcoreapp3.0"
180211
#endif
181212
let repoRoot = SCRIPT_ROOT ++ ".." ++ ".."
182213
let artifactsPath = repoRoot ++ "artifacts"
@@ -185,31 +216,42 @@ let config configurationName envVars =
185216
let csc_flags = "/nologo"
186217
let fsc_flags = "-r:System.Core.dll --nowarn:20 --define:COMPILED"
187218
let fsi_flags = "-r:System.Core.dll --nowarn:20 --define:INTERACTIVE --maxerrors:1 --abortonerror"
188-
let Is64BitOperatingSystem = WindowsPlatform.Is64BitOperatingSystem envVars
219+
let operatingSystem = getOperatingSystem ()
220+
let Is64BitOperatingSystem = DotnetPlatform.Is64BitOperatingSystem envVars
189221
let architectureMoniker = if Is64BitOperatingSystem then "x64" else "x86"
190-
let CSC = requireFile (packagesDir ++ "Microsoft.Net.Compilers" ++ "2.7.0" ++ "tools" ++ "csc.exe")
191-
let ILDASM = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "ildasm.exe")
192-
let ILASM = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.ILAsm") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "ilasm.exe")
193-
let coreclrdll = requireFile (packagesDir ++ ("runtime.win-" + architectureMoniker + ".Microsoft.NETCore.Runtime.CoreCLR") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ ("win-" + architectureMoniker) ++ "native" ++ "coreclr.dll")
194-
let PEVERIFY = requireFile (artifactsBinPath ++ "PEVerify" ++ configurationName ++ "net472" ++ "PEVerify.exe")
195-
let FSI_FOR_SCRIPTS = artifactsBinPath ++ "fsi" ++ configurationName ++ fsiArchitecture ++ "fsi.exe"
196-
let FSharpBuild = requireFile (artifactsBinPath ++ "FSharp.Build" ++ configurationName ++ fsharpBuildArchitecture ++ "FSharp.Build.dll")
197-
let FSharpCompilerInteractiveSettings = requireFile (artifactsBinPath ++ "FSharp.Compiler.Interactive.Settings" ++ configurationName ++ fsharpCompilerInteractiveSettingsArchitecture ++ "FSharp.Compiler.Interactive.Settings.dll")
222+
let packagesDir = getPackagesDir ()
223+
let requirePackage = requireFile packagesDir
224+
let requireArtifact = requireFile artifactsBinPath
225+
let CSC = requirePackage ("Microsoft.Net.Compilers" ++ "2.7.0" ++ "tools" ++ "csc.exe")
226+
let ILDASM_EXE = if operatingSystem = "windows" then "ildasm.exe" else "ildasm"
227+
let ILDASM = requirePackage (("runtime." + operatingSystem + "-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ (operatingSystem + "-" + architectureMoniker) ++ "native" ++ ILDASM_EXE)
228+
let ILASM_EXE = if operatingSystem = "windows" then "ilasm.exe" else "ilasm"
229+
let ILASM = requirePackage (("runtime." + operatingSystem + "-" + architectureMoniker + ".Microsoft.NETCore.ILAsm") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ (operatingSystem + "-" + architectureMoniker) ++ "native" ++ ILASM_EXE)
230+
let CORECLR_DLL = if operatingSystem = "windows" then "coreclr.dll" elif operatingSystem = "osx" then "libcoreclr.dylib" else "libcoreclr.so"
231+
let coreclrdll = requirePackage (("runtime." + operatingSystem + "-" + architectureMoniker + ".Microsoft.NETCore.Runtime.CoreCLR") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ (operatingSystem + "-" + architectureMoniker) ++ "native" ++ CORECLR_DLL)
232+
let PEVERIFY_EXE = if operatingSystem = "windows" then "PEVerify.exe" else "PEVerify"
233+
let PEVERIFY = requireArtifact ("PEVerify" ++ configurationName ++ peverifyArchitecture ++ PEVERIFY_EXE)
234+
let FSharpBuild = requireArtifact ("FSharp.Build" ++ configurationName ++ fsharpBuildArchitecture ++ "FSharp.Build.dll")
235+
let FSharpCompilerInteractiveSettings = requireArtifact ("FSharp.Compiler.Interactive.Settings" ++ configurationName ++ fsharpCompilerInteractiveSettingsArchitecture ++ "FSharp.Compiler.Interactive.Settings.dll")
236+
198237
let dotNetExe =
199238
// first look for {repoRoot}\.dotnet\dotnet.exe, otherwise fallback to %PATH%
200-
let repoLocalDotnetPath = repoRoot ++ ".dotnet" ++ "dotnet.exe"
239+
let DOTNET_EXE = if operatingSystem = "windows" then "dotnet.exe" else "dotnet"
240+
let repoLocalDotnetPath = repoRoot ++ ".dotnet" ++ DOTNET_EXE
201241
if File.Exists(repoLocalDotnetPath) then repoLocalDotnetPath
202-
else "dotnet.exe"
242+
else DOTNET_EXE
243+
203244
// ildasm + ilasm requires coreclr.dll to run which has already been restored to the packages directory
204-
File.Copy(coreclrdll, Path.GetDirectoryName(ILDASM) ++ "coreclr.dll", overwrite=true)
205-
File.Copy(coreclrdll, Path.GetDirectoryName(ILASM) ++ "coreclr.dll", overwrite=true)
245+
File.Copy(coreclrdll, Path.GetDirectoryName(ILDASM) ++ CORECLR_DLL, overwrite=true)
246+
File.Copy(coreclrdll, Path.GetDirectoryName(ILASM) ++ CORECLR_DLL, overwrite=true)
206247

207-
let FSI = requireFile (FSI_FOR_SCRIPTS)
248+
let FSI_FOR_SCRIPTS = ("fsi" ++ configurationName ++ fsiArchitecture ++ "fsi.exe")
249+
let FSI = requireArtifact FSI_FOR_SCRIPTS
208250
#if !NETCOREAPP
209-
let FSIANYCPU = requireFile (artifactsBinPath ++ "fsiAnyCpu" ++ configurationName ++ "net472" ++ "fsiAnyCpu.exe")
251+
let FSIANYCPU = requireArtifact ("fsiAnyCpu" ++ configurationName ++ "net472" ++ "fsiAnyCpu.exe")
210252
#endif
211-
let FSC = requireFile (artifactsBinPath ++ "fsc" ++ configurationName ++ fscArchitecture ++ "fsc.exe")
212-
let FSCOREDLLPATH = requireFile (artifactsBinPath ++ "FSharp.Core" ++ configurationName ++ fsharpCoreArchitecture ++ "FSharp.Core.dll")
253+
let FSC = requireArtifact ("fsc" ++ configurationName ++ fscArchitecture ++ "fsc.exe")
254+
let FSCOREDLLPATH = requireArtifact ("FSharp.Core" ++ configurationName ++ fsharpCoreArchitecture ++ "FSharp.Core.dll")
213255

214256
let defaultPlatform =
215257
match Is64BitOperatingSystem with
@@ -279,9 +321,9 @@ let envVars () =
279321
let initializeSuite () =
280322

281323
#if DEBUG
282-
let configurationName = "debug"
324+
let configurationName = "Debug"
283325
#else
284-
let configurationName = "release"
326+
let configurationName = "Release"
285327
#endif
286328
let env = envVars ()
287329

tests/README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ Existing FSharpQA and Cambridge need to be migrated to corresponding test projec
9393

9494
## Next steps
9595

96-
* [**In Progress**] Move `FSharp.TestHelpers` to `FSharp.Test.Utilities`.
97-
* [**In Progress**] Create initial test projects structure for new tests (`FSharp.Compiler.ComponentTests`).
9896
* [**In Progress**] Migrate existing `NUnit` tests to xUnit.
99-
* [**In progress**] Change build scripts to run new suites as well as old ones.
97+
* Clean up CompilerAssert.
98+
* Make PEVerify tests work in netcore/non-windows environment.
10099
* Start migration of existing (namely, FSharpQA and Cambridge) suites to xUnit-based projects.
101100

102101
## Open questions:
@@ -108,5 +107,3 @@ Existing FSharpQA and Cambridge need to be migrated to corresponding test projec
108107
Related issues: (https://github.com/dotnet/fsharp/issues/7075)
109108

110109
You can find this document under 'tests/README.md'.
111-
112-
**I would like to hear some feedback the community, so we can quickly re-iterate over it (if needed), and start working :)**

tests/fsharp/FSharpSuite.Tests.fsproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
<Compile Include="Compiler\ErrorMessages\WarnExpressionTests.fs" />
5050
<Compile Include="Compiler\ErrorMessages\DontSuggestTests.fs" />
5151
<Compile Include="Compiler\ErrorMessages\MissingExpressionTests.fs" />
52-
<Compile Include="Compiler\ErrorMessages\InvalidNumericLiteralTests.fs" />
5352
<Compile Include="Compiler\ErrorMessages\ModuleAbbreviationTests.fs" />
5453
<Compile Include="Compiler\Warnings\AssignmentWarningTests.fs" />
5554
<Compile Include="Compiler\Warnings\ExperimentalAttributeTests.fs" />

tests/fsharpqa/testenv/src/PEVerify/PEVerify.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net472</TargetFramework>
5+
<TargetFrameworks>net472;netcoreapp3.0</TargetFrameworks>
6+
<TargetFrameworks Condition="'$(OS)' == 'Unix'">netcoreapp3.0</TargetFrameworks>
67
<NoWarn>$(NoWarn);1591</NoWarn>
78
</PropertyGroup>
89

0 commit comments

Comments
 (0)