Skip to content
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

add test case for fake interop and update FAKE package #566

Merged
merged 1 commit into from
Mar 8, 2020
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: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"fake-cli": {
"version": "5.19.0",
"version": "5.20.0-alpha.1545",
"commands": [
"fake"
]
Expand Down
12 changes: 9 additions & 3 deletions .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperExeDir Condition=" Exists('$(PaketBootStrapperExePath)') " >$([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\</PaketBootStrapperExeDir>

<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT' ">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
<PaketBootStrapperCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>

<!-- Disable automagic references for F# DotNet SDK -->
<!-- This will not do anything for other project types -->
<!-- see https://github.com/fsharp/fslang-design/blob/master/tooling/FST-1002-fsharp-in-dotnet-sdk.md -->
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>

<!-- Disable Paket restore under NCrunch build -->
<PaketRestoreDisabled Condition="'$(NCrunch)' == '1'">True</PaketRestoreDisabled>

Expand Down Expand Up @@ -130,7 +136,7 @@
<!-- Parse our simple 'paket.restore.cached' json ...-->
<PaketRestoreCachedSplitObject Include="$([System.Text.RegularExpressions.Regex]::Split(`$(PaketRestoreCachedContents)`, `{|}|,`))"></PaketRestoreCachedSplitObject>
<!-- Keep Key, Value ItemGroup-->
<PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)"
<PaketRestoreCachedKeyValue Include="@(PaketRestoreCachedSplitObject)"
Condition=" $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `&quot;: &quot;`).Length) &gt; 1 ">
<Key>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))</Key>
<Value>$([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))</Value>
Expand Down Expand Up @@ -163,7 +169,7 @@
<Exec Command='$(PaketBootStrapperCommand)' Condition=" '$(PaketBootstrapperStyle)' == 'classic' AND Exists('$(PaketBootStrapperExePath)') AND !(Exists('$(PaketExePath)'))" ContinueOnError="false" />
<Error Text="Stop build because of PAKET_ERROR_ON_MSBUILD_EXEC and we need a full restore (hashes don't match)" Condition=" '$(PAKET_ERROR_ON_MSBUILD_EXEC)' == 'true' AND '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true'" />
<Exec Command='$(PaketCommand) restore' Condition=" '$(PaketRestoreRequired)' == 'true' AND '$(PaketDisableGlobalRestore)' != 'true' " ContinueOnError="false" />

<!-- Step 2 Detect project specific changes -->
<ItemGroup>
<MyTargetFrameworks Condition="'$(TargetFramework)' != '' " Include="$(TargetFramework)"></MyTargetFrameworks>
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Product>FsAutoComplete</Product>
<Description>A command line tool for interfacing with FSharp.Compiler.Service over a pipe.</Description>
<PackageLicenseExpression Condition=" '$(PackAsTool)' != 'true' ">Apache-2.0</PackageLicenseExpression>
<NoWarn>3186</NoWarn><!-- circumvent an error with the fake dependencymanager for paket: https://github.com/dotnet/fsharp/issues/8678 -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

Expand Down
11 changes: 7 additions & 4 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ NUGET
Destructurama.FSharp (1.1.1-dev-00035)
FSharp.Core (>= 4.3.4) - restriction: || (&& (== net461) (>= netstandard1.6)) (== netcoreapp2.1) (== netstandard2.0)
Serilog (>= 2.0 < 3.0) - restriction: || (&& (== net461) (>= netstandard1.6)) (== netcoreapp2.1) (== netstandard2.0)
Fake.Core.Context (5.19.1) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Fake.Core.Context (5.20.0-alpha.1545) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
FSharp.Core (>= 4.7) - restriction: || (&& (== net461) (>= net462)) (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Fake.Runtime (5.19.1)
Fake.Core.Context (>= 5.19.1) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
FSharp.Compiler.Service (>= 33.0.1) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Fake.Core.DependencyManager.Paket (5.20.0-alpha.1545) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
FSharp.Core (>= 4.7) - restriction: || (&& (== net461) (>= net462)) (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Fake.Runtime (5.20.0-alpha.1545)
Fake.Core.Context (>= 5.20.0-alpha.1545) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Fake.Core.DependencyManager.Paket (>= 5.20.0-alpha.1545) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
FSharp.Compiler.Service (>= 34.1.1) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
FSharp.Core (>= 4.7) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Microsoft.DotNet.PlatformAbstractions (>= 2.1) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Mono.Cecil (>= 0.11.1) - restriction: || (&& (== net461) (>= netstandard2.0)) (== netcoreapp2.1) (== netstandard2.0)
Expand Down
8 changes: 4 additions & 4 deletions src/FsAutoComplete.Core/CompilerServiceInterface.fs
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,10 @@ type FSharpCompilerServiceChecker(backgroundServiceEnabled) =
match errors with
| [] ->
let refs, otherOpts = projOptions.OtherOptions |> Array.partition (fun o -> o.StartsWith("-r"))
logQueueLength optsLogger (Log.setMessage "Resolved references" >> Log.addContextDestructured "refs" refs)
logQueueLength optsLogger (Log.setMessage "Resolved other options" >> Log.addContextDestructured "otherOpts" otherOpts)
logQueueLength optsLogger (Log.setMessage "Resolved references: {refs}" >> Log.addContextDestructured "refs" refs)
logQueueLength optsLogger (Log.setMessage "Resolved other options: {otherOpts}" >> Log.addContextDestructured "otherOpts" otherOpts)
| errs ->
logQueueLength optsLogger (Log.setLogLevel LogLevel.Error >> Log.setMessage "Resolved options with errors" >> Log.addContextDestructured "opts" projOptions >> Log.addContextDestructured "errors" errs)
logQueueLength optsLogger (Log.setLogLevel LogLevel.Error >> Log.setMessage "Resolved {opts} with {errors}" >> Log.addContextDestructured "opts" projOptions >> Log.addContextDestructured "errors" errs)

try
match FakeSupport.detectFakeScript file with
Expand All @@ -631,7 +631,7 @@ type FSharpCompilerServiceChecker(backgroundServiceEnabled) =
logQueueLength optsLogger (Log.setMessage "{file} is a FAKE script" >> Log.addContextDestructured "file" file)
try
let otherOpts = FakeSupport.getProjectOptions detectionInfo
logQueueLength optsLogger (Log.setMessage "Discovered FAKE options" >> Log.addContextDestructured "file" file >> Log.addContextDestructured "otherOpts" otherOpts)
logQueueLength optsLogger (Log.setMessage "Discovered FAKE options {otherOpts} " >> Log.addContextDestructured "file" file >> Log.addContextDestructured "otherOpts" otherOpts)
return { projOptions with OtherOptions = otherOpts }
with e ->
logQueueLength optsLogger (Log.setLogLevel LogLevel.Error >> Log.setMessage "Error in FAKE script support" >> Log.addExn e)
Expand Down
11 changes: 11 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/TestCases/FakeInterop/build.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#r "paket:
nuget Fake.Core.Target //"

#load "./.fake/build.fsx/intellisense.fsx"

open Fake.Core

// Default target
Target.create "Default" (fun _ ->
Trace.trace "Hello World from FAKE"
)
21 changes: 21 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,26 @@ let formattingTests =
))
]

let fakeInteropTests =
let serverStart = lazy (
let folderPath = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "FakeInterop")
let (server, events) = serverInitialize folderPath defaultConfigDto
let buildScript = "build.fsx"
do waitForWorkspaceFinishedParsing events
server, events, folderPath, buildScript
)
let serverTest f () = f serverStart.Value

testList "fake integration" [
testCase "can typecheck a fake script including uses of paket-delivered types" (serverTest (fun (server, events, rootPath, scriptName) ->
do server.TextDocumentDidOpen { TextDocument = loadDocument (Path.Combine(rootPath, scriptName)) } |> Async.RunSynchronously
match waitForParseResultsForFile scriptName events with
| Ok () ->
() // all good, no parsing/checking errors
| Core.Result.Error errors ->
failwithf "Errors while parsing script %s: %A" (Path.Combine(rootPath, scriptName)) errors
))
]
///Global list of tests
let tests =
testSequenced <| testList "lsp" [
Expand All @@ -998,4 +1018,5 @@ let tests =
scriptEvictionTests
tooltipTests
formattingTests
fakeInteropTests
]