Skip to content

Commit c488082

Browse files
committed
Changes
1 parent 0d5f07b commit c488082

2 files changed

Lines changed: 50 additions & 23 deletions

File tree

tests/ParallelTypeCheckingTests/Code/DependencyResolution.fs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -271,29 +271,29 @@ module internal DependencyResolution =
271271
|> Array.Parallel.map processFile
272272
|> readOnlyDict
273273

274-
let totalSize1 =
275-
graph
276-
|> Seq.sumBy (fun (KeyValue(_k,v)) -> v.Length)
277-
let t =
278-
graph
279-
|> Graph.transitive
280-
let totalSize2 =
281-
t
282-
|> Seq.sumBy (fun (KeyValue(_k,v)) -> v.Length)
283-
284-
printfn $"Non-transitive size: {totalSize1}, transitive size: {totalSize2}"
285-
286-
let res =
287-
{
288-
DepsResult.Files = nodes
289-
DepsResult.Graph = graph
290-
}
291-
res
274+
{
275+
DepsResult.Files = nodes
276+
DepsResult.Graph = graph
277+
}
292278

293279
/// <summary>
294280
/// Calculate and print some stats about the expected parallelism factor of a dependency graph
295281
/// </summary>
296282
let analyseEfficiency (result : DepsResult) : unit =
283+
let graph = result.Graph
284+
let totalSize1 =
285+
graph
286+
|> Seq.sumBy (fun (KeyValue(_k,v)) -> v.Length)
287+
let t =
288+
graph
289+
|> Graph.transitive
290+
let totalSize2 =
291+
t
292+
|> Seq.sumBy (fun (KeyValue(_k,v)) -> v.Length)
293+
294+
printfn $"Non-transitive size: {totalSize1}, transitive size: {totalSize2}"
295+
296+
297297
let totalFileSize =
298298
result.Files
299299
|> Array.sumBy (fun file -> int64(file.CodeSize))

tests/ParallelTypeCheckingTests/Tests/TestDependencyResolution.fs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,33 @@ let x = 1
8888
]
8989
assertGraphEqual deps expectedEdges
9090

91+
[<Test>]
92+
let ``Files with module or type abbreviations depend on all files above``() =
93+
let files =
94+
[|
95+
"A.fs", """
96+
module A
97+
"""
98+
"B.fs", """
99+
module B
100+
module X = Y
101+
"""
102+
"C.fs", """
103+
module C
104+
type X = Y
105+
"""
106+
|]
107+
|> buildFiles
108+
109+
let deps = DependencyResolution.detectFileDependencies files
110+
111+
let expectedEdges =
112+
[
113+
"B.fs", ["A.fs"]
114+
"C.fs", ["A.fs"; "B.fs"]
115+
]
116+
assertGraphEqual deps expectedEdges
117+
91118

92119
let sampleFiles =
93120
[
@@ -177,10 +204,10 @@ let private parseProjectAndGetSourceFiles (projectFile : string) =
177204
log "built project using Buildalyzer"
178205
files
179206

180-
[<TestCase(@"C:\projekty\fsharp\heuristic\tests\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj")>]
181-
[<TestCase(@"C:\projekty\fsharp\fsharp_main\src\Compiler\FSharp.Compiler.Service.fsproj")>]
207+
[<TestCase(__SOURCE_DIRECTORY__ + @"\..\..\FSharp.Compiler.ComponentTests\FSharp.Compiler.ComponentTests.fsproj")>]
208+
[<TestCase(__SOURCE_DIRECTORY__ + @"\..\..\..\src\Compiler\FSharp.Compiler.Service.fsproj")>]
182209
[<Explicit("Slow as it uses Buildalyzer to analyse (build) projects first")>]
183-
let ``Test fsproj files`` (projectFile : string) =
210+
let ``Analyse whole projects and print statistics`` (projectFile : string) =
184211
log $"Start finding file dependency graph for {projectFile}"
185212
let files = parseProjectAndGetSourceFiles projectFile
186213
let files =
@@ -213,11 +240,11 @@ let ``Test fsproj files`` (projectFile : string) =
213240

214241
analyseEfficiency graph
215242

216-
let totalDeps = graph.Graph |> Seq.sumBy (fun (KeyValue(k, v)) -> v.Length)
243+
let totalDeps = graph.Graph |> Seq.sumBy (fun (KeyValue(_k, v)) -> v.Length)
217244
let topFirstDeps =
218245
graph.Graph
219246
|> Seq.sumBy (
220-
fun (KeyValue(k, v)) ->
247+
fun (KeyValue(_k, v)) ->
221248
if v.Length = 0 then 0
222249
else v |> Array.map (fun d -> graph.Graph[d].Length) |> Array.max
223250
)

0 commit comments

Comments
 (0)