From 91bdb8a8e07f205300d9f7af14969dd9344f6c61 Mon Sep 17 00:00:00 2001 From: Don Syme Date: Wed, 13 Mar 2019 19:55:24 +0000 Subject: [PATCH] add diagnostics (#6321) * add diagnostics * add diagnostics * diagnostics * diagnostics * diagnostics * add diagnostics and possible fix for tp smoke tests * fix build * fix build * more diagnostics * try to fix flaky test * fix build * try to fix dodgy test --- .../Microsoft.FSharp.Control/Cancellation.fs | 6 ++-- .../DummyProviderForLanguageServiceTesting.fs | 5 ++- .../Tests.LanguageService.Script.fs | 34 ++++++++++++++----- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs index a14429fe00a..5afff678472 100644 --- a/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs +++ b/tests/FSharp.Core.UnitTests/FSharp.Core/Microsoft.FSharp.Control/Cancellation.fs @@ -278,8 +278,10 @@ type CancellationType() = } |> Async.Start try - let res = t.Wait(1000) - Assert.Fail (sprintf "Excepted TimeoutException wrapped in an AggregateException, but got %A" res) + let res = t.Wait(2000) + let msg = sprintf "Excepted TimeoutException wrapped in an AggregateException, but got %A" res + printfn "failure msg: %s" msg + Assert.Fail (msg) with :? AggregateException as agg -> () [] diff --git a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fs b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fs index 697ba4a2d7a..7c36d8f37e1 100644 --- a/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fs +++ b/vsintegration/tests/MockTypeProviders/DummyProviderForLanguageServiceTesting/DummyProviderForLanguageServiceTesting.fs @@ -124,7 +124,10 @@ module GlobalCounters = let AddConfig c = lock counterLock (fun () -> configs <- c :: configs) let GetConfigs() = lock counterLock (fun () -> configs) let CheckAllConfigsDisposed() = - for c in GetConfigs() do + let cs = GetConfigs() + lock counterLock (fun () -> + configs <- []) + for c in cs do try c.SystemRuntimeContainsType("System.Object") |> ignore failwith "expected configuration object to be disposed" diff --git a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs index 9255acf3436..cb5c4da346e 100644 --- a/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs +++ b/vsintegration/tests/UnitTests/LegacyLanguageService/Tests.LanguageService.Script.fs @@ -1623,28 +1623,44 @@ type UsingMSBuild() as this = let file1 = OpenFile(project,fileName) // The disposals should be at least one less - Assert.IsTrue(countDisposals() < i, "Check1, countDisposals() < i, iteration " + string i) let c = countCreations() let d = countDisposals() - Assert.IsTrue(c >= countDisposals(), "Check2, countCreations() >= countDisposals(), iteration " + string i + ", countCreations() = " + string c + ", countDisposals() = " + string d) - Assert.IsTrue((c = i), "Check3, countCreations() = i, iteration " + string i + ", countCreations() = " + string c) + + // Creations should always be greater or equal to disposals + Assert.IsTrue(c >= d, "Check2, countCreations() >= countDisposals(), iteration " + string i + ", countCreations() = " + string c + ", countDisposals() = " + string d) + + // Creations can run ahead of iterations if the background checker resurrects the builder for a project + // even after we've moved on from it. + Assert.IsTrue((c >= i), "Check3, countCreations() >= i, iteration " + string i + ", countCreations() = " + string c) + if not clearing then // By default we hold 3 build incrementalBuilderCache entries and 5 typeCheckInfo entries, so if we're not clearing // there should be some roots to project builds still present if i >= 3 then - Assert.IsTrue(i >= countDisposals() + 3, "Check4a, i >= countDisposals() + 3, iteration " + string i + ", i = " + string i + ", countDisposals() = " + string (countDisposals())) + Assert.IsTrue(c >= d + 3, "Check4a, c >= countDisposals() + 3, iteration " + string i + ", i = " + string i + ", countDisposals() = " + string d) printfn "Check4a2, i = %d, countInvaldiationHandlersRemoved() = %d" i (countInvaldiationHandlersRemoved()) // If we forcefully clear out caches and force a collection, then we can say much stronger things... if clearing then ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients(this.VS) - Assert.IsTrue((i = countDisposals()), "Check4b, countCreations() = countDisposals(), iteration " + string i) - Assert.IsTrue(countInvaldiationHandlersAdded() - countInvaldiationHandlersRemoved() = 0, "Check4b2, all invlidation handlers removed, iteration " + string i) + let c = countCreations() + let d = countDisposals() + + // Creations should be equal to disposals after a `ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients` + Assert.IsTrue((c = d), "Check4b, countCreations() = countDisposals(), iteration " + string i) + Assert.IsTrue((countInvaldiationHandlersAdded() = countInvaldiationHandlersRemoved()), "Check4b2, all invlidation handlers removed, iteration " + string i) - Assert.IsTrue(countCreations() = 50, "Check5, at end, countCreations() = 50") + let c = countCreations() + let d = countDisposals() + Assert.IsTrue(c >= 50, "Check5, at end, countCreations() >= 50") + ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients(this.VS) - Assert.IsTrue(countDisposals() = 50, "Check6b, at end, countDisposals() = 50 after explicit clearing") - Assert.IsTrue(countInvaldiationHandlersAdded() - countInvaldiationHandlersRemoved() = 0, "Check6b2, at end, all invalidation handlers removed after explicit cleraring") + + let c = countCreations() + let d = countDisposals() + // Creations should be equal to disposals after a `ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients` + Assert.IsTrue((c = d), "Check6b, at end, countCreations() = countDisposals() after explicit clearing") + Assert.IsTrue((countInvaldiationHandlersAdded() = countInvaldiationHandlersRemoved()), "Check6b2, at end, all invalidation handlers removed after explicit cleraring") checkConfigsDisposed() []