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

Conversation

TheAngryByrd
Copy link
Member

@TheAngryByrd TheAngryByrd commented Sep 17, 2023

WHAT

🤖 Generated by Copilot at 841c093

This pull request improves the test suite for the LSP features of FsAutoComplete by fixing a build error, reformatting a test file, and enhancing the test setup and runner functions. It also updates the paket.dependencies file and removes a redundant call to dotnetRestore in one of the test files.

🤖 Generated by Copilot at 841c093

To fix a build error they faced
They updated YoloDev.Expecto.TestSdk
They also improved the test setup and run
With DirectoryInfo and -v d for fun
And reformatted EmptyFileTests.fs for heck

📦🛠️🧹

WHY

Project work to make Test Run Debugger usable in FSAC.

debug-test-from-ionide2.mp4

HOW

🤖 Generated by Copilot at 841c093

  • Fixed a build error by pinning the version of YoloDev.Expecto.TestSdk to 0.14.2 in paket.dependencies (link)
  • Simplified the test runner configuration by using the runTestsWithCLIArgsAndCancel function in Program.fs (link)
  • Improved the test setup reliability and debugging by using the DirectoryInfo type and the -v d option for the dotnet restore command in Helpers.fs (link)
  • Removed unnecessary and redundant calls to dotnetRestore in Server.Tests.fs (link)
  • Reformatted EmptyFileTests.fs to use the <| operator and remove extra blank lines for readability and consistency (link, link, link, link)

Copy link
Member Author

@TheAngryByrd TheAngryByrd left a comment

Choose a reason for hiding this comment

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

Did self review.

cc @farlee2121 so you can see how awesome this is.

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

@@ -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

Comment on lines +542 to +545
let dotnetRestore dir = async {
let! r = runProcess (DirectoryInfo(dir).FullName) "dotnet" "restore -v d"
return expectExitCodeZero r
}
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.

Comment on lines +248 to +255
let args =
[
CLIArguments.Printer (Expecto.Impl.TestPrinters.summaryWithLocationPrinter defaultConfig.printer)
CLIArguments.Verbosity logLevel
// CLIArguments.Parallel
]

runTestsWithCLIArgsAndCancel cts.Token args fixedUpArgs tests
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.

@@ -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.

@TheAngryByrd TheAngryByrd marked this pull request as ready for review September 17, 2023 17:54
@TheAngryByrd TheAngryByrd force-pushed the make-test-explorer-work-with-fsac-tests branch from 76c32f5 to 36e4c5c Compare September 17, 2023 18:45
Comment on lines +145 to +146
| Case, SynExpr.Paren(expr = SynExpr.App(argExpr = SynExpr.ComputationExpr _))
| Case, SynExpr.Paren(expr = (SynExpr.Lambda _)) ->
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated Pattern matching to find testCaseAsync "test paren" (async { ... })

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

@baronfel baronfel left a comment

Choose a reason for hiding this comment

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

Let's goooo

@TheAngryByrd
Copy link
Member Author

Tangent: I've noticed mac builds failing on so many repositories, makes me think they're busted for dotnet right now.

@TheAngryByrd TheAngryByrd changed the title Make test explorer work with fsac tests Make test explorer work with fsac tests and add an expecto detection Sep 17, 2023
@TheAngryByrd TheAngryByrd changed the title Make test explorer work with fsac tests and add an expecto detection Make test explorer work with fsac tests and fix an expecto test detection Sep 17, 2023
@TheAngryByrd TheAngryByrd merged commit 2522cff into ionide:main Sep 17, 2023
7 of 9 checks passed
nojaf pushed a commit to nojaf/FsAutoComplete that referenced this pull request Nov 3, 2023
…tion (ionide#1165)

* update Expecto to use FilterExpression

* fix ability to debug some tests

* unset yolodev dependency restriction

* expand expecto test detection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants