Skip to content

Restart sourcekitd and clangd after they have crashed #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Documentation/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ Location(ws.testLoc("aaa:call"))
Position(ws.testLoc("aaa:call"))
```

### Long tests

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.

## Tibs

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.
Expand Down
1 change: 1 addition & 0 deletions Sources/SKTestSupport/INPUTS/ClangCrashRecovery/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*loc*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"clang_flags": ["-fno-modules", "-Wunused-variable"],
"sources": ["main.cpp"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*loc*/

#if FOO
void foo() {}
#else
void foo() {}
#endif

int main() {
foo();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"clang_flags": ["-fno-modules", "-Wunused-variable", "-DFOO"],
"sources": ["main.cpp"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*loc*/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sources": ["main.swift"]}
20 changes: 20 additions & 0 deletions Sources/SKTestSupport/LongTestsEnabled.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

import Foundation

public var longTestsEnabled: Bool {
if let value = ProcessInfo.processInfo.environment["SOURCEKIT_LSP_ENABLE_LONG_TESTS"] {
return value == "1" || value == "YES"
}
return false
}
1 change: 1 addition & 0 deletions Sources/SKTestSupport/SKTibsTestWorkspace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,5 @@ extension TibsToolchain {

extension TestLocation {
public var docIdentifier: TextDocumentIdentifier { TextDocumentIdentifier(url) }
public var docUri: DocumentURI { DocumentURI(url) }
}
4 changes: 4 additions & 0 deletions Sources/SourceKitD/sourcekitd_uids.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public struct sourcekitd_keys {
}

public struct sourcekitd_requests {
public let crash_exit: sourcekitd_uid_t
public let editor_open: sourcekitd_uid_t
public let editor_close: sourcekitd_uid_t
public let editor_replacetext: sourcekitd_uid_t
Expand All @@ -143,6 +144,7 @@ public struct sourcekitd_requests {
public let semantic_refactoring: sourcekitd_uid_t

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

public struct sourcekitd_values {
public let notification_documentupdate: sourcekitd_uid_t
public let notification_sema_enabled: sourcekitd_uid_t
public let diag_error: sourcekitd_uid_t
public let diag_warning: sourcekitd_uid_t
public let diag_note: sourcekitd_uid_t
Expand Down Expand Up @@ -250,6 +253,7 @@ public struct sourcekitd_values {

public init(api: sourcekitd_functions_t) {
notification_documentupdate = api.uid_get_from_cstr("source.notification.editor.documentupdate")!
notification_sema_enabled = api.uid_get_from_cstr("source.notification.sema_enabled")!
diag_error = api.uid_get_from_cstr("source.diagnostic.severity.error")!
diag_warning = api.uid_get_from_cstr("source.diagnostic.severity.warning")!
diag_note = api.uid_get_from_cstr("source.diagnostic.severity.note")!
Expand Down
Loading