Skip to content

Commit 131907d

Browse files
committed
When the SourceKit plugins fail to load during testing, include the search base in the error
1 parent fe5644b commit 131907d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

Sources/SKTestSupport/PluginPaths.swift

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,30 @@ private func pluginPaths(relativeTo base: URL) -> PluginPaths? {
112112
package var sourceKitPluginPaths: PluginPaths {
113113
get throws {
114114
struct PluginLoadingError: Error, CustomStringConvertible {
115-
var description: String =
116-
"Could not find SourceKit plugin. Ensure that you build the entire SourceKit-LSP package before running tests."
115+
let searchBase: URL
116+
var description: String {
117+
"""
118+
Could not find SourceKit plugin. Ensure that you build the entire SourceKit-LSP package before running tests.
119+
120+
Searching for plugin relative to \(searchBase)
121+
"""
122+
}
117123
}
118124

119-
var base =
125+
let base =
120126
if let pluginPaths = ProcessInfo.processInfo.environment["SOURCEKIT_LSP_TEST_PLUGIN_PATHS"] {
121127
URL(fileURLWithPath: pluginPaths)
122128
} else {
123129
xctestBundle
124130
}
125-
while base.pathComponents.count > 1 {
126-
if let paths = pluginPaths(relativeTo: base) {
131+
var searchPath = base
132+
while searchPath.pathComponents.count > 1 {
133+
if let paths = pluginPaths(relativeTo: searchPath) {
127134
return paths
128135
}
129-
base = base.deletingLastPathComponent()
136+
searchPath = searchPath.deletingLastPathComponent()
130137
}
131138

132-
throw PluginLoadingError()
139+
throw PluginLoadingError(searchBase: base)
133140
}
134141
}

0 commit comments

Comments
 (0)