File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed
main/kotlin/com/bazel_diff/bazel
test/kotlin/com/bazel_diff/e2e Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,13 @@ class BazelClient(
35
35
// In addition, we must include all source dependencies in this query in order for them to
36
36
// show up in
37
37
// `configuredRuleInput`. Hence, one must not filter them out with `kind(rule, deps(..))`.
38
- (queryService.query(" deps(//...:all-targets)" , useCquery = true ) +
39
- queryService.query(repoTargetsQuery.joinToString(" + " ) { " '$it '" }))
40
- .distinctBy { it.name }
38
+ val mainTargets = queryService.query(" deps(//...:all-targets)" , useCquery = true )
39
+ val repoTargets = if (repoTargetsQuery.isNotEmpty()) {
40
+ queryService.query(repoTargetsQuery.joinToString(" + " ) { " '$it '" })
41
+ } else {
42
+ emptyList()
43
+ }
44
+ (mainTargets + repoTargets).distinctBy { it.name }
41
45
} else {
42
46
val buildTargetsQuery =
43
47
listOf (" //...:all-targets" ) +
Original file line number Diff line number Diff line change @@ -587,6 +587,31 @@ class E2ETest {
587
587
assertThat(actual).isEqualTo(expected)
588
588
}
589
589
590
+ @Test
591
+ fun testUseCqueryWithExcludeExternalTargets () {
592
+ // This test verifies the fix for the issue where using --excludeExternalTargets with --useCquery
593
+ // would cause an empty query string to be passed to Bazel, resulting in exit code 2.
594
+ val project = extractFixtureProject(" /fixture/integration-test-1.zip" )
595
+
596
+ val workingDirectory = File (project, " integration" )
597
+ val bazelPath = " bazel"
598
+ val outputDir = temp.newFolder()
599
+ val hashesJson = File (outputDir, " hashes.json" )
600
+
601
+ val cli = CommandLine (BazelDiff ())
602
+
603
+ val exitCodeFrom = cli.execute(
604
+ " generate-hashes" ,
605
+ " -w" ,
606
+ workingDirectory.absolutePath,
607
+ " -b" ,
608
+ bazelPath,
609
+ " --useCquery" ,
610
+ " --excludeExternalTargets" ,
611
+ hashesJson.absolutePath)
612
+ assertThat(exitCodeFrom).isEqualTo(0 )
613
+ }
614
+
590
615
@Test
591
616
fun testTargetDistanceMetrics () {
592
617
val workspace = copyTestWorkspace(" distance_metrics" )
You can’t perform that action at this time.
0 commit comments