Skip to content

Commit 90e20cb

Browse files
committed
Merge pull request #561 from ncave/netcore
Dotnet Core tests - wip
2 parents 5a87eb9 + ee55c10 commit 90e20cb

29 files changed

+1063
-314
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Build Status
1919

2020
Head (branch ``master``), Mono 3.x, OSX + unit tests (Travis) [![Build Status](https://travis-ci.org/fsharp/FSharp.Compiler.Service.png?branch=master)](https://travis-ci.org/fsharp/FSharp.Compiler.Service/branches)
2121

22-
Head (branch ``master``), Windows Server 2012 R2 + unit tests (AppVeyor) [![Build status](https://ci.appveyor.com/api/projects/status/3yllu2qh19brk61d)](https://ci.appveyor.com/project/fsgit/fsharp-compiler-service)
22+
Head (branch ``master``), Windows Server 2012 R2 + unit tests (AppVeyor) [![Build status](https://ci.appveyor.com/api/projects/status/3yllu2qh19brk61d?svg=true)](https://ci.appveyor.com/project/fsgit/fsharp-compiler-service)
2323

2424
NuGet Feed [![NuGet Badge](https://buildstats.info/nuget/FSharp.Compiler.Service)](https://www.nuget.org/packages/FSharp.Compiler.Service)
2525

appveyor.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
os: Windows Server 2012 R2
1+
os: Visual Studio 2015
2+
23
init:
34
- git config --global core.autocrlf input
5+
6+
environment:
7+
matrix:
8+
- BUILD_TARGET: DotnetCliTests
9+
- BUILD_TARGET: NuGet
10+
11+
matrix:
12+
allow_failures:
13+
- BUILD_TARGET: DotnetCliTests
14+
415
build_script:
5-
- cmd: build.cmd NuGet
16+
- ps: dotnet --info
17+
- cmd: build.cmd %BUILD_TARGET%
18+
619
test: off
720
version: '{build}'
821
artifacts:

build.fsx

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -230,21 +230,32 @@ Target "DotnetCliBuild" (fun _ ->
230230
let open1 = @" --open Microsoft.FSharp.Compiler.AbstractIL"
231231
let open2 = @" --open Microsoft.FSharp.Compiler"
232232
let open3 = @" --open Microsoft.FSharp.Compiler"
233-
let options = " --configuration Release"
233+
234+
// FSharp.Compiler.Service
235+
let workDir = @"src/fsharp/FSharp.Compiler.Service.netcore/"
236+
Shell.Exec("dotnet", "restore -v Minimal", workDir) |> assertExitCodeZero
237+
238+
Shell.Exec("dotnet", "fssrgen ../FSComp.txt ./FSComp.fs ./FSComp.resx", workDir) |> assertExitCodeZero
239+
Shell.Exec("dotnet", "fssrgen ../fsi/FSIstrings.txt ./FSIstrings.fs ./FSIstrings.resx", workDir) |> assertExitCodeZero
240+
Shell.Exec(fsLex, @"../lex.fsl --unicode" + lexArgs + " -o lex.fs", workDir) |> assertExitCodeZero
241+
Shell.Exec(fsLex, @"../pplex.fsl --unicode" + lexArgs + " -o pplex.fs", workDir) |> assertExitCodeZero
242+
Shell.Exec(fsLex, @"../../absil/illex.fsl --unicode" + lexArgs + " -o illex.fs", workDir) |> assertExitCodeZero
243+
Shell.Exec(fsYacc, @"../../absil/ilpars.fsy" + lexArgs + yaccArgs + module1 + open1 + " -o ilpars.fs", workDir) |> assertExitCodeZero
244+
Shell.Exec(fsYacc, @"../pars.fsy" + lexArgs + yaccArgs + module2 + open2 + " -o pars.fs", workDir) |> assertExitCodeZero
245+
Shell.Exec(fsYacc, @"../pppars.fsy" + lexArgs + yaccArgs + module3 + open3 + " -o pppars.fs", workDir) |> assertExitCodeZero
246+
247+
Shell.Exec("dotnet", "pack -c Release -o ../../../" + buildDir, workDir) |> assertExitCodeZero
234248

235-
let outPath = @"src/fsharp/FSharp.Compiler.Service.netcore/"
236-
Shell.Exec("dotnet", "restore", outPath) |> ignore //assertExitCodeZero
237-
238-
Shell.Exec("dotnet", "fssrgen ../FSComp.txt ./FSComp.fs ./FSComp.resx", outPath) |> assertExitCodeZero
239-
Shell.Exec("dotnet", "fssrgen ../fsi/FSIstrings.txt ./FSIstrings.fs ./FSIstrings.resx", outPath) |> assertExitCodeZero
240-
Shell.Exec(fsLex, @"../lex.fsl --unicode" + lexArgs + " -o lex.fs", outPath) |> assertExitCodeZero
241-
Shell.Exec(fsLex, @"../pplex.fsl --unicode" + lexArgs + " -o pplex.fs", outPath) |> assertExitCodeZero
242-
Shell.Exec(fsLex, @"../../absil/illex.fsl --unicode" + lexArgs + " -o illex.fs", outPath) |> assertExitCodeZero
243-
Shell.Exec(fsYacc, @"../../absil/ilpars.fsy" + lexArgs + yaccArgs + module1 + open1 + " -o ilpars.fs", outPath) |> assertExitCodeZero
244-
Shell.Exec(fsYacc, @"../pars.fsy" + lexArgs + yaccArgs + module2 + open2 + " -o pars.fs", outPath) |> assertExitCodeZero
245-
Shell.Exec(fsYacc, @"../pppars.fsy" + lexArgs + yaccArgs + module3 + open3 + " -o pppars.fs", outPath) |> assertExitCodeZero
246-
247-
Shell.Exec("dotnet", "--verbose pack" + options, outPath) |> assertExitCodeZero
249+
// FSharp.Compiler.Service.ProjectCracker
250+
let workDir = @"src/fsharp/FSharp.Compiler.Service.ProjectCracker.netcore/"
251+
Shell.Exec("dotnet", "restore -v Minimal", workDir) |> assertExitCodeZero
252+
Shell.Exec("dotnet", "pack -c Release -o ../../../" + buildDir, workDir) |> assertExitCodeZero
253+
)
254+
255+
Target "DotnetCliTests" (fun _ ->
256+
let workDir = @"tests/FSharp.Compiler.Service.Tests.netcore/"
257+
Shell.Exec("dotnet", "restore -v Minimal", workDir) |> assertExitCodeZero
258+
Shell.Exec("dotnet", "run", workDir) |> assertExitCodeZero
248259
)
249260

250261
// --------------------------------------------------------------------------------------
@@ -254,13 +265,17 @@ Target "Prepare" DoNothing
254265
Target "PrepareRelease" DoNothing
255266
Target "All" DoNothing
256267
Target "Release" DoNothing
268+
Target "AllDotnetCli" DoNothing
269+
270+
"AllDotnetCli"
271+
=?> ("DotnetCliBuild", isDotnetCliInstalled)
272+
=?> ("DotnetCliTests", isDotnetCliInstalled)
257273

258274
"Clean"
259275
=?> ("BuildVersion", isAppVeyorBuild)
260276
==> "AssemblyInfo"
261277
==> "GenerateFSIStrings"
262278
==> "Prepare"
263-
=?> ("DotnetCliBuild", isDotnetCliInstalled)
264279
==> "Build"
265280
==> "RunTests"
266281
==> "All"

src/fsharp/CompileOps.fs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,6 @@ let OutputErrorOrWarningContext prefix fileLineFn os err =
15431543

15441544
let GetFSharpCoreLibraryName () = "FSharp.Core"
15451545

1546-
type internal TypeInThisAssembly = class end
15471546
let GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) =
15481547
// On Mono, there is no good reference resolution
15491548
if useMonoResolution then
@@ -1555,10 +1554,10 @@ let GetFSharpCoreReferenceUsedByCompiler(useMonoResolution) =
15551554
// So use the fsharp.core.dll from alongside the fsc compiler.
15561555
// This can also be used for the out of gac work on DEV15
15571556
let fscCoreLocation =
1558-
let fscLocation = typeof<TypeInThisAssembly>.Assembly.Location
1557+
let fscLocation = typeof<Microsoft.FSharp.Core.MeasureAttribute>.Assembly.Location
15591558
Path.Combine(Path.GetDirectoryName(fscLocation), fsCoreName + ".dll")
15601559
if File.Exists(fscCoreLocation) then fsCoreName + ".dll"
1561-
else failwithf "Internal error: Could not find %s" fsCoreName
1560+
else failwithf "Internal error: Could not find %s" fscCoreLocation
15621561
#else
15631562
// check if FSharp.Core can be found from the hosting environment
15641563
let foundReference =
@@ -2119,7 +2118,12 @@ type TcConfigBuilder =
21192118
System.Diagnostics.Debug.Assert(FileSystem.IsPathRootedShim(implicitIncludeDir), sprintf "implicitIncludeDir should be absolute: '%s'" implicitIncludeDir)
21202119
if (String.IsNullOrEmpty(defaultFSharpBinariesDir)) then
21212120
failwith "Expected a valid defaultFSharpBinariesDir"
2122-
{ primaryAssembly = PrimaryAssembly.Mscorlib; // defaut value, can be overridden using the command line switch
2121+
{
2122+
#if TODO_REWORK_ASSEMBLY_LOAD
2123+
primaryAssembly = PrimaryAssembly.DotNetCore; // defaut value, can be overridden using the command line switch
2124+
#else
2125+
primaryAssembly = PrimaryAssembly.Mscorlib; // defaut value, can be overridden using the command line switch
2126+
#endif
21232127
light = None;
21242128
noFeedback=false;
21252129
stackReserveSize=None;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
5+
<clear />
6+
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
7+
<add key="fsharp-daily" value="https://www.myget.org/F/fsharp-daily/api/v3/index.json" />
8+
<add key="dotnet-buildtools" value="https://dotnet.myget.org/F/dotnet-buildtools/api/v3/index.json" />
9+
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
10+
<add key="dotnet-cli" value="https://dotnet.myget.org/F/dotnet-cli/api/v3/index.json" />
11+
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
12+
</packageSources>
13+
</configuration>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
2+
3+
open System
4+
open System.IO
5+
open System.Runtime.Serialization.Json
6+
7+
module Program =
8+
9+
[<EntryPoint>]
10+
let main argv =
11+
let text = Array.exists (fun (s: string) -> s = "--text") argv
12+
let argv = Array.filter (fun (s: string) -> s <> "--text") argv
13+
14+
let ret, opts = ProjectCrackerTool.crackOpen argv
15+
16+
if text then
17+
printfn "%A" opts
18+
else
19+
let ser = new DataContractJsonSerializer(typeof<ProjectOptions>)
20+
ser.WriteObject(Console.OpenStandardOutput(), opts)
21+
ret
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace Microsoft.FSharp.Compiler.SourceCodeServices
2+
3+
open System
4+
open System.IO
5+
open System.Text
6+
open Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
7+
8+
9+
type ProjectCracker =
10+
11+
static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
12+
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
13+
let properties = defaultArg properties []
14+
let enableLogging = defaultArg enableLogging true
15+
let logMap = ref Map.empty
16+
17+
let rec convert (opts: ProjectOptions) : FSharpProjectOptions =
18+
let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions
19+
logMap := Map.add opts.ProjectFile opts.LogOutput !logMap
20+
{
21+
ProjectFileName = opts.ProjectFile
22+
ProjectFileNames = [| |]
23+
OtherOptions = opts.Options
24+
ReferencedProjects = referencedProjects
25+
IsIncompleteTypeCheckEnvironment = false
26+
UseScriptResolutionRules = false
27+
LoadTime = loadedTimeStamp
28+
UnresolvedReferences = None
29+
}
30+
31+
let arguments = [|
32+
yield projectFileName
33+
yield enableLogging.ToString()
34+
for k, v in properties do
35+
yield k
36+
yield v
37+
|]
38+
39+
let ret, opts = ProjectCrackerTool.crackOpen arguments
40+
ignore ret
41+
convert opts, !logMap
42+
43+
static member GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) =
44+
fst (ProjectCracker.GetProjectOptionsFromProjectFileLogged(
45+
projectFileName,
46+
?properties=properties,
47+
?loadedTimeStamp=loadedTimeStamp,
48+
enableLogging=false))
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Microsoft.FSharp.Compiler.SourceCodeServices.ProjectCrackerTool
2+
3+
[<CLIMutable>]
4+
type ProjectOptions =
5+
{
6+
ProjectFile: string
7+
Options: string[]
8+
ReferencedProjectOptions: (string * ProjectOptions)[]
9+
LogOutput: string
10+
}

0 commit comments

Comments
 (0)