You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
of Bazel. You may want to fallback to use normal query mode in that case.
240
247
See <https://github.com/bazelbuild/bazel/issues/17743> for more details.
241
248
249
+
#### Handling Failing Analysis Targets with `--cqueryExpression`
250
+
251
+
When using `--useCquery`, Bazel's `cquery` command analyzes all targets (executes their implementation functions). This can cause issues with targets that are intentionally designed to fail during analysis, such as:
252
+
253
+
-`analysis_test` targets from the Bazel `rules_testing` library
254
+
- Other validation targets that verify build failures
255
+
256
+
With regular `bazel query`, these targets don't cause problems because `query` doesn't execute implementation functions. However, `cquery` will fail when it encounters these targets.
257
+
258
+
**Solution**: Use the `--cqueryExpression` flag to specify a custom query expression that excludes the problematic targets:
Copy file name to clipboardExpand all lines: cli/src/main/kotlin/com/bazel_diff/cli/GenerateHashesCommand.kt
+9Lines changed: 9 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -124,6 +124,14 @@ class GenerateHashesCommand : Callable<Int> {
124
124
)
125
125
var cqueryCommandOptions:List<String> = emptyList()
126
126
127
+
@CommandLine.Option(
128
+
names = ["--cqueryExpression"],
129
+
description =
130
+
[
131
+
"Custom cquery expression to use instead of the default 'deps(//...:all-targets)'. This allows you to exclude problematic targets (e.g., analysis_test targets that are designed to fail). Example: 'deps(//...:all-targets) except //path/to/failing:target'. This flag has no effect if `--useCquery` is false."],
132
+
scope =CommandLine.ScopeType.INHERIT)
133
+
var cqueryExpression:String?=null
134
+
127
135
@CommandLine.Option(
128
136
names = ["-k", "--keep_going"],
129
137
negatable =true,
@@ -200,6 +208,7 @@ class GenerateHashesCommand : Callable<Int> {
0 commit comments