Repository navigation
Cover the language client stop-failure path deterministically - #40
Merged
Merged
Conversation
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>
Coverage Report for CI Build 42409895212Coverage increased (+0.4%) to 66.015%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - 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>
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.
Summary
restartServerinto an exportedstopServerhelper insrc/common/server.ts. Behaviour is unchanged: stop failures are still logged withtraceErrorand swallowed so the restart can continue.src/test/suite/server.test.ts, which testsstopServerwith fake clients: no client, a client that stops cleanly, and a client whosestop()rejects with the "Client is not running and can't be stopped… state is: starting" error.settings.checkIfConfigurationChangedtests. 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 onmaintoo (e.g. run 42408513567). They now wait only for an event that affects the section each test updates (python-ta.args,editor.wordWrap).Why
TypeScript coverage was flaky (e.g. -0.7% on #39, which changed no TypeScript). The
catchbranch inrestartServer(server.ts) andtraceError(logging.ts) were only covered whensettings.test.ts, which changespython-ta.argsand 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
restartServerdirectly 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 andpnpm run compile-testspassserver.stopServertests pass in CI (3/3), and lines 88-89 ofserver.tsand line 13 oflogging.tsare covered🤖 Generated with Claude Code