ionide / ionide/FsAutoComplete

[Repo Assist] fix: fix flaky test infrastructure - empty diagnostics buffer and directory cleanup failures

Open
#1,522 2 comments 0 reactions 0 assignees View on GitHub
automation bug repo-assist
Dominant language
F#
Stars
486
Forks
169
Avg merge
2d 8h
Merged PRs (30d)
5

Description

🤖 *This issue was created by Repo Assist, an automated AI assistant.*

Two distinct test infrastructure bugs causing intermittent CI failures have been identified and fixed. The PR creation was blocked, so the patch is provided here for manual application.

## Fix 1: Empty diagnostics buffer in `waitForLatestDiagnostics`

**Root cause**: `waitForLatestDiagnostics` uses `Observable.bufferSpan` to collect `publishDiagnostics` notifications. For **error-free code**, the language server sends no notifications, so the buffer emits an empty `IList`. The call `Seq.last` throws `System.InvalidOperationException: The input sequence was empty`.

**Observed in CI** (PR #1518):
```
InlayHint.voption.show: for custom function
System.InvalidOperationException: The input sequence was empty
at ... waitForLatestDiagnostics@301
```

**Fix in** `test/FsAutoComplete.Tests.Lsp/Utils/Server.fs`:
```diff
- |> Array.last
+ |> (fun arr -> if arr.Length = 0 then [||] else arr[arr.Length - 1])
```
More precisely, change `Seq.last` → `Seq.tryLast |> Option.defaultValue [||]`.

## Fix 2: Directory cleanup failures in `dotnetCleanup`

**Root cause**: On macOS + .NET 10, `Directory.Delete(path, true)` fails with `IOException: Directory not empty` because .NET SDK background processes hold locks on files in `obj/Debug` at cleanup time.

**Observed in CI**: ~15 `GoTo Tests` failures on `macos-15 / net10.0 / TransparentCompiler`.

**Fix in** `test/FsAutoComplete.Tests.Lsp/Helpers.fs`: wrap `Directory.Delete` in try/catch with 200ms retry.

## Applying the Fix

The patch can be downloaded from [workflow run 23994119498](https://github.com/ionide/FsAutoComplete/actions/runs/23994119498):

```sh
gh run download 23994119498 -n agent -D /tmp/agent-23994119498
git checkout -b fix/flaky-test-infrastructure main
git am --3way /tmp/agent-23994119498/aw-repo-assist-fix-flaky-diagnostics-test-20260405.patch
git push origin fix/flaky-test-infrastructure
gh pr create --title 'fix: fix flaky test infrastructure' --base main
```

---

> Generated by 🌈 Repo Assist, see [workflow run](https://github.com/ionide/FsAutoComplete/actions/runs/23994119498).

> Generated by 🌈 Repo Assist, see [workflow run](https://github.com/ionide/FsAutoComplete/actions/runs/23994119498). [Learn more](https://github.com/githubnext/agentics/blob/main/docs/repo-assist.md).
>
> To install this [agentic workflow](https://github.com/githubnext/agentics/blob/7ee2b60744abf71b985bead4599640f165edcd93/workflows/repo-assist.md), run
> ```
> gh aw add githubnext/agentics/workflows/repo-assist.md@7ee2b60744abf71b985bead4599640f165edcd93
> ```

Contributor guide

Open the contributing guide

Research direction

Start with waitForLatestDiagnostics in test/FsAutoComplete.Tests.Lsp/Utils/Server.fs and dotnetCleanup in test/FsAutoComplete.Tests.Lsp/Helpers.fs. Apply the described empty-buffer handling and directory-delete retry, then run the affected LSP tests or CI scenarios. Done means error-free diagnostics no longer fail on an empty sequence and macOS cleanup no longer intermittently reports a non-empty directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.