Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update test fixes
  • Loading branch information
dsyme committed Feb 20, 2019
commit e5d48e55f5b33d17bf2a017c4aae5d74b2235abf
15 changes: 11 additions & 4 deletions tests/service/PerfTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,17 @@ let ``Test request for parse and check doesn't check whole project`` () =
printfn "CheckFileInProject()..."
let checkResults1 = checker.CheckFileInProject(parseResults1, Project1.fileNames.[5], 0, Project1.fileSources2.[5], Project1.options) |> Async.RunSynchronously
let pD, tD = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
printfn "checking backgroundParseCount.Value = %d" backgroundParseCount.Value
backgroundParseCount.Value |> shouldEqual 5
printfn "checking backgroundCheckCount.Value = %d" backgroundCheckCount.Value
backgroundCheckCount.Value |> shouldEqual 5

printfn "checking background parsing happened...., backgroundParseCount.Value = %d" backgroundParseCount.Value
(backgroundParseCount.Value >= 5) |> shouldEqual true // but note, the project does not get reparsed
printfn "checking background typechecks happened...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value
(backgroundCheckCount.Value >= 5) |> shouldEqual true // only two extra typechecks of files

printfn "checking no extra background parsing...., backgroundParseCount.Value = %d" backgroundParseCount.Value
(backgroundParseCount.Value <= 10) |> shouldEqual true // but note, the project does not get reparsed
printfn "checking no extra background typechecks...., backgroundCheckCount.Value = %d" backgroundCheckCount.Value
(backgroundCheckCount.Value <= 10) |> shouldEqual true // only two extra typechecks of files

printfn "checking (pD - pC) = %d" (pD - pC)
(pD - pC) |> shouldEqual 0
printfn "checking (tD - tC) = %d" (tD - tC)
Expand Down
39 changes: 0 additions & 39 deletions tests/service/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5161,45 +5161,6 @@ module internal ProjectBig =
let parsingOptions, _ = checker.GetParsingOptionsFromCommandLineArgs(List.ofArray args)


[<Test>]
let ``Test request for parse and check doesn't check whole project`` () =

let backgroundParseCount = ref 0
let backgroundCheckCount = ref 0
checker.FileChecked.Add (fun x -> incr backgroundCheckCount)
checker.FileParsed.Add (fun x -> incr backgroundParseCount)

checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
let pB, tB = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
let parseResults1 = checker.ParseFile(ProjectBig.fileNames.[5], ProjectBig.fileSources2.[5], ProjectBig.parsingOptions) |> Async.RunSynchronously
let pC, tC = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
(pC - pB) |> shouldEqual 1
(tC - tB) |> shouldEqual 0
backgroundParseCount.Value |> shouldEqual 0
backgroundCheckCount.Value |> shouldEqual 0
let checkResults1 = checker.CheckFileInProject(parseResults1, ProjectBig.fileNames.[5], 0, ProjectBig.fileSources2.[5], ProjectBig.options) |> Async.RunSynchronously
let pD, tD = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
backgroundParseCount.Value |> shouldEqual 5
backgroundCheckCount.Value |> shouldEqual 5
(pD - pC) |> shouldEqual 0
(tD - tC) |> shouldEqual 1

let checkResults2 = checker.CheckFileInProject(parseResults1, ProjectBig.fileNames.[7], 0, ProjectBig.fileSources2.[7], ProjectBig.options) |> Async.RunSynchronously
let pE, tE = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
(pE - pD) |> shouldEqual 0
(tE - tD) |> shouldEqual 1
(backgroundParseCount.Value <= 8) |> shouldEqual true // but note, the project does not get reparsed
(backgroundCheckCount.Value <= 8) |> shouldEqual true // only two extra typechecks of files

// A subsequent ParseAndCheck of identical source code doesn't do any more anything
let checkResults2 = checker.ParseAndCheckFileInProject(ProjectBig.fileNames.[7], 0, ProjectBig.fileSources2.[7], ProjectBig.options) |> Async.RunSynchronously
let pF, tF = FSharpChecker.GlobalForegroundParseCountStatistic, FSharpChecker.GlobalForegroundTypeCheckCountStatistic
(pF - pE) |> shouldEqual 0 // note, no new parse of the file
(tF - tE) |> shouldEqual 0 // note, no new typecheck of the file
(backgroundParseCount.Value <= 8) |> shouldEqual true // but note, the project does not get reparsed
(backgroundCheckCount.Value <= 8) |> shouldEqual true // only two extra typechecks of files

()

[<Test>]
// Simplified repro for https://github.com/Microsoft/visualfsharp/issues/2679
Expand Down