Skip to content

Commit 8e7968b

Browse files
committed
Restart sourcekitd and clangd after they have crashed
1 parent 78e102d commit 8e7968b

File tree

16 files changed

+638
-56
lines changed

16 files changed

+638
-56
lines changed

Documentation/Development.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ Location(ws.testLoc("aaa:call"))
175175
Position(ws.testLoc("aaa:call"))
176176
```
177177

178+
### Long tests
179+
180+
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.
181+
178182
## Tibs
179183

180184
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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*loc*/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"clang_flags": ["-fno-modules", "-Wunused-variable"],
3+
"sources": ["main.cpp"]
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*loc*/
2+
3+
#if FOO
4+
void foo() {}
5+
#else
6+
void foo() {}
7+
#endif
8+
9+
int main() {
10+
foo();
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"clang_flags": ["-fno-modules", "-Wunused-variable", "-DFOO"],
3+
"sources": ["main.cpp"]
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*loc*/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"sources": ["main.swift"]}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Foundation
14+
15+
public var longTestsEnabled: Bool {
16+
if let value = ProcessInfo.processInfo.environment["SOURCEKIT_LSP_ENABLE_LONG_TESTS"] {
17+
return value == "1" || value == "YES"
18+
}
19+
return false
20+
}

Sources/SKTestSupport/SKTibsTestWorkspace.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,5 @@ extension TibsToolchain {
236236

237237
extension TestLocation {
238238
public var docIdentifier: TextDocumentIdentifier { TextDocumentIdentifier(url) }
239+
public var docUri: DocumentURI { DocumentURI(url) }
239240
}

Sources/SourceKitD/sourcekitd_uids.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public struct sourcekitd_keys {
131131
}
132132

133133
public struct sourcekitd_requests {
134+
public let crash_exit: sourcekitd_uid_t
134135
public let editor_open: sourcekitd_uid_t
135136
public let editor_close: sourcekitd_uid_t
136137
public let editor_replacetext: sourcekitd_uid_t
@@ -143,6 +144,7 @@ public struct sourcekitd_requests {
143144
public let semantic_refactoring: sourcekitd_uid_t
144145

145146
public init(api: sourcekitd_functions_t) {
147+
crash_exit = api.uid_get_from_cstr("source.request.crash_exit")!
146148
editor_open = api.uid_get_from_cstr("source.request.editor.open")!
147149
editor_close = api.uid_get_from_cstr("source.request.editor.close")!
148150
editor_replacetext = api.uid_get_from_cstr("source.request.editor.replacetext")!
@@ -158,6 +160,7 @@ public struct sourcekitd_requests {
158160

159161
public struct sourcekitd_values {
160162
public let notification_documentupdate: sourcekitd_uid_t
163+
public let notification_sema_enabled: sourcekitd_uid_t
161164
public let diag_error: sourcekitd_uid_t
162165
public let diag_warning: sourcekitd_uid_t
163166
public let diag_note: sourcekitd_uid_t
@@ -250,6 +253,7 @@ public struct sourcekitd_values {
250253

251254
public init(api: sourcekitd_functions_t) {
252255
notification_documentupdate = api.uid_get_from_cstr("source.notification.editor.documentupdate")!
256+
notification_sema_enabled = api.uid_get_from_cstr("source.notification.sema_enabled")!
253257
diag_error = api.uid_get_from_cstr("source.diagnostic.severity.error")!
254258
diag_warning = api.uid_get_from_cstr("source.diagnostic.severity.warning")!
255259
diag_note = api.uid_get_from_cstr("source.diagnostic.severity.note")!

0 commit comments

Comments
 (0)