Skip to content

Commit 24c9e94

Browse files
authored
Merge pull request #1946 from ahoppen/show-plugin-load-base
When the SourceKit plugins fail to load during testing, include the search base in the error
2 parents ed098f5 + 425102e commit 24c9e94

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Sources/SKTestSupport/PluginPaths.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,23 +112,34 @@ 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+
// We can't declare a dependency from the test *target* on the SourceKit plugin *product*
118+
// (https://github.com/swiftlang/swift-package-manager/issues/8245).
119+
// We thus require a build before running the tests to ensure the plugin dylibs are in the build products
120+
// folder.
121+
"""
122+
Could not find SourceKit plugin. Ensure that you build the entire SourceKit-LSP package before running tests.
123+
124+
Searching for plugin relative to \(searchBase)
125+
"""
126+
}
117127
}
118128

119-
var base =
129+
let base =
120130
if let pluginPaths = ProcessInfo.processInfo.environment["SOURCEKIT_LSP_TEST_PLUGIN_PATHS"] {
121131
URL(fileURLWithPath: pluginPaths)
122132
} else {
123133
xctestBundle
124134
}
125-
while base.pathComponents.count > 1 {
126-
if let paths = pluginPaths(relativeTo: base) {
135+
var searchPath = base
136+
while searchPath.pathComponents.count > 1 {
137+
if let paths = pluginPaths(relativeTo: searchPath) {
127138
return paths
128139
}
129-
base = base.deletingLastPathComponent()
140+
searchPath = searchPath.deletingLastPathComponent()
130141
}
131142

132-
throw PluginLoadingError()
143+
throw PluginLoadingError(searchBase: base)
133144
}
134145
}

0 commit comments

Comments
 (0)