Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter diagnostics for errors. #16622

Merged
merged 2 commits into from
Jan 31, 2024
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 _ =
psfinaki marked this conversation as resolved.
Show resolved Hide resolved
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
Loading