Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
[fix] now we report the failure of the whole test target and binaries…
Browse files Browse the repository at this point in the history
… are reporting stdout | #BAZEL-361 Done

changelog

binaries are reporting output now

[fix] now we report the failure of the whole test target

Merge-request: BAZEL-MR-326
Merged-by: Marcin Abramowicz <marcin.abramowicz@jetbrains.com>
  • Loading branch information
abrams27 authored and qodana-bot committed Jun 27, 2023
1 parent 3d23205 commit 224c1ec
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

- Bloop support has been dropped.

### Fixes 🛠️
- Now we report the failure of the whole test target and binaries are reporting stdout.


## [2.7.2]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ open class BazelRunnerBuilder internal constructor(
return this
}

fun executeBazelCommand(): BazelProcess {
return bazelRunner.runBazelCommand(bazelCommand, flags, arguments)
fun executeBazelCommand(originId: String? = null): BazelProcess {
return bazelRunner.runBazelCommand(bazelCommand, flags, arguments, originId)
}

fun executeBazelBesCommand(originId: String? = null, bazelBesPort: Int): BazelProcess {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetbrains.bsp.bazel.bazelrunner.outputs

import com.google.common.base.Charsets
import org.eclipse.lsp4j.jsonrpc.CancelChecker
import java.io.BufferedReader
import java.io.IOException
Expand Down Expand Up @@ -30,7 +31,7 @@ abstract class OutputProcessor(private val process: Process, vararg loggers: Out
protected fun start(inputStream: InputStream, vararg handlers: OutputHandler) {
val runnable = Runnable {
try {
BufferedReader(InputStreamReader(inputStream)).use { reader ->
BufferedReader(InputStreamReader(inputStream, Charsets.UTF_8)).use { reader ->
var prevLine: String? = null

while (!Thread.currentThread().isInterrupted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import ch.epfl.scala.bsp4j.CompileParams
import ch.epfl.scala.bsp4j.CompileResult
import ch.epfl.scala.bsp4j.RunParams
import ch.epfl.scala.bsp4j.RunResult
import ch.epfl.scala.bsp4j.StatusCode
import ch.epfl.scala.bsp4j.TaskId
import ch.epfl.scala.bsp4j.TestParams
import ch.epfl.scala.bsp4j.TestResult
import ch.epfl.scala.bsp4j.TestStatus
import ch.epfl.scala.bsp4j.TextDocumentIdentifier
import io.grpc.Server
import org.eclipse.lsp4j.jsonrpc.CancelChecker
Expand Down Expand Up @@ -59,16 +62,29 @@ class ExecuteService(
return TestResult(result.statusCode)
}
val targetsSpec = TargetsSpec(targets, emptyList())
val taskId = TaskId(params.originId)
val displayName = targets.joinToString(", ") { it.uri }
bspClientTestNotifier.startTest(
isSuite = false,
displayName = displayName,
taskId = taskId
)

result = withBepServer {server ->
bazelRunner.commandBuilder().test()
.withTargets(targetsSpec)
.withArguments(params.arguments)
.withFlag(BazelFlag.testOutputAll())
.executeBazelBesCommand(params.originId, server.port)
.waitAndGetResult(cancelChecker, true)
}
JUnit5TestParser(bspClientTestNotifier).processTestOutput(result)
result = bazelRunner.commandBuilder().test()
.withTargets(targetsSpec)
.withArguments(params.arguments)
.withFlag(BazelFlag.testOutputAll())
.withFlag(BazelFlag.color(true))
.executeBazelCommand(params.originId)
.waitAndGetResult(cancelChecker, true)

bspClientTestNotifier.finishTest(
isSuite = false,
displayName = displayName,
taskId = taskId,
status = if (result.statusCode == StatusCode.OK) TestStatus.PASSED else TestStatus.FAILED,
message = null,
)
return TestResult(result.statusCode).apply {
originId = originId
data = result
Expand All @@ -92,11 +108,13 @@ class ExecuteService(
return RunResult(result.statusCode)
}
val bazelProcessResult =
withBepServer { server ->
bazelRunner.commandBuilder().run().withArgument(BspMappings.toBspUri(bspId))
.withArguments(params.arguments).executeBazelBesCommand(params.originId, server.port)
.waitAndGetResult(cancelChecker)
}
bazelRunner.commandBuilder()
.run()
.withArgument(BspMappings.toBspUri(bspId))
.withArguments(params.arguments)
.withFlag(BazelFlag.color(true))
.executeBazelCommand(params.originId)
.waitAndGetResult(cancelChecker)
return RunResult(bazelProcessResult.statusCode).apply { originId = originId }
}

Expand Down

0 comments on commit 224c1ec

Please sign in to comment.