diff --git a/tests/FSharp.Test.Utilities/ProjectGeneration.fs b/tests/FSharp.Test.Utilities/ProjectGeneration.fs index 22dcc12c184..144e535bccb 100644 --- a/tests/FSharp.Test.Utilities/ProjectGeneration.fs +++ b/tests/FSharp.Test.Utilities/ProjectGeneration.fs @@ -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 @@ -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