[Repo Assist] fix: fix flaky test infrastructure - empty diagnostics buffer and directory cleanup failures#1521
Draft
github-actions[bot] wants to merge 2 commits intomainfrom
Conversation
When the language server does not publish any diagnostics (e.g. for error-free code), the Observable.bufferSpan window completes with an empty IList. The previous Seq.last call threw 'The input sequence was empty', causing intermittent test failures in tests like the InlayHint voption 'show: for custom function' test. Change Seq.last to Seq.tryLast |> Option.defaultValue [||] to return an empty diagnostics array instead of throwing when no diagnostic notifications are received. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On some platforms (notably macOS with .NET 10), Directory.Delete with recursive=true can fail with 'Directory not empty' when background SDK processes (e.g., hot reload daemon) still hold file locks. This caused 15 test failures in Go-to-definition tests on macOS+net10.0 CI matrix. Change dotnetCleanup to retry once after 200ms and then silently ignore cleanup failures. Stale build artifacts from a previous run are not critical -- tests still produce correct results. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
27 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Fixes two distinct flaky test infrastructure issues that cause intermittent test failures.
Fix 1: Empty diagnostics buffer in
waitForLatestDiagnosticsRoot cause:
waitForLatestDiagnosticsinServer.fsusesObservable.bufferSpanto collect diagnostic notifications. For error-free code, the LSP server sends nopublishDiagnosticsnotifications, so the buffer emits an emptyIList<Diagnostic[]>. CallingSeq.laston this empty list throwsSystem.InvalidOperationException: The input sequence was empty.Observed failure:
Fix: Replace
Seq.lastwithSeq.tryLast |> Option.defaultValue [||]— an empty buffer returns[||](no diagnostics), which is the correct result for error-free code.Fix 2: Directory cleanup failures in
dotnetCleanupRoot cause: On macOS + .NET 10,
Directory.Delete(path, true)fails withIOException: Directory not emptybecause background .NET SDK processes (hot reload daemon, file watchers) may hold locks on files inobj/Debugduring test cleanup. This causes ~15 test failures on themacos-15 / net10.0 / TransparentCompilerCI matrix.Fix: Wrap
Directory.Deletein a try/catch with a 200ms retry. If both attempts fail, silently ignore the error — the test result is valid even if the temp directory persists.Files Changed
test/FsAutoComplete.Tests.Lsp/Utils/Server.fs—Seq.last→Seq.tryLast |> Option.defaultValue [||]test/FsAutoComplete.Tests.Lsp/Helpers.fs— retry/fallback indotnetCleanupTest Status
dotnet build -f net8.0passesdotnet fantomas --checkpasses