File tree 1 file changed +16
-2
lines changed
tests/FSharp.Compiler.Service.Tests
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
module FSharp.Compiler.Service.Tests.ProjectAnalysisTests
2
2
3
+ open System.Threading .Tasks
4
+
3
5
#nowarn " 57" // Experimental stuff
4
6
5
7
let runningOnMono = try System.Type.GetType( " Mono.Runtime" ) <> null with e -> false
@@ -128,8 +130,20 @@ module ClearLanguageServiceRootCachesTest =
128
130
let weakTcImports = test ()
129
131
checker.InvalidateConfiguration Project1.options
130
132
checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
131
- GC.Collect()
132
- System.Threading.SpinWait.SpinUntil( fun () -> not weakTcImports.IsAlive)
133
+
134
+ task {
135
+ GC.Collect()
136
+ GC.WaitForPendingFinalizers()
137
+ // Try collecting many times, because GC has some problems, especially on Linux.
138
+ // See for example: https://github.com/dotnet/runtime/discussions/108081
139
+ let mutable attempt = 1
140
+ while weakTcImports.IsAlive && attempt < 10 do
141
+ GC.Collect()
142
+ GC.WaitForPendingFinalizers()
143
+ attempt <- attempt + 1
144
+ do ! Task.Delay( attempt * 1000 )
145
+ Assert.False weakTcImports.IsAlive
146
+ }
133
147
134
148
[<Fact>]
135
149
let ``Test Project1 should have protected FullName and TryFullName return same results`` () =
You can’t perform that action at this time.
0 commit comments