Skip to content

Commit ed49c04

Browse files
Correctly handle --keep_going
I will work on making this logic more testable soon Fixes fineGrainedHashExternalRepos parameter issue #267 Signed-off-by: Maxwell Elliott <maxwell.elliott@gotinder.com>
1 parent 3361a6a commit ed49c04

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

cli/src/main/kotlin/com/bazel_diff/bazel/BazelQueryService.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.bazel_diff.bazel
22

33
import com.bazel_diff.log.Logger
4+
import com.bazel_diff.process.ProcessService
45
import com.bazel_diff.process.Redirect
56
import com.bazel_diff.process.process
67
import com.google.devtools.build.lib.analysis.AnalysisProtosV2
@@ -130,6 +131,8 @@ class BazelQueryService(
130131

131132
queryFile.writeText(query)
132133

134+
val allowedExitCodes = mutableListOf(0)
135+
133136
val cmd: MutableList<String> =
134137
ArrayList<String>().apply {
135138
add(bazelPath.toString())
@@ -179,6 +182,7 @@ class BazelQueryService(
179182
}
180183
if (keepGoing) {
181184
add("--keep_going")
185+
allowedExitCodes.add(3)
182186
}
183187
if (useCquery) {
184188
addAll(cqueryOptions)
@@ -204,8 +208,9 @@ class BazelQueryService(
204208
destroyForcibly = true,
205209
)
206210

207-
if (result.resultCode != 0)
208-
throw RuntimeException("Bazel query failed, exit code ${result.resultCode}")
211+
if (result.resultCode !in allowedExitCodes)
212+
logger.w { "Bazel query failed, output: ${result.output.joinToString("\n")}" }
213+
throw RuntimeException("Bazel query failed, exit code ${result.resultCode}, allowed exit codes: ${allowedExitCodes.joinToString()}")
209214
return outputFile
210215
}
211216

0 commit comments

Comments
 (0)