Skip to content

Commit d9b2d65

Browse files
authored
Merge pull request #353 from ahoppen/crash-recovery-again
Restart sourcekitd and clangd after they have crashed
2 parents f9b9f4c + a0c9b30 commit d9b2d65

File tree

16 files changed

+706
-114
lines changed

16 files changed

+706
-114
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
@@ -238,4 +238,5 @@ extension TibsToolchain {
238238

239239
extension TestLocation {
240240
public var docIdentifier: TextDocumentIdentifier { TextDocumentIdentifier(url) }
241+
public var docUri: DocumentURI { DocumentURI(url) }
241242
}

Sources/SourceKitD/sourcekitd_uids.swift

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

135135
public struct sourcekitd_requests {
136+
public let crash_exit: sourcekitd_uid_t
136137
public let editor_open: sourcekitd_uid_t
137138
public let editor_close: sourcekitd_uid_t
138139
public let editor_replacetext: sourcekitd_uid_t
@@ -145,6 +146,7 @@ public struct sourcekitd_requests {
145146
public let semantic_refactoring: sourcekitd_uid_t
146147

147148
public init(api: sourcekitd_functions_t) {
149+
crash_exit = api.uid_get_from_cstr("source.request.crash_exit")!
148150
editor_open = api.uid_get_from_cstr("source.request.editor.open")!
149151
editor_close = api.uid_get_from_cstr("source.request.editor.close")!
150152
editor_replacetext = api.uid_get_from_cstr("source.request.editor.replacetext")!
@@ -160,6 +162,7 @@ public struct sourcekitd_requests {
160162

161163
public struct sourcekitd_values {
162164
public let notification_documentupdate: sourcekitd_uid_t
165+
public let notification_sema_enabled: sourcekitd_uid_t
163166
public let diag_error: sourcekitd_uid_t
164167
public let diag_warning: sourcekitd_uid_t
165168
public let diag_note: sourcekitd_uid_t
@@ -252,6 +255,7 @@ public struct sourcekitd_values {
252255

253256
public init(api: sourcekitd_functions_t) {
254257
notification_documentupdate = api.uid_get_from_cstr("source.notification.editor.documentupdate")!
258+
notification_sema_enabled = api.uid_get_from_cstr("source.notification.sema_enabled")!
255259
diag_error = api.uid_get_from_cstr("source.diagnostic.severity.error")!
256260
diag_warning = api.uid_get_from_cstr("source.diagnostic.severity.warning")!
257261
diag_note = api.uid_get_from_cstr("source.diagnostic.severity.note")!

0 commit comments

Comments
 (0)