Skip to content

Commit 275544c

Browse files
authored
Fix querying of test bundles (#134)
1 parent 44e3285 commit 275544c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BazelTargetQuerier.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ final class BazelTargetQuerier {
8888
// Always fetch source information.
8989
// FIXME: Need to also handle `generated file`
9090
dependencyKindsFilter.append("source file")
91-
92-
var topLevelKindsFilter = supportedTopLevelRuleTypes.map { $0.rawValue }
9391
// If we're searching for test rules, we need to also include their test bundle rules.
9492
// Otherwise we won't be able to map test dependencies back to their top level parents.
9593
let testBundleRules = supportedTopLevelRuleTypes.compactMap { $0.testBundleRule }
96-
topLevelKindsFilter.append(contentsOf: testBundleRules)
94+
dependencyKindsFilter.append(contentsOf: testBundleRules)
95+
96+
let topLevelKindsFilter = supportedTopLevelRuleTypes.map { $0.rawValue }
9797

9898
// Collect the top-level targets -> collect these targets' dependencies
9999
let providedTargetsQuerySet = "set(\(userProvidedTargets.joined(separator: " ")))"

Sources/SourceKitBazelBSP/RequestHandlers/BuildTargets/BazelTargetQuerierParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ final class BazelTargetQuerierParserImpl: BazelTargetQuerierParser {
265265
// The cquery seems to pick up things that have the expected name somewhere within the string, like
266266
// my_custom_swift_library. Ignore those
267267
logger.warning(
268-
"Skipping target \(rule.name, privacy: .public) with unexpected rule class: \(rule.ruleClass). This can also happen if you used --dependency-rule-to-discover flag is set to filter this type."
268+
"Skipping target \(rule.name, privacy: .public) with unexpected rule class: \(rule.ruleClass). This can also happen if the BSP was configured to filter this type."
269269
)
270270
continue
271271
}
@@ -309,7 +309,7 @@ final class BazelTargetQuerierParserImpl: BazelTargetQuerierParser {
309309
// If we don't know how to parse the full path to a target, we need to drop it.
310310
// Otherwise we will not know how to properly communicate this target's capabilities to sourcekit-lsp.
311311
logger.warning(
312-
"Skipping orphan target \(label, privacy: .public). This can happen if the target is a dependency of a test host or of something we don't know how to parse."
312+
"Skipping orphan target \(label, privacy: .public). This can happen if the target is a dependency of a test host, of something we don't know how to parse, or if the BSP was configured to filter this target's parent(s)."
313313
)
314314
result[label] = nil
315315
}

Tests/SourceKitBazelBSPTests/BazelTargetQuerierTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ struct BazelTargetQuerierTests {
181181
let config = Self.makeInitializedConfig()
182182

183183
let expectedCommand =
184-
"bazelisk --output_base=/path/to/output/base cquery \'let topLevelTargets = kind(\"ios_application|watchos_unit_test|_watchos_internal_unit_test_bundle\", set(//HelloWorld)) in $topLevelTargets union (kind(\"swift_library|objc_library|cc_library|alias|source file\", deps($topLevelTargets)))\' --noinclude_aspects --notool_deps --noimplicit_deps --output proto --config=test"
184+
"bazelisk --output_base=/path/to/output/base cquery \'let topLevelTargets = kind(\"ios_application|watchos_unit_test\", set(//HelloWorld)) in $topLevelTargets union (kind(\"swift_library|objc_library|cc_library|alias|source file|_watchos_internal_unit_test_bundle\", deps($topLevelTargets)))\' --noinclude_aspects --notool_deps --noimplicit_deps --output proto --config=test"
185185
runnerMock.setResponse(for: expectedCommand, cwd: Self.mockRootUri, response: exampleCqueryOutput)
186186

187187
_ = try querier.cqueryTargets(

0 commit comments

Comments
 (0)