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

Make test explorer work with fsac tests and fix an expecto test detection #1165

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ nuget Microsoft.NETFramework.ReferenceAssemblies
nuget Ionide.KeepAChangelog.Tasks copy_local: true
nuget Expecto
nuget Expecto.Diff
nuget YoloDev.Expecto.TestSdk
nuget YoloDev.Expecto.TestSdk 0.14.2
nuget AltCover
nuget GitHubActionsTestLogger
nuget Ionide.LanguageServerProtocol >= 0.4.16
Expand Down
14 changes: 7 additions & 7 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ NUGET
Microsoft.SourceLink.Bitbucket.Git (>= 1.1.1)
Microsoft.SourceLink.GitHub (>= 1.1.1)
Microsoft.SourceLink.GitLab (>= 1.1.1)
Expecto (9.0.4)
FSharp.Core (>= 4.6)
Mono.Cecil (>= 0.11.3)
Expecto (10.1)
FSharp.Core (>= 7.0.200) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Mono.Cecil (>= 0.11.4 < 1.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
Expecto.Diff (9.0.4)
DiffPlex (>= 1.6.3)
Expecto (>= 9.0.4)
Expand Down Expand Up @@ -485,10 +485,10 @@ NUGET
System.Runtime.CompilerServices.Unsafe (>= 4.5.3) - restriction: || (&& (== net6.0) (>= net461)) (&& (== net6.0) (< netcoreapp2.1)) (&& (== net6.0) (< netstandard1.0)) (&& (== net6.0) (< netstandard2.0)) (&& (== net6.0) (>= wp8)) (&& (== net7.0) (>= net461)) (&& (== net7.0) (< netcoreapp2.1)) (&& (== net7.0) (< netstandard1.0)) (&& (== net7.0) (< netstandard2.0)) (&& (== net7.0) (>= wp8)) (== netstandard2.0) (== netstandard2.1)
System.Windows.Extensions (7.0) - copy_local: false, restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
System.Drawing.Common (>= 7.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
YoloDev.Expecto.TestSdk (0.13.3)
Expecto (>= 9.0 < 10.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
FSharp.Core (>= 4.6.2) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
System.Collections.Immutable (>= 6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= netcoreapp3.1)) (&& (== netstandard2.1) (>= netcoreapp3.1))
YoloDev.Expecto.TestSdk (0.14.2)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expecto Test SDK added support for Filter Expressions in 0.14.2

Expecto (>= 10.0 < 11.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
FSharp.Core (>= 7.0.200) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))
System.Collections.Immutable (>= 6.0) - restriction: || (== net6.0) (== net7.0) (&& (== netstandard2.0) (>= net6.0)) (&& (== netstandard2.1) (>= net6.0))

GROUP Build
STORAGE: NONE
Expand Down
10 changes: 5 additions & 5 deletions test/FsAutoComplete.Tests.Lsp/EmptyFileTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ let tests state =
[
testCaseAsync
"no parsing/checking errors"
(async {
<| async {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a necessary change but showing that we're still missing some extremely complex syntax pattern match to be able to see the runnable part on the side. (See nothing next to async ({ .. }) vs async <| having an icon)

image

let! server, events, scriptPath = server1
do! server.TextDocumentDidOpen { TextDocument = loadDocument scriptPath }

match! waitForParseResultsForFile "EmptyFile.fsx" events with
| Ok _ -> () // all good, no parsing/checking errors
| Core.Result.Error errors -> failwithf "Errors while parsing script %s: %A" scriptPath errors
})
}

testCaseAsync
"auto completion does not throw and is empty"
(async {
Expand All @@ -66,7 +66,7 @@ let tests state =
(async {
let! server, events, scriptPath = server2
do! server.TextDocumentDidOpen { TextDocument = loadDocument scriptPath }

do! server.TextDocumentDidChange {
TextDocument = { Uri = Path.FilePathToUri scriptPath; Version = 1 }
ContentChanges = [| {
Expand Down Expand Up @@ -106,4 +106,4 @@ let tests state =
| Ok None -> failtest "Should have gotten some completion items"
| Error e -> failtestf "Got an error while retrieving completions: %A" e
})
]]
]]
14 changes: 9 additions & 5 deletions test/FsAutoComplete.Tests.Lsp/Helpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,15 @@ let inline expectExitCodeZero (r: BufferedCommandResult) =
0
$"Expected exit code zero but was %i{r.ExitCode}.\nStdOut: %s{r.StandardOutput}\nStdErr: %s{r.StandardError}"

let dotnetRestore dir =
runProcess dir "dotnet" "restore" |> Async.map expectExitCodeZero

let dotnetToolRestore dir =
runProcess dir "dotnet" "tool restore" |> Async.map expectExitCodeZero
let dotnetRestore dir = async {
let! r = runProcess (DirectoryInfo(dir).FullName) "dotnet" "restore -v d"
return expectExitCodeZero r
}
Comment on lines +542 to +545
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Async.map actually makes it hard to get correct stack tracing.

This was throwing on debug attaching for some reason. I was getting:

   Assembly loaded during TaskRun (NuGet.Build.Tasks.GetRestoreSettingsTask): System.Diagnostics.StackTrace, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (location: C:\\Program Files\\dotnet\\shared\\Microsoft.NETCore.App\\7.0.11\\System.Diagnostics.StackTrace.dll, MVID: a66c8790-3b61-402e-b635-09e18e1fbd38, AppDomain: [Default])
         System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
            at System.ArgumentNullException.Throw(String paramName)
            at System.IO.Path.Combine(String path1, String path2)
            at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder)
            at NuGet.Configuration.XPlatMachineWideSetting..ctor()
            at NuGet.Build.Tasks.GetRestoreSettingsTask.<>c.<.cctor>b__85_0()
            at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
            at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
            at System.Lazy`1.CreateValue()
            at NuGet.Build.Tasks.RestoreSettingsUtils.ReadSettings(String solutionDirectory, String restoreDirectory, String restoreConfigFile, Lazy`1 machineWideSettings, SettingsLoadingContext settingsLoadContext)
            at NuGet.Build.Tasks.GetRestoreSettingsTask.Execute()
       Done executing task \"GetRestoreSettingsTask\" -- FAILED.


let dotnetToolRestore dir = async {
let! r = runProcess (DirectoryInfo(dir).FullName) "dotnet" "tool restore"
return expectExitCodeZero r
}

let serverInitialize path (config: FSharpConfigDto) createServer =
async {
Expand Down
17 changes: 8 additions & 9 deletions test/FsAutoComplete.Tests.Lsp/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,13 @@ let main args =

let cts = new CancellationTokenSource(testTimeout)

let config =
{ defaultConfig with
// failOnFocusedTests = true
printer = Expecto.Impl.TestPrinters.summaryWithLocationPrinter defaultConfig.printer
verbosity = logLevel
// runInParallel = false
}

runTestsWithArgsAndCancel cts.Token config fixedUpArgs tests
let args =
[
CLIArguments.Printer (Expecto.Impl.TestPrinters.summaryWithLocationPrinter defaultConfig.printer)
CLIArguments.Verbosity logLevel
// CLIArguments.Parallel
]

runTestsWithCLIArgsAndCancel cts.Token args fixedUpArgs tests
Comment on lines +248 to +255
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mechanical shift to new API.



1 change: 0 additions & 1 deletion test/FsAutoComplete.Tests.Lsp/Utils/Server.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ let tests state = testList (nameof(Server)) [

testSequenced <| testList "contesting" [
let projectDir = inTestCases "Project"
dotnetRestore projectDir.Value |> Async.RunSynchronously
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was causing using the new debug feature to fail. Guessing this was here before we started doing restores in the serverInit functions.

serverTestList "dir with project and no analyzers" state noAnalyzersConfig projectDir (fun server -> [
testCaseAsync "can load file in project" (async {
let! (doc, diags) = server |> Server.openDocument "Other.fs"
Expand Down
Loading