sbt/server-test/src/test/scala/testpkg
Anatolii Kmetiuk 4ed16c96ce
[2.x] Fix publishDiagnostics propagation (#9376)
**Problem**
Test is based on https://github.com/sbt/sbt/issues/9345#issuecomment-4718229113 which gives us the following sequence:

1. Metals sends buildTarget/compile.
2. sbt publishes real non-empty diagnostics.
3. Metals sends buildTarget/scalaMainClasses.
4. During that request, sbt emits build/publishDiagnostics with diagnostics: [] and reset: true.
5. The following build/taskFinish still reports errors: 1.

Previously, errors for diagnostics reporting via bsp were collected from a live compilation run. In the sequence above, that is triggered by buildTarget/compile. Then, buildTarget/scalaMainClasses does not trigger such a run for the second time, it uses the cached compilation result. Therefore, the diagnostics is not populated.

**Solution**
The proposed fix modifies sendFailureReport to accept an optional CompileFailed object that contains the diagnostics even in case the actual compiler did not run because the cached result was used. If no problems were found for a file via default means, this CompileFailed object is queried to see if it has any information about problems in a given file.
2026-06-26 12:36:42 -04:00
..
AbstractServerTest.scala Add parentheses (#9000) 2026-03-31 13:48:59 -04:00
BuildServerTest.scala [2.x] Fix publishDiagnostics propagation (#9376) 2026-06-26 12:36:42 -04:00
ChannelCursorTest.scala [2.x] fix: server-test and related refactoring (#8904) 2026-03-21 23:45:37 -04:00
ClientSubscriptionTest.scala [2.x] fix: server-test and related refactoring (#8904) 2026-03-21 23:45:37 -04:00
ClientTest.scala [2.x] fix: server-test and related refactoring (#8904) 2026-03-21 23:45:37 -04:00
EventsTest.scala [2.x] fix: server-test and related refactoring (#8904) 2026-03-21 23:45:37 -04:00
HandshakeTest.scala [2.x] fix: server-test and related refactoring (#8904) 2026-03-21 23:45:37 -04:00
QueuedNotificationTest.scala [2.x] fix: server-test and related refactoring (#8904) 2026-03-21 23:45:37 -04:00
ResponseTest.scala [2.x] fix: Return JSON-RPC error for unknown server methods (#9002) 2026-04-10 01:33:20 -04:00
ServerCompletionsTest.scala [2.x] fix: server-test and related refactoring (#8904) 2026-03-21 23:45:37 -04:00