Skip to content

Commit

Permalink
When the SourceKit plugins fail to load during testing, include the s…
Browse files Browse the repository at this point in the history
…earch base in the error
  • Loading branch information
ahoppen committed Jan 22, 2025
1 parent fe5644b commit 131907d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Sources/SKTestSupport/PluginPaths.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,30 @@ private func pluginPaths(relativeTo base: URL) -> PluginPaths? {
package var sourceKitPluginPaths: PluginPaths {
get throws {
struct PluginLoadingError: Error, CustomStringConvertible {
var description: String =
"Could not find SourceKit plugin. Ensure that you build the entire SourceKit-LSP package before running tests."
let searchBase: URL
var description: String {
"""
Could not find SourceKit plugin. Ensure that you build the entire SourceKit-LSP package before running tests.
Searching for plugin relative to \(searchBase)
"""
}
}

var base =
let base =
if let pluginPaths = ProcessInfo.processInfo.environment["SOURCEKIT_LSP_TEST_PLUGIN_PATHS"] {
URL(fileURLWithPath: pluginPaths)
} else {
xctestBundle
}
while base.pathComponents.count > 1 {
if let paths = pluginPaths(relativeTo: base) {
var searchPath = base
while searchPath.pathComponents.count > 1 {
if let paths = pluginPaths(relativeTo: searchPath) {
return paths
}
base = base.deletingLastPathComponent()
searchPath = searchPath.deletingLastPathComponent()
}

throw PluginLoadingError()
throw PluginLoadingError(searchBase: base)
}
}

0 comments on commit 131907d

Please sign in to comment.