You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -134,81 +134,6 @@ Where "N" configures the log verbosity and is one of the following numbers: 0 (e
134
134
135
135
As much as is practical, all code should be covered by tests. New tests can be added under the `Tests` directory and should use `XCTest`. The rest of this section will describe the additional tools available in the `SKTestSupport` module to make it easier to write good and efficient tests.
136
136
137
-
### Test Projects (Fixtures)
138
-
139
-
SourceKit test projects should be put in the `SKTestSupport/INPUTS` directory. Generally, they should use the [Tibs](#tibs) build system to define their sources and targets. An exception is for tests that need to specifically test the interaction with the Swift Package Manager. An example Tibs test project might look like:
140
-
141
-
```
142
-
SKTestSupport/
143
-
INPUTS/
144
-
MyTestProj/
145
-
a.swift
146
-
b.swift
147
-
c.cpp
148
-
```
149
-
150
-
Where `project.json` describes the project's targets, for example
151
-
152
-
```
153
-
{ "sources": ["a.swift", "b.swift", "c.cpp"] }
154
-
```
155
-
156
-
Tibs supports more advanced project configurations, such as multiple swift modules with dependencies, etc. For much more information about Tibs, including what features it supports and how it works, see [Tibs](#tibs).
157
-
158
-
### SKTibsTestWorkspace
159
-
160
-
The `SKTibsTestWorkspace` pulls together the various pieces needed for working with tests, including opening a connection to the language server, building the project to produce index data, loading source code into open documents, etc.
161
-
162
-
To create a `SKTibsTestWorkspace`, use the `staticSourceKitTibsWorkspace` method (the intent is to provide a `mutableSourceKitTibsWorkspace` method in the future for tests that mutate source code).
163
-
164
-
```swift
165
-
functestFoo() {
166
-
// Create the workspace, including opening a connection to the TestServer.
It is common to want to refer to specific locations in the source code of a test project. This is supported using inline comment syntax.
184
-
185
-
```swift
186
-
Test.swift:
187
-
func/*myFuncDef*/myFunc() {
188
-
/*myFuncCall*/myFunc()
189
-
}
190
-
```
191
-
192
-
In a test, these locations can be referenced by name. The named location is immediately after the comment.
193
-
194
-
```swift
195
-
196
-
let loc = ws.testLoc("myFuncDef")
197
-
// TestLocation(url: ..., line: 1, column: 19)
198
-
```
199
-
200
-
`TestLocation`s can be easily converted to LSP `Location` and `Position`s.
201
-
202
-
```swift
203
-
Location(ws.testLoc("aaa:call"))
204
-
Position(ws.testLoc("aaa:call"))
205
-
```
206
-
207
137
### Long tests
208
138
209
139
Tests that run longer than approx. 1 second are only executed if the the `SOURCEKIT_LSP_ENABLE_LONG_TESTS` environment variable is set to `YES` or `1`. This, in particular, includes the crash recovery tests.
210
-
211
-
## Tibs
212
-
213
-
We use Tibs, the "Test Index Build System" from the IndexStoreDB project to provide build system support for test projects, including getting compiler arguments and building an index.
214
-
For much more information about Tibs, see [IndexStoreDB/Documentation/Tibs.md](https://github.com/apple/indexstore-db/blob/main/Documentation/Tibs.md).
0 commit comments