Skip to content
Merged
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
18 changes: 16 additions & 2 deletions tests/FSharp.Compiler.Service.Tests/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module FSharp.Compiler.Service.Tests.ProjectAnalysisTests

open System.Threading.Tasks

#nowarn "57" // Experimental stuff

let runningOnMono = try System.Type.GetType("Mono.Runtime") <> null with e -> false
Expand Down Expand Up @@ -128,8 +130,20 @@ module ClearLanguageServiceRootCachesTest =
let weakTcImports = test ()
checker.InvalidateConfiguration Project1.options
checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
GC.Collect()
System.Threading.SpinWait.SpinUntil(fun () -> not weakTcImports.IsAlive)

task {
GC.Collect()
GC.WaitForPendingFinalizers()
// Try collecting many times, because GC has some problems, especially on Linux.
// See for example: https://github.com/dotnet/runtime/discussions/108081
let mutable attempt = 1
while weakTcImports.IsAlive && attempt < 10 do
GC.Collect()
GC.WaitForPendingFinalizers()
attempt <- attempt + 1
do! Task.Delay(attempt * 1000)
Assert.False weakTcImports.IsAlive
}

[<Fact>]
let ``Test Project1 should have protected FullName and TryFullName return same results`` () =
Expand Down