Skip to content

Commit 6b0786e

Browse files
authored
Merge pull request #1069 from ahoppen/ahoppen/diagnose-tests-with-xcode-toolchain
Add `-sdk` to request yaml in diagnose tests
2 parents 28d00a9 + 40eb731 commit 6b0786e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

Tests/DiagnoseTests/DiagnoseTests.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,22 @@ import SKTestSupport
1919
import SourceKitD
2020
import XCTest
2121

22+
import class ISDBTibs.TibsBuilder
2223
import struct TSCBasic.AbsolutePath
2324

2425
final class DiagnoseTests: XCTestCase {
26+
/// If a default SDK is present on the test machine, return the `-sdk` argument that can be placed in the request
27+
/// YAML. Otherwise, return an empty string.
28+
private var sdkArg: String {
29+
if let sdk = TibsBuilder.defaultSDKPath {
30+
return """
31+
"-sdk", "\(sdk)",
32+
"""
33+
} else {
34+
return ""
35+
}
36+
}
37+
2538
func testRemoveCodeItemsAndMembers() async throws {
2639
// We consider the test case reproducing if cursor info returns the two ambiguous results including their doc
2740
// comments.
@@ -55,7 +68,8 @@ final class DiagnoseTests: XCTestCase {
5568
{
5669
key.request: source.request.cursorinfo,
5770
key.compilerargs: [
58-
"$FILE"
71+
"$FILE",
72+
\(sdkArg)
5973
],
6074
key.offset: $OFFSET,
6175
key.sourcefile: "$FILE"
@@ -102,7 +116,8 @@ final class DiagnoseTests: XCTestCase {
102116
{
103117
key.request: source.request.cursorinfo,
104118
key.compilerargs: [
105-
"$FILE"
119+
"$FILE",
120+
\(sdkArg)
106121
],
107122
key.offset: $OFFSET,
108123
key.sourcefile: "$FILE"

0 commit comments

Comments
 (0)