Skip to content
Merged
Changes from all commits
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
19 changes: 15 additions & 4 deletions tests/FSharp.Test.Utilities/ProjectGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,21 @@ module ProjectOperations =
|> Option.map (fun s -> s.ToString())
|> Option.defaultValue ""

let filterErrors (diagnostics: FSharpDiagnostic array) =
diagnostics
|> Array.filter (fun diag ->
match diag.Severity with
| FSharpDiagnosticSeverity.Hidden
| FSharpDiagnosticSeverity.Info
| FSharpDiagnosticSeverity.Warning -> false
| FSharpDiagnosticSeverity.Error -> true)

let expectOk parseAndCheckResults _ =
let checkResult = getTypeCheckResult parseAndCheckResults
let errors = filterErrors checkResult.Diagnostics

if checkResult.Diagnostics.Length > 0 then
failwith $"Expected no errors, but there were some: \n%A{checkResult.Diagnostics}"
if errors.Length > 0 then
failwith $"Expected no errors, but there were some: \n%A{errors}"

let expectSingleWarningAndNoErrors (warningSubString:string) parseAndCheckResults _ =
let checkResult = getTypeCheckResult parseAndCheckResults
Expand Down Expand Up @@ -880,9 +890,10 @@ let SaveAndCheckProject project checker isExistingProject =
let! snapshot = FSharpProjectSnapshot.FromOptions(options, getFileSnapshot project)

let! results = checker.ParseAndCheckProject(snapshot)
let errors = filterErrors results.Diagnostics

if not (Array.isEmpty results.Diagnostics || project.SkipInitialCheck) then
failwith $"Project {project.Name} failed initial check: \n%A{results.Diagnostics}"
if not (Array.isEmpty errors || project.SkipInitialCheck) then
failwith $"Project {project.Name} failed initial check: \n%A{errors}"

let! signatures =
Async.Sequential
Expand Down