Skip to content

Commit 0d5f07b

Browse files
committed
Cleanup. Generate fsc args for FCS and ComponentTests projects. Add a script for preparing the codebase
1 parent 2a6451b commit 0d5f07b

18 files changed

+178
-123
lines changed

tests/ParallelTypeCheckingTests/Code/DepResolving.fs renamed to tests/ParallelTypeCheckingTests/Code/DependencyResolution.fs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ open System
66
open System.Collections.Generic
77
open ParallelTypeCheckingTests
88
open ParallelTypeCheckingTests.FileInfoGathering
9-
open ParallelTypeCheckingTests.Graph
109
open ParallelTypeCheckingTests.Types
1110
open FSharp.Compiler.Syntax
1211

@@ -30,12 +29,13 @@ type DepsResult =
3029
Files : FileData[]
3130
Graph : DepsGraph
3231
}
32+
with member this.Edges() = this.Graph |> Graph.collectEdges
3333

3434
type References = Reference seq
3535

3636
/// Algorithm for automatically detecting (lack of) file dependencies based on their AST contents
3737
[<RequireQualifiedAccess>]
38-
module internal AutomatedDependencyResolving =
38+
module internal DependencyResolution =
3939

4040
/// Eg. 'A' and 'B' in "module A.B"
4141
type ModuleSegment = string
@@ -142,20 +142,22 @@ module internal AutomatedDependencyResolving =
142142
printfn $"{backed.Length} backed files found"
143143
let filesWithModuleAbbreviations =
144144
nodes
145-
|> Array.filter (fun n -> n.Data.Abbreviations |> Array.exists (function Abbreviation.ModuleAbbreviation _ -> true | _ -> false))
145+
|> Array.filter (fun n ->
146+
n.Data.Abbreviations
147+
|> Array.exists (function Abbreviation.ModuleAbbreviation -> true | _ -> false))
146148

147149
let trie = buildTrie nodes
148150

149151
let fsiFiles =
150152
nodes
151-
|> Array.filter (fun f -> f.File.Name.EndsWith ".fsi")
153+
|> Array.filter (fun f -> match f.File.AST with | ASTOrX.AST (ParsedInput.SigFile _) -> true | _ -> false)
152154

153155
let processFile (node : FileData) =
154156
let deps =
155157
let fsiDep =
156158
if node.File.FsiBacked then
157159
nodes
158-
|> Array.find (fun x -> x.File.Name = node.File.Name + "i")
160+
|> Array.find (fun x -> x.File.QualifiedName = node.File.QualifiedName)
159161
|> fun x -> [|x|]
160162
else
161163
[||]
@@ -239,7 +241,7 @@ module internal AutomatedDependencyResolving =
239241
reachable
240242
|> Seq.collect (fun node -> node.Files)
241243
// TODO Temporary - Add all nodes
242-
|> Seq.append nodes
244+
// |> Seq.append nodes
243245
// If not, then the below is not necessary.
244246
// Assume that this file depends on all files that have any module abbreviations
245247
// TODO Handle module abbreviations in a better way

tests/ParallelTypeCheckingTests/Code/FileInfoGathering.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ let internal gatherBackingInfo (files : SourceFiles) : Files =
1414
let fsiBacked =
1515
match f.AST with
1616
| ParsedInput.SigFile _ ->
17-
// TODO Use QualifiedNameOfFile
18-
seenSigFiles.Add f.AST.FileName |> ignore
17+
seenSigFiles.Add f.QualifiedName |> ignore
1918
false
2019
| ParsedInput.ImplFile _ ->
21-
let fsiName = System.IO.Path.ChangeExtension(f.QualifiedName, "fsi")
22-
let fsiBacked = seenSigFiles.Contains fsiName
20+
let fsiBacked = seenSigFiles.Contains f.QualifiedName
2321
fsiBacked
2422
{
2523
Idx = FileIdx.make i

tests/ParallelTypeCheckingTests/Code/Graph.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
module ParallelTypeCheckingTests.Graph
1+
namespace ParallelTypeCheckingTests
22
#nowarn "1182"
33
#nowarn "40"
44

55
open System.Collections.Generic
6-
open System.Drawing.Drawing2D
76
open ParallelTypeCheckingTests.Utils
87

98
/// <summary> DAG of files </summary>
109
type Graph<'Node> = IReadOnlyDictionary<'Node, 'Node[]>
1110

1211
module Graph =
1312

13+
let collectEdges<'Node when 'Node : equality> (graph : Graph<'Node>) : ('Node * 'Node)[] =
14+
let graph : IReadOnlyDictionary<'Node, 'Node[]> = graph
15+
graph
16+
|> Seq.collect (fun (KeyValue(node, deps)) -> deps |> Array.map (fun dep -> node, dep))
17+
|> Seq.toArray
18+
1419
/// Create entries for nodes that don't have any dependencies but are mentioned as dependencies themselves
1520
let fillEmptyNodes<'Node when 'Node : equality> (graph : Graph<'Node>) : Graph<'Node> =
1621
let missingNodes =

tests/ParallelTypeCheckingTests/Code/GraphProcessing.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module ParallelTypeCheckingTests.GraphProcessing
33

44
open System.Collections.Generic
55
open System.Threading
6-
open ParallelTypeCheckingTests.Graph
76

87
/// Used for processing
98
type NodeInfo<'Item> =

tests/ParallelTypeCheckingTests/Code/ParallelTypeChecking.fs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#nowarn "1182"
33
open System.Collections.Concurrent
44
open System.Collections.Generic
5-
open System.Threading
65
open FSharp.Compiler
76
open FSharp.Compiler.CheckBasics
87
open FSharp.Compiler.CheckDeclarations
@@ -12,7 +11,6 @@ open FSharp.Compiler.DiagnosticsLogger
1211
open FSharp.Compiler.NameResolution
1312
open FSharp.Compiler.ParseAndCheckInputs
1413
open ParallelTypeCheckingTests.FileInfoGathering
15-
open ParallelTypeCheckingTests.Graph
1614
open ParallelTypeCheckingTests.Types
1715
open ParallelTypeCheckingTests.Utils
1816
open ParallelTypeCheckingTests
@@ -21,7 +19,6 @@ open FSharp.Compiler.Syntax
2119
open FSharp.Compiler.TcGlobals
2220
open FSharp.Compiler.Text
2321
open FSharp.Compiler.TypedTree
24-
open Internal.Utilities.Collections
2522
open Internal.Utilities.Library
2623
open Internal.Utilities.Library.Extras
2724
open Newtonsoft.Json
@@ -70,12 +67,12 @@ let CheckMultipleInputsInParallel
7067
|> List.map (fun ast -> ast.FileName, ast)
7168
|> readOnlyDict
7269
|> ConcurrentDictionary<_,_>
73-
let graph = DepResolving.AutomatedDependencyResolving.detectFileDependencies sourceFiles
70+
let graph = DepResolving.DependencyResolution.detectFileDependencies sourceFiles
7471

7572
let mutable nextIdx = (graph.Files |> Array.map (fun f -> f.File.Idx.Idx) |> Array.max) + 1
76-
let fakeX (idx : FileIdx) (fsi : string) : FileData =
73+
let fakeX (idx : FileIdx) (fsi : File) : FileData =
7774
{
78-
File = File.FakeFs idx fsi
75+
File = File.FakeFs idx fsi.QualifiedName
7976
Data =
8077
{
8178
Tops = [||]
@@ -91,7 +88,7 @@ let CheckMultipleInputsInParallel
9188
|> Array.map (fun fsi ->
9289
let idx = FileIdx.make nextIdx
9390
nextIdx <- nextIdx + 1
94-
fsi.File, fakeX idx fsi.File.Name
91+
fsi.File, fakeX idx fsi.File
9592
)
9693
|> readOnlyDict
9794

tests/ParallelTypeCheckingTests/Code/SingleTcStateTypeChecking.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ let CheckMultipleInputsInParallel
8989
|> List.toArray
9090
|> Array.mapi (fun i inp -> { Idx = FileIdx.make i; AST = inp }: SourceFile)
9191

92-
AutomatedDependencyResolving.detectFileDependencies sourceFiles
92+
DependencyResolution.detectFileDependencies sourceFiles
9393

9494
do ()
9595

tests/ParallelTypeCheckingTests/Code/Types.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type SourceFile =
2727
| _ -> false
2828
override this.GetHashCode () = this.Idx.GetHashCode()
2929
override this.ToString() = this.Idx.ToString()
30-
member this.QualifiedName = this.AST.FileName
30+
member this.QualifiedName = this.AST.QualifiedName.Text
3131

3232
type SourceFiles = SourceFile[]
3333

@@ -38,7 +38,11 @@ type ASTOrX =
3838
member x.Name =
3939
match x with
4040
| AST ast -> ast.FileName
41-
| X fsi -> fsi + "x"
41+
| X qualifiedName -> qualifiedName + "x"
42+
member x.QualifiedName =
43+
match x with
44+
| AST ast -> ast.QualifiedName.Text
45+
| X qualifiedName -> qualifiedName + ".fsix"
4246

4347
/// Basic data about a parsed source file with extra information needed for graph processing
4448
[<CustomEquality; CustomComparison>]
@@ -53,6 +57,7 @@ type File =
5357
with
5458
member this.Name = this.AST.Name // TODO Use qualified name
5559
member this.CodeSize = this.Code.Length
60+
member this.QualifiedName = this.AST.QualifiedName
5661
override this.Equals other =
5762
match other with
5863
| :? File as f -> f.Name.Equals this.Name

tests/ParallelTypeCheckingTests/ParallelTypeCheckingTests.fsproj

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,27 @@
2828
<Compile Include="..\service\Common.fs">
2929
<Link>Common.fs</Link>
3030
</Compile>
31-
<Compile Include="Code/Utils.fs" />
32-
<Compile Include="Code/Types.fs" />
33-
<Compile Include="Code/ASTVisit.fs" />
34-
<Compile Include="Code/FileInfoGathering.fs" />
35-
<Compile Include="Code/Graph.fs" />
36-
<Compile Include="Code/DepResolving.fs" />
37-
<Compile Include="Code/Parallel.fs" />
38-
<Compile Include="Code/GraphProcessing.fs" />
39-
<Compile Include="Code/ParallelTypeChecking.fs" />
31+
<Compile Include="Code\Utils.fs" />
32+
<Compile Include="Code\Types.fs" />
33+
<Compile Include="Code\ASTVisit.fs" />
34+
<Compile Include="Code\FileInfoGathering.fs" />
35+
<Compile Include="Code\Graph.fs" />
36+
<Compile Include="Code\DependencyResolution.fs" />
37+
<Compile Include="Code\Parallel.fs" />
38+
<Compile Include="Code\GraphProcessing.fs" />
39+
<Compile Include="Code\ParallelTypeChecking.fs" />
4040
<Compile Include="Code\SingleTcStateTypeChecking.fs" />
41-
<Compile Include="Tests\TestASTVisit.fs" />
42-
<Compile Include="Tests\TestDepResolving.fs" />
4341
<Compile Include="Tests\Utils.fs" />
4442
<Compile Include="Tests\AssemblySetUp.fs" />
43+
<Compile Include="Tests\TestASTVisit.fs" />
44+
<Compile Include="Tests\TestDependencyResolution.fs" />
4545
<Compile Include="Tests\TestGraphProcessing.fs" />
4646
<Compile Include="Tests\TestCompilation.fs" />
47-
<Content Include="Tests\DiamondArgs.txt" />
48-
<Content Include="Tests\FCS.txt" />
4947
<Compile Include="Tests\TestCompilationFromCmdlineArgs.fs" />
5048
<Compile Include="Tests\TestGraph.fs" />
49+
<Content Include="Tests\FCS.args.txt" />
50+
<Content Include="Tests\FCS.prepare.ps1" />
51+
<Content Include="Tests\ComponentTests.args.txt" />
5152
<Compile Include="Program.fs" />
5253
<Content Include="Docs.md" />
5354
</ItemGroup>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.checkouts

tests/ParallelTypeCheckingTests/Tests/AssemblySetUp.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
namespace global
22
open NUnit.Framework
3-
open ParallelTypeCheckingTests
43
open OpenTelemetry.Trace
54

65
/// One-time Otel setup for NUnit tests
@@ -10,7 +9,7 @@ type AssemblySetUp() =
109

1110
[<OneTimeSetUp>]
1211
member this.SetUp() =
13-
tracerProvider <- TestUtils.setupOtel() |> Some
12+
tracerProvider <- ParallelTypeCheckingTests.TestUtils.setupOtel() |> Some
1413

1514
[<OneTimeTearDown>]
1615
member this.TearDown() =

0 commit comments

Comments
 (0)