diff --git a/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs b/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs index c922cde76..1247b6310 100644 --- a/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs +++ b/test/FsAutoComplete.Tests.Lsp/SnapshotTests.fs @@ -109,8 +109,25 @@ let awaitOutOfDate (o : amap<_,_>) = // So we need to wait for a change to happen before we continue. task { + // printfn "o.Content.OutOfDate: %b" o.Content.OutOfDate + // printfn "o.GetReader.OutOfDate: %b" (o.GetReader().OutOfDate) let tcs = new TaskCompletionSource() - use _ = o.AddCallback(fun _ _ -> tcs.TrySetResult() |> ignore) + use cts = new System.Threading.CancellationTokenSource() + cts.CancelAfter(5000) + use _ = cts.Token.Register(fun () -> tcs.TrySetCanceled(cts.Token) |> ignore) + use _ = o.AddCallback(fun s d -> + // printfn "state: %A" s + // printfn "delta: %A" d + // printfn "o.Content.OutOfDate: %b" o.Content.OutOfDate + // printfn "o.GetReader.OutOfDate: %b" (o.GetReader().OutOfDate) + if s.IsEmpty |> not then + tcs.TrySetResult() |> ignore + ) + + // use _ = o.AddCallback(fun s d -> + // printfn "state: %A" s + // printfn "delta: %A" d) + // printfn "Awaiting out of date" return! tcs.Task // while not o.Content.OutOfDate do // do! Async.Sleep 15 @@ -121,7 +138,7 @@ let awaitOutOfDate (o : amap<_,_>) = let snapshotTests loaders toolsPath = - testList "ProjectWorkspace" [ + ftestList "ProjectWorkspace" [ for (loaderName, workspaceLoaderFactory) in loaders do testSequencedGroup loaderName <| testList $"{loaderName}" [ @@ -234,17 +251,19 @@ let snapshotTests loaders toolsPath = let snapsA = Snapshots.createSnapshots AMap.empty (AVal.constant sourceTextFactory) loadedProjectsA let snaps = snapsA |> AMap.mapA (fun _ (_,v) -> v) - let snapshotsBefore = snaps |> AMap.force + let consoleFile = Projects.MultiProjectScenario1.Console1.programFileIn dDir.DirectoryInfo + + let snapshotsBefore = snaps |> AMap.force let awaitOutOfDate = awaitOutOfDate snaps do! File.WriteAllTextAsync(consoleFile.FullName, "let x = 1") do! awaitOutOfDate consoleFile.Refresh() + let snapshotAfter = snaps |> AMap.force - let snapshotAfter = snaps |> AMap.force let ls1 = snapshotsBefore |> HashMap.find (normalizePath (Projects.MultiProjectScenario1.Library1.projectIn dDir.DirectoryInfo).FullName) let ls2 = snapshotAfter |> HashMap.find (normalizePath (Projects.MultiProjectScenario1.Library1.projectIn dDir.DirectoryInfo).FullName) @@ -282,10 +301,13 @@ let snapshotTests loaders toolsPath = let snapsA = Snapshots.createSnapshots AMap.empty (AVal.constant sourceTextFactory) loadedProjectsA let snaps = snapsA |> AMap.mapA (fun _ (_,v) -> v) - let snapshotBefore = snaps |> AMap.force + let libraryFile = Projects.MultiProjectScenario1.Library1.libraryFileIn dDir.DirectoryInfo + + let snapshotBefore = snaps |> AMap.force let awaitOutOfDate = awaitOutOfDate snaps + printfn "Writing to file: %s" libraryFile.FullName do! File.WriteAllTextAsync(libraryFile.FullName, "let x = 1") do! awaitOutOfDate