Repository navigation
test: cover the three test gaps that CodeRabbit found in #1924, #1938 and #1986 - #2033
Merged
lagergren merged 1 commit intoNov 20, 2026
Merged
Conversation
…oper#1924, redhat-developer#1938 and redhat-developer#1986 Part of redhat-developer#2011: its three test gaps. No change in behavior. - `ApplicationUtilsTest` (redhat-developer#1924): on the EDT without read access, it now checks that there is no read access before each of the two overloads, not only before the first, so the second shows that it takes the write-intent lock itself, rather than running with access that the first one left. - "Set Value..." of a read-only variable (redhat-developer#1938): `DAPValueReadOnlyTest` checks `canSetValue`, but not that `DAPValue.getModifier()` uses it. A `DAPValue` needs a debug session, so the check is in `DAPBreakOnValueChangeSessionTest`, whose DAP server now supports `setVariable` and has a read-only field: `getModifier()` gives a modifier for `count` and none for `limit`. - The IPv4 listener (redhat-developer#1986): `ConnectingServer` connects to `InetAddress.getLoopbackAddress()`, which is `::1` on a JVM that prefers IPv6, so no test reached the IPv4 listener there. `IPv4ConnectingServer` connects to `127.0.0.1`, as `IPv6ConnectingServer` does to `::1`. Each new check fails without what it checks: with `getModifier()` ignoring the hint, the session test fails ("A read-only value can't be set"), and with the first listener only, on a JVM started with `-Djava.net.preferIPv6Addresses=true`, the IPv4 test fails. On such a JVM, six tests of `SocketStreamConnectionProviderTest` and `UserDefinedSocketConnectionTest` fail before and after this change: they expect the text of an IPv4 address, such as `HOST + ":" + port` without the brackets of an IPv6 address, or `127.0.0.1` before `[::1]`. They are left as they are.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2033 +/- ##
==========================================
+ Coverage 49.39% 49.42% +0.03%
==========================================
Files 813 813
Lines 33323 33323
Branches 5191 6848 +1657
==========================================
+ Hits 16461 16471 +10
+ Misses 14290 14277 -13
- Partials 2572 2575 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 20, 2026
lagergren
added a commit
that referenced
this pull request
Nov 20, 2026
…2034) On a JVM started with `-Djava.net.preferIPv6Addresses=true`, `InetAddress.getLoopbackAddress()` is `::1`, and six socket tests failed, for the way they wrote the expected text, not for what LSP4IJ does: - `SocketStreamConnectionProviderTest` wrote the host before a port as `HOST + ":" + port`, which for `0:0:0:0:0:0:0:1` lacks the brackets that the provider writes, as it must: `testConnectsToALanguageServerThatRunsAlreadyAndLeavesItRunningWhenItStops`, `testCannotStartWhenNoLanguageServerListens` and `testConnectionDescriptionForAttach`. - `UserDefinedSocketConnectionTest` looked for the JVM's loopback address as `getHostAddress() + ":" + port`, so `0:0:0:0:0:0:0:1:6005` in `connect to [::1]:6005 or 127.0.0.1:6005`: `testALanguageServerThatRunsAlreadyIsReachedOnTheLoopbackAddressWithoutAHost`, `testABlankHostIsTheLoopbackAddress` and `testALanguageServerWhichListensIsReachedOnTheLoopbackAddress`. The first now writes the host in brackets when it is an IPv6 address. The second now checks both loopback addresses in the order the provider tries them, the JVM's first, which also checks that order, where it checked each address on its own before. Follow-up to #2033, which adds a test of the IPv4 listener for such a JVM. The two touch different lines and merge cleanly. ### Tests - On a JVM that prefers IPv6 addresses (`JAVA_TOOL_OPTIONS=-Djava.net.preferIPv6Addresses=true`), the 22 test classes that use loopback addresses had these six failures and no others (171 tests). With this change, `SocketStreamConnectionProviderTest` and `UserDefinedSocketConnectionTest` pass there, and on a default JVM (37 tests each). - With #2033 merged in, both classes pass on a JVM that prefers IPv6 addresses too, its new IPv4 test included (38 tests).
lagergren
added a commit
that referenced
this pull request
Nov 21, 2026
…#2035) `DAPLoopbackConnectionTest.withoutAnAddressTheWaitForTheDAPServerSeesItsSocketOnTheIPv6LoopbackAddress` failed in the 2026.3 job of #2032, which doesn't touch DAP: org.opentest4j.AssertionFailedError: expected: <false> but was: <true> at ...DAPLoopbackConnectionTest.java:59 The three tests of the class listen on a port of `::1` that the system picks, and expect nothing on the same port of `127.0.0.1`: a connection there must be refused, and a client without an address must fall through to `::1`. A port that is free on `::1` can be in use on `127.0.0.1` by another program or test, and then the connection is accepted and the test fails. The tests now also bind that port of `127.0.0.1` with a socket that doesn't listen, and take another port when it is in use. While it is bound, nothing else can listen there, so a connection to it is refused. ### Tests Checked on macOS, with another process as the other program: - a program can listen on `127.0.0.1` on the port that the test has on `::1`, and a connection to it is then accepted, which is the failure of the job; - then the reservation can't bind the port (`Address already in use`), and the test takes another one; - once the port is reserved, another program can't listen on it, even with `SO_REUSEADDR`, nor can a `ServerSocket` with `SO_REUSEADDR`, and a connection to it is refused. `DAPLoopbackConnectionTest` passes on a default JVM and on one that prefers IPv6 addresses. Not here: two tests of `SocketStreamConnectionProviderTest` have the same race, `testWithoutAHostItReachesALanguageServerWhichListensOnTheIPv6LoopbackAddressOnly` and `testAnIPv4AddressAsTheHostIsNotTriedOverIPv6`. #2033 and #2034 change that file, so they can follow once those are merged.
lagergren
added a commit
that referenced
this pull request
Nov 23, 2026
… of the file it found (#2089) Fixes #2011 ## What When the check of an installer finds the server installed, the download doesn't run, and only the download gives the server its command. So a server created from a template once its binary was installed kept the template's command, such as `clangd` or `${BASE_DIR}/rust-analyzer`. #2041, #2054 and #2057 fixed the templates with a fixed path. This fixes the rest: servers in a folder or file named after their version, or at a path by architecture. #2033 already covered the test gaps of #2011. ## Change - **`${check.file}`:** `fileExists` gives the file it found to the tasks after it. - The path is as written in `file`, with `${...}` properties resolved and macros kept, as `$USER_HOME$/.lsp4ij/lsp/clangd_19.1.2/bin/clangd`. That is the same form as a download's `${output.dir}`. - If a glob matches several files, the last in natural order wins, segment by segment: `clangd_19.1.10` after `clangd_19.1.2`, and `camel-lsp-server-1.31.0.jar` after `camel-lsp-server-1.9.0.jar`. - A `fileExists` that finds nothing removes `${check.file}`. - **A new task, `replaceTemplateCommand`,** with `templateCommand` and `command`, both by OS like `command`. - It sets the command as `configureServer` does, but only while the server's command is exactly `templateCommand`. - Otherwise it leaves the command and succeeds, so the check still passes, and *Check installation* in the settings keeps a command that the user or a download set. - On an OS without a `templateCommand`, it changes nothing. - **Why a separate task, not an option of `configureServer`: older versions stay safe.** - LSP4IJ 0.30.1 skips a task type it doesn't know. So after a downgrade, a Settings Sync with an older IDE, or a template imported into an older version, the check still passes, and the server keeps its command. - A `configureServer` there would set the literal `"${check.file}"`. - Both were checked by running the 0.30.1 code on these installers. - **`configureServer`** is unchanged, except that a command that still has `${check.file}` after resolution is now reported as an error and not set. - **The bundled installers:** the checks of clangd, camel-lsp-server, ada_language_server, rust-analyzer, wgsl-analyzer, codelldb, perl-dap and vscode-js-debug get an `onSuccess` `replaceTemplateCommand`, with their template's command and the command that their download gives, from `${check.file}`. cpp_ls, docker-language-server and terraform-ls keep their commands on the PATH. - **ada_language_server's check** now looks under `integration/`. Every Ada release archive since before the template existed has that single root folder, which the download adds to `${output.dir}`, so the old check never found the installed server. - **Schema and docs:** the `installer.json` schema and `docs/UserDefinedLanguageServerTemplate.md` describe `fileExists`, `${check.file}` and `replaceTemplateCommand`, with clangd's check as the example. Servers created before this change keep the installer they were created with, so they aren't affected. ## Test - **`FileExistsTaskTest`:** `${check.file}` without a glob, with several matches (in natural order; a folder without the file is ignored), with a glob in the file name, and with macros kept; no property when the file is missing, and an earlier one removed. - **`ReplaceTemplateCommandTaskTest`** (new): - the template's command is replaced; - a command that the user changed, and one that an earlier download set, stay, and the task still succeeds; - no `templateCommand` for the OS changes nothing; - an unresolved `${check.file}` is an error and changes nothing, in this task and in `configureServer`; - `configureServer` still changes the command as before; - `templateCommand` by OS; - the plugin's registry loads the task for the bundled clangd installer; - a full check with two versions of clangd. - **`InstallerTaskRegistryFileExistsTest`:** for clangd, camel-lsp-server, codelldb, perl-dap and vscode-js-debug, it runs the download from a local archive, then the check for a server with the template's command. The check sets the same command as the download, and a changed command and one from an earlier version stay. - **`BundledTemplateCommandsTest`:** for the eight templates and each OS and architecture that they declare, the check finds the file that the download installs, its command equals the download's, and `templateCommand` equals the template's command. The test of a home directory with a space now also covers the check commands. - **Results:** the installation and template tests pass (110), and so does the full suite (1,845 tests, 0 failures, 7 skipped).
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.
Part of #2011: its three test gaps. No change in behavior.
ApplicationUtilsTest(fix: read on the EDT without a non-blocking read action #1924): on the EDT without read access, it nowchecks that there is no read access before each of the two overloads,
not only before the first, so the second shows that it takes the
write-intent lock itself, rather than running with access that the
first one left.
DAPValueReadOnlyTestchecks
canSetValue, but not thatDAPValue.getModifier()uses it. ADAPValueneeds a debug session, so the check is inDAPBreakOnValueChangeSessionTest, whose DAP server now supportssetVariableand has a read-only field:getModifier()gives amodifier for
countand none forlimit.ConnectingServerconnects toInetAddress.getLoopbackAddress(), which is::1on a JVM thatprefers IPv6, so no test reached the IPv4 listener there.
IPv4ConnectingServerconnects to127.0.0.1, asIPv6ConnectingServerdoes to::1.Each new check fails without what it checks: with
getModifier()ignoring the hint, the session test fails ("A read-only value can't be
set"), and with the first listener only, on a JVM started with
-Djava.net.preferIPv6Addresses=true, the IPv4 test fails.On such a JVM, six tests of
SocketStreamConnectionProviderTestandUserDefinedSocketConnectionTestfail before and after this change: theyexpect the text of an IPv4 address, such as
HOST + ":" + portwithoutthe brackets of an IPv6 address, or
127.0.0.1before[::1]. They areleft as they are.
Tests
ApplicationUtilsTest,SocketStreamConnectionProviderTest,DAPBreakOnValueChangeSessionTestandDAPValueReadOnlyTestpass (46 tests).