Skip to content

Test Explorer fsharp tag from the project's language (#604), 20-attach reliability test, unpredictable sidecar endpoints - #607

Merged
MelbourneDeveloper merged 6 commits into
mainfrom
chore/finish-plans-5
Nov 19, 2026
Merged

MelbourneDeveloper merged 6 commits into
mainfrom
chore/finish-plans-5

Conversation

@MelbourneDeveloper

@MelbourneDeveloper MelbourneDeveloper commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

TLDR

Fixes the Test Explorer's fsharp tag (#604), adds a test that attaches 20 times in a row, makes sidecar endpoint names unpredictable, and ticks the plan rows these prove.

Details

  • Test Explorer 'fsharp' tag is guessed from the test name: real Expecto tests are untagged, C# 'Property' tests are tagged F# #604 fsharp tag (test-language.ts, new):
    • A test row is now tagged fsharp when an .fsproj built it. The project is the one the listing names; otherwise it is the nearest project file above the assembly's output folder.
    • Before, the tag was guessed from the test name: a real Expecto test was untagged, and a C# PropertyTests was tagged F#.
    • isExpectoTest and isFsCheckTest have no remaining production use, so they are deleted.
    • The shared test helpers (assertLeafItem, assertPlainLeaf, assertSnapshotUriShape, assertTaggedFor) now take each row's expected language tag instead of asserting "no tag". This change was made with the fix, as the issue asked.
  • Sidecar endpoint names (sidecar/manager/launch.rs):
    • The IPC token now XORs a 64-bit random number from getrandom (the OS's secure random source) into the root/pid/counter hash.
    • It is now 16 hex digits. On macOS the socket path is about 86 bytes, under the 104-byte limit.
    • getrandom 0.4 was already in Cargo.lock through other crates.
    • If the random source fails, a warning is logged and the token falls back to the hash alone.
  • Restore failures name their cause (WorkspaceRestore.cs): a failed workspace restore now reports the SDK's own error lines (e.g. NU1101: Unable to find package …) and falls back to the tail of the output. Before, it said only "Package restore failed for ".
  • Attach reliability (debug-attach-reliability-e2e.test.ts, new): attaches 20 times to one running process. Each attach must pause the process and detach without killing it. The attach suite's shared helpers move into debug-attach-kit.ts.
  • Plans:

How Do The Automated Tests Prove It Works?

  • test-explorer-fsharp-frameworks.test.ts: every Expecto and FsCheck row must carry exactly ['fsharp'].
    • Before the fix it failed with calculator.adds two numbers carries exactly the tags of its project's language (#604) (actual []).
  • test-explorer-frameworks.test.ts, test-explorer-e2e.test.ts, test-explorer-netfx.test.ts, real-repo-netfx-fsharp.test.ts: F# xUnit, NUnit and MSTest rows carry fsharp, and C# rows carry no tag.
  • test-language.test.ts uses real folders:
    • a PropertyTests.csproj resolves to C#;
    • an Expecto .fsproj resolves to F#;
    • a project named in the listing wins over the folder walk;
    • an assembly with no project resolves to no language.
  • Local run on macOS: 63 passing, covering the frameworks, e2e, lens, reactive, Expecto/FsCheck, mixed-MTP and language suites. The .NET Framework suites run only on Windows, so CI's Windows legs cover them.
  • WorkspaceRestoreGateTests (new) uses a package missing from an empty local feed:
    • the restore fails, and no workspace is created;
    • the error names the missing package (this failed before the message fix);
    • after the project is repaired, the same manager opens it.
    • The Common restore tests (21) and the F# restore tests (9) still pass.
  • launch.rs:
    • endpoint_tokens_are_unpredictable_and_constant_length: 64 random values, all distinct and non-zero; 64 tokens for the same root, all distinct and all 16 hex digits.
    • same_workspace_managers_get_distinct_ipc_endpoints still passes.
  • debug-attach-reliability-e2e.test.ts: 20/20 attaches locally in 15 s, and the existing attach suite still passes (5 passing).

…s each pause it and detach without killing it; the attach suite's shared helpers move into debug-attach-kit
…ndom nonce into the root/pid/counter hash, 16 hex digits, so no local process can predict and pre-bind it
…s name looks like Expecto or FsCheck (#604): every F# test is tagged, no C# test is; the name-guessing helpers are deleted
@MelbourneDeveloper
MelbourneDeveloper enabled auto-merge (squash) November 19, 2026 14:55
…'s own error lines (NU1101 …) instead of only the project path; the C# gate is proven to open no workspace until the project is repaired
…hat terminal on open, instead of firing the close before anyone listens and leaving a ghost terminal beside the next run
@MelbourneDeveloper
MelbourneDeveloper merged commit 9e59895 into main Nov 19, 2026
116 of 119 checks passed
@MelbourneDeveloper
MelbourneDeveloper deleted the chore/finish-plans-5 branch November 19, 2026 16:20
MelbourneDeveloper added a commit that referenced this pull request Nov 19, 2026
…sts flake) (#610)

## TLDR
A cancelled Test Explorer Debug gesture no longer leaves a leftover
"SharpLsp Test Debug" terminal beside the next debug run. This is the
cause of the repeated Linux `debug-tests` failures (`the cancelled
gesture leaves no ghost terminal beside the live debug run`, `2 !== 1`).

## Details
- `test-debug.ts`:
- **An already-cancelled gesture opens no terminal.** It runs nothing
worth showing.
- **A run's end disposes its terminal window.** Firing the pty's close
event alone only reaches a terminal VS Code has opened. On headless
Linux, VS Code may never open the pty of a short-lived run, so its
terminal stayed open.
- #607's open-time close stays, for a run that ends while its terminal
is opening.
- Live runs are unchanged: the terminal still opens, stays live while
the debugger attaches, and closes when the run ends.

## How Do The Automated Tests Prove It Works?
- `debug-test-stop-e2e.test.ts` *Stop ends its host and terminal, never
retries, and the next Debug starts clean* (F# and C#, VSTest and MTP)
asserts exactly one test-debug terminal after a pre-cancelled gesture.
- It failed on Linux CI on the first run of #606, #607 and #609 with `2
!== 1`.
- CI on this PR is the proof, because it always passed locally on macOS.
- Locally: the `debug-test-mtp`, `debug-test-stop`,
`debug-terminal-cancel` and `debug-test-debugging` suites pass, 35
tests.
- `test-explorer-outcomes.test.ts` still asserts that the Debug profile
opens exactly one live terminal for a real run.
MelbourneDeveloper added a commit that referenced this pull request Nov 19, 2026
…mpt (Linux debug-inspection wedge) (#614)

## TLDR
The 20-attach reliability test (added in #607) stops wedging Linux
`debug-inspection`. Each attempt now attaches to its own fresh process
and pauses the session that attach started.

## Details
- **Failure** (#613, Linux `debug-inspection`): attempt 2's
`stopDebuggee` timed out after 45 s. The stuck session then failed every
later suite in the chunk, 12 failures in all.
- **Mechanism, from the uploaded debugger trace:**
  - Attempt 1 attached, paused and detached in 0.2 s.
- Attempt 2's attach was accepted, but no `pause` was ever sent.
`startAttached` returns `vscode.debug.activeDebugSession`, which still
named attempt 1's ending session. `pauseAttached` polled `threads` on
that dead session until its 60-second limit.
- Meanwhile the fixture's 30-second `wait` ran out. The process exited
(`exited` code 0 at +29 s), and the session never settled in time.
- Separately, 20 attaches to ONE 30-second fixture cannot fit on a slow
runner: the attaches took 15 s locally, but CI is slower.
- **Fix** (test only, no product change):
- Every attempt starts a fresh fixture process. After the detach the
test asserts that process is still alive, then kills it.
- The attempt's session comes from `DebugSessionRecorder`, by its start
index, never from `activeDebugSession`.
- New end-of-test assertions: exactly 20 sessions started, and every one
ended.

## How Do The Automated Tests Prove It Works?
- `debug-attach-reliability-e2e.test.ts` *at least 19 of 20 attaches
pause a live process, and every detach leaves it running* passes
locally: 20/20 in 21 s, with every pause stop recorded and a clean
session.
- `debug-attach-e2e.test.ts` still passes (5 tests).
- On this PR, Linux `debug-inspection` runs the test after the rest of
the chunk, at CI speed.
MelbourneDeveloper added a commit that referenced this pull request Nov 19, 2026
…ile watcher (Windows F# add-file hover) (#613)

## TLDR
Adding an F# file from the Solution Explorer now reloads the F# project
right away. Before, the reload waited for the file watcher to notice the
host's own `.fsproj` write; on Windows it sometimes didn't, and the new
file stayed unowned, with no hover or diagnostics.

## Details
- **Symptom:** the Windows `workspace` leg failed on #607, #609 and #612
in *Solution Explorer — Add F# Source File: project node: adds .fs
before the last Compile item and FCS owns it*. A hover on the new file
stayed `[]` for the test's 90-second polling limit. Each failure passed
on re-run.
- **Mechanism, from the uploaded host and sidecar logs of a passing
run:**
- `sharplsp/project/addCompileItem` edits the `.fsproj` through the C#
sidecar's MSBuild editing.
- Nothing then told the F# sidecar. Its reload ("F# loaded …fsproj,
which owns …NewLogic.fs") came about 1.8 s later, only because the
native watcher noticed the write.
- The Windows logs show watcher `EPERM` and "watcher shutdown" errors.
When the event is lost, the project is never reloaded.
- **Fix:**
- `pull_diagnostics/monitor.rs` gains `written(paths)`. It posts the
same `workspace/didChangeWatchedFiles` notification the native watcher
sends (type Changed, `sharplspRescan: false`) onto the foreground
dispatch queue.
- `project_edit.rs` calls it after any compile-item edit that modified
the project.
- A watcher event that also arrives is merged into the same reload by
the existing reload worker.
- `pull_diagnostics/state.rs` exposes the dispatch queue (`inbound()`).
Both files stay under 500 lines.

## How Do The Automated Tests Prove It Works?
-
`written_tests::a_project_file_the_host_writes_is_announced_as_a_watched_change`
(new) checks three cases:
  1. Before the dispatch queue exists, the call is a no-op.
2. Once the queue exists, one `didChangeWatchedFiles` arrives, carrying
exactly `[{ uri: <project>, type: 2 }]` with `sharplspRescan: false`.
  3. Writing no paths sends no notification.
- All 371 host unit tests pass (`--test-threads=1`), and clippy is
clean.
- On this PR, the Windows `workspace` leg runs the Add F# Source File
suite end to end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant