Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
safesparrow committed Nov 9, 2022
1 parent e4643f2 commit b0d5af0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ module internal DependencyResolution =

let fsiFiles =
nodes
|> Array.filter (fun f -> match f.File.AST with | ASTOrX.AST (ParsedInput.SigFile _) -> true | _ -> false)
|> Array.filter (fun f -> match f.File.AST with | ASTOrFsix.AST (ParsedInput.SigFile _) -> true | _ -> false)

let processFile (node : FileData) =
let deps =
Expand Down
4 changes: 2 additions & 2 deletions tests/ParallelTypeCheckingTests/Code/FileInfoGathering.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let internal gatherBackingInfo (files : SourceFiles) : Files =
{
Idx = FileIdx.make i
Code = "no code here" // TODO
AST = ASTOrX.AST f.AST
AST = ASTOrFsix.AST f.AST
FsiBacked = fsiBacked
}
)
Expand Down Expand Up @@ -61,7 +61,7 @@ let gatherForAllFiles (files : SourceFiles) =
files
// TODO Proper async with cancellation
|> Array.Parallel.map (fun f ->
let ast = match f.AST with ASTOrX.AST ast -> ast | X _ -> failwith "Unexpected X item"
let ast = match f.AST with ASTOrFsix.AST ast -> ast | Fsix _ -> failwith "Unexpected X item"
let data = gatherFileData ast
{
File = f
Expand Down
9 changes: 5 additions & 4 deletions tests/ParallelTypeCheckingTests/Code/ParallelTypeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ let CheckMultipleInputsInParallel
let graphDumpName = tcConfig.outputFile |> Option.map Path.GetFileName |> Option.defaultValue "project"
$"{graphDumpName}.deps.json"
graph.Graph
|> Graph.map (fun n -> n.Name)
|> Graph.serialiseToJson graphDumpPath

let _ = ctok // TODO Use
Expand All @@ -151,7 +152,7 @@ let CheckMultipleInputsInParallel
let c = cnt
cnt <- cnt + 1
match file.AST with
| ASTOrX.AST _ ->
| ASTOrFsix.AST _ ->
printfn $"#{c} [thread {Thread.CurrentThread.ManagedThreadId}] Type-checking {file.ToString()}"
let! f = CheckOneInput'(
checkForErrors2,
Expand Down Expand Up @@ -179,7 +180,7 @@ let CheckMultipleInputsInParallel
// printfn $"Finished applying {file.ToString()}"
partialResult, state
)
| ASTOrX.X fsi ->
| ASTOrFsix.Fsix fsi ->
// printfn $"[{c}] Processing X {file.ToString()}"

let hadSig = true
Expand Down Expand Up @@ -231,9 +232,9 @@ let CheckMultipleInputsInParallel
let processFile (file : File) (state : State) : State -> PartialResult * State =
let parsedInput, logger =
match file.AST with
| ASTOrX.AST ast ->
| ASTOrFsix.AST ast ->
ast, inputsWithLoggers[file.Idx] |> snd
| ASTOrX.X _ ->
| ASTOrFsix.Fsix _ ->
inputs |> List.item 0, diagnosticsLogger
processFile file (parsedInput, logger) state

Expand Down
14 changes: 8 additions & 6 deletions tests/ParallelTypeCheckingTests/Code/Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,20 @@ type SourceFile =

type SourceFiles = SourceFile[]

type ASTOrX =
type ASTOrFsix =
// Actual AST of a real file
| AST of AST
| X of string
// A dummy file/node we create for performing TcState updates for fsi-backed impl files
| Fsix of string
with
member x.Name =
match x with
| AST ast -> ast.FileName
| X qualifiedName -> qualifiedName + "x"
| Fsix qualifiedName -> qualifiedName + "x"
member x.QualifiedName =
match x with
| AST ast -> ast.QualifiedName.Text
| X qualifiedName -> qualifiedName + ".fsix"
| Fsix qualifiedName -> qualifiedName + ".fsix"

/// Basic data about a parsed source file with extra information needed for graph processing
[<CustomEquality; CustomComparison>]
Expand All @@ -51,7 +53,7 @@ type File =
/// Order of the file in the project. Files with lower number cannot depend on files with higher number
Idx : FileIdx
Code : string
AST : ASTOrX
AST : ASTOrFsix
FsiBacked : bool
}
with
Expand All @@ -74,7 +76,7 @@ type File =
{
Idx = idx
Code = "Fake '.fsix' node for dummy .fs state"
AST = ASTOrX.X fsi
AST = ASTOrFsix.Fsix fsi
FsiBacked = false
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ParallelTypeCheckingTests/Tests/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.checkouts
.fcs_test
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type Codebase =

let codebases =
[|
{ WorkDir = $@"{__SOURCE_DIRECTORY__}\.checkouts\fcs\src\compiler"; Path = $@"{__SOURCE_DIRECTORY__}\FCS.args.txt"; Limit = None }
{ WorkDir = $@"{__SOURCE_DIRECTORY__}\.checkouts\fcs\tests\FSharp.Compiler.ComponentTests"; Path = $@"{__SOURCE_DIRECTORY__}\ComponentTests.args.txt"; Limit = None }
{ WorkDir = $@"{__SOURCE_DIRECTORY__}\.fcs_test\src\compiler"; Path = $@"{__SOURCE_DIRECTORY__}\FCS.args.txt"; Limit = None }
{ WorkDir = $@"{__SOURCE_DIRECTORY__}\.fcs_test\tests\FSharp.Compiler.ComponentTests"; Path = $@"{__SOURCE_DIRECTORY__}\ComponentTests.args.txt"; Limit = None }
|]

let internal setupParsed config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ let ``Analyse whole projects and print statistics`` (projectFile : string) =

let path = $"{Path.GetFileName(projectFile)}.deps.json"
graph.Graph
|> Graph.map (fun n -> n.Name)
|> Graph.serialiseToJson path

log $"Analysed {N} files, detected {totalDeps}/{maxPossibleDeps} file dependencies (%.1f{100.0 * double(totalDeps) / double(maxPossibleDeps)}%%)."
Expand Down
4 changes: 2 additions & 2 deletions tests/ParallelTypeCheckingTests/Tests/TestGraphProcessing.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let a = 3
{
Idx = FileIdx.make 1
Code = code
AST = ASTOrX.AST <| parseSourceCode ("A.fs", code)
AST = ASTOrFsix.AST <| parseSourceCode ("A.fs", code)
FsiBacked = false
}

Expand All @@ -72,7 +72,7 @@ let b = 3
{
Idx = FileIdx.make 2
Code = code
AST = ASTOrX.AST <| parseSourceCode ("B.fs", code)
AST = ASTOrFsix.AST <| parseSourceCode ("B.fs", code)
FsiBacked = false
}
[|
Expand Down

0 comments on commit b0d5af0

Please sign in to comment.