Skip to content

Commit 4a49bbe

Browse files
Add e2e coverage for cquery streamed_proto path (#219) and bump to 19.0.1 (#333)
The fix for #219 (streamed_proto support for cquery) landed in #278; this adds an explicit e2e test that exercises the --useCquery code path to guard against regressions in the parseDelimitedFrom loop. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 71ce2a1 commit 4a49bbe

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module(
22
name = "bazel-diff",
3-
version = "19.0.0",
3+
version = "19.0.1",
44
compatibility_level = 0,
55
)
66

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ First, add the following snippet to your project:
320320
#### Bzlmod snippet
321321

322322
```bazel
323-
bazel_dep(name = "bazel-diff", version = "19.0.0")
323+
bazel_dep(name = "bazel-diff", version = "19.0.1")
324324
```
325325

326326
You can now run the tool with:

cli/src/test/kotlin/com/bazel_diff/e2e/E2ETest.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,33 @@ class E2ETest {
183183
"/fixture/impacted_targets-1-2-rule-sourcefile.txt")
184184
}
185185

186+
@Test
187+
fun testGenerateHashesWithCqueryStreamedProto() {
188+
// Validates the --useCquery code path that consumes Bazel's `--output=streamed_proto`
189+
// cquery output (https://github.com/Tinder/bazel-diff/issues/219). On Bazel 7.0.0+ this
190+
// exercises the AnalysisProtosV2.CqueryResult.parseDelimitedFrom loop in
191+
// BazelQueryService.query(); on older Bazel it falls back to single-message proto parsing.
192+
// Uses the `distance_metrics` shell-only workspace so cquery analysis works without a
193+
// sandboxed JDK / coursier fetch.
194+
val workspace = copyTestWorkspace("distance_metrics")
195+
val outputDir = temp.newFolder()
196+
val output = File(outputDir, "hashes.json")
197+
198+
val cli = CommandLine(BazelDiff())
199+
val exitCode = cli.execute(
200+
"generate-hashes",
201+
"-w", workspace.absolutePath,
202+
"-b", "bazel",
203+
"--useCquery",
204+
output.absolutePath)
205+
206+
assertThat(exitCode).isEqualTo(0)
207+
208+
val hashes: Map<String, Any> =
209+
Gson().fromJson(output.readText(), object : TypeToken<Map<String, Any>>() {}.type)
210+
assertThat(hashes.isNotEmpty()).isEqualTo(true)
211+
}
212+
186213
@Test
187214
fun testFineGrainedHashExternalRepo() {
188215
// The difference between these two snapshots is simply upgrading the Guava version.

0 commit comments

Comments
 (0)