Skip to content

Cover the language client stop-failure path deterministically - #40

Merged
david-yz-liu merged 3 commits into
mainfrom
cover-restart-stop-failure
Nov 7, 2026
Merged

david-yz-liu merged 3 commits into
mainfrom
cover-restart-stop-failure

Conversation

@david-yz-liu

@david-yz-liu david-yz-liu commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Extract the stop step of restartServer into an exported stopServer helper in src/common/server.ts. Behaviour is unchanged: stop failures are still logged with traceError and swallowed so the restart can continue.
  • Add src/test/suite/server.test.ts, which tests stopServer with fake clients: no client, a client that stops cleanly, and a client whose stop() rejects with the "Client is not running and can't be stopped… state is: starting" error.
  • Fix the flaky settings.checkIfConfigurationChanged tests. They resolved on the first configuration change event of any kind, so an unrelated change (e.g. from another extension activating) could arrive first and fail the assertion. This was failing intermittently on main too (e.g. run 42408513567). They now wait only for an event that affects the section each test updates (python-ta.args, editor.wordWrap).
  • Add CHANGELOG entries under "Internal changes".

Why

TypeScript coverage was flaky (e.g. -0.7% on #39, which changed no TypeScript). The catch branch in restartServer (server.ts) and traceError (logging.ts) were only covered when settings.test.ts, which changes python-ta.args and so triggers a real server restart, happened to restart while the previous client was still starting. Whether that happens depends on how fast the Python server launches on the CI runner. With this change those lines are covered on every run.

Calling restartServer directly from a test would launch a second real language server alongside the extension's own, which is why the stop step is extracted instead.

Test plan

  • pnpm run lint, Prettier check and pnpm run compile-tests pass
  • New server.stopServer tests pass in CI (3/3), and lines 88-89 of server.ts and line 13 of logging.ts are covered
  • CI: settings tests pass (17/17 extension tests passing)

🤖 Generated with Claude Code

david-yz-liu and others added 2 commits November 7, 2026 15:06
Extract the stop step of restartServer into an exported stopServer
helper and test it with fake clients, including one whose stop()
rejects. Previously the catch branch (and traceError) was only covered
when a settings test happened to restart the server while the previous
client was still starting, which made TypeScript coverage flaky.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coveralls

coveralls commented Nov 7, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 42409895212

Coverage increased (+0.4%) to 66.015%

Details

  • Coverage increased (+0.4%) from the base build.
  • Patch coverage: 18 of 18 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 1319
Covered Lines: 865
Line Coverage: 65.58%
Relevant Branches: 114
Covered Branches: 81
Branch Coverage: 71.05%
Branches in Coverage %: Yes
Coverage Strength: 1.74 hits per line

💛 - Coveralls

The checkIfConfigurationChanged tests resolved on the first
onDidChangeConfiguration event of any kind, so an unrelated settings
change (e.g. from another extension activating) could arrive first and
make the assertion fail. Wait only for an event that affects the
section each test updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@david-yz-liu
david-yz-liu merged commit d7b536f into main Nov 7, 2026
7 checks passed
@david-yz-liu
david-yz-liu deleted the cover-restart-stop-failure branch November 7, 2026 20:24
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.

2 participants