Skip to content

Commit b8722fd

Browse files
authored
Merge pull request #25089 from DavidGoldman/master
[SourceKit] Fail requests when an error occurs
2 parents f271158 + 6f68ab2 commit b8722fd

File tree

26 files changed

+486
-286
lines changed

26 files changed

+486
-286
lines changed

test/SourceKit/CompileNotifications/arg-parsing.swift

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1-
// RUN: not %sourcekitd-test -req=track-compiles == -req=complete %s -offset=0 -- %s -no-such-arg | %FileCheck %s -check-prefix=ARG_PARSE_1
1+
// RUN: not %sourcekitd-test -req=track-compiles == -req=complete %s -offset=0 -- %s -no-such-arg 2>&1 | %FileCheck %s -check-prefix=ARG_PARSE_0
2+
// ARG_PARSE_0: (Request Failed): error: unknown argument: '-no-such-arg'
3+
// ARG_PARSE_0: {
4+
// ARG_PARSE_0: key.notification: source.notification.compile-will-start
5+
// ARG_PARSE_0: key.compileid: [[CID1:".*"]]
6+
// ARG_PARSE_0: key.compilerargs-string: "{{.*}}.swift -no-such-arg"
7+
// ARG_PARSE_0: }
8+
// ARG_PARSE_0: {
9+
// ARG_PARSE_0: key.notification: source.notification.compile-did-finish
10+
// ARG_PARSE_0: key.diagnostics: [
11+
// ARG_PARSE_0: {
12+
// ARG_PARSE_0: key.filepath: "<unknown>",
13+
// ARG_PARSE_0: key.severity: source.diagnostic.severity.error,
14+
// ARG_PARSE_0: key.description: "unknown argument: '-no-such-arg'"
15+
// ARG_PARSE_0: }
16+
// ARG_PARSE_0: ]
17+
// ARG_PARSE_0: key.compileid: [[CID1]]
18+
// ARG_PARSE_0: }
19+
// ARG_PARSE_0-NOT: compile-will-start
20+
// ARG_PARSE_0-NOT: compile-did-finish
21+
222
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -print-raw-response -- %s -no-such-arg | %FileCheck %s -check-prefix=ARG_PARSE_1
3-
// RUN: %sourcekitd-test -req=track-compiles == -req=cursor -offset=0 %s -- %s -no-such-arg | %FileCheck %s -check-prefix=ARG_PARSE_1
23+
// RUN: not %sourcekitd-test -req=track-compiles == -req=cursor -offset=0 %s -- %s -no-such-arg | %FileCheck %s -check-prefix=ARG_PARSE_1
424
// ARG_PARSE_1: {
525
// ARG_PARSE_1: key.notification: source.notification.compile-will-start
626
// ARG_PARSE_1: key.compileid: [[CID1:".*"]]
@@ -20,8 +40,8 @@
2040
// ARG_PARSE_1-NOT: compile-will-start
2141
// ARG_PARSE_1-NOT: compile-did-finish
2242

23-
// RUN: not %sourcekitd-test -req=track-compiles == -req=complete %s -offset=0 | %FileCheck %s -check-prefix=ARG_PARSE_2
24-
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -print-raw-response | %FileCheck %s -check-prefix=ARG_PARSE_2
43+
// %sourcekitd-test -req=track-compiles == -req=complete %s -offset=0 | %FileCheck %s -check-prefix=ARG_PARSE_2
44+
// %sourcekitd-test -req=track-compiles == -req=sema %s -print-raw-response | %FileCheck %s -check-prefix=ARG_PARSE_2
2545
// ARG_PARSE_2: {
2646
// ARG_PARSE_2: key.notification: source.notification.compile-will-start
2747
// ARG_PARSE_2: key.compileid: [[CID1:".*"]]

test/SourceKit/CompileNotifications/cursor-info.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
// COMPILE_1: key.notification: source.notification.compile-did-finish,
99
// COMPILE_1: key.compileid: [[CID1]]
1010
// COMPILE_1: }
11+
// COMPILE_1: <empty cursor info; internal diagnostic: "Unable to resolve cursor info.">
1112
// COMPILE_1-NOT: compile-will-start
12-
// COMPILE_1-NOT: compile-did-finish
13+
// COMPILE_1-NOT: compile-did-finish

test/SourceKit/CursorInfo/cursor_getter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ struct S1 {
2121
// RUN: %sourcekitd-test -req=cursor -pos=3:41 %s -- %s | %FileCheck %s
2222
// RUN: %sourcekitd-test -req=cursor -pos=6:29 %s -- %s | %FileCheck %s
2323
// RUN: %sourcekitd-test -req=cursor -pos=6:31 %s -- %s | %FileCheck %s
24-
// CHECK: <empty cursor info>
24+
// CHECK: <empty cursor info; internal diagnostic: "Unable to resolve cursor info.">

test/SourceKit/CursorInfo/cursor_info.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,20 +379,17 @@ enum E7: String {
379379
// CHECK22: <decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityIntroduced</decl.name>()</decl.function.method.instance>
380380

381381
// RUN: %sourcekitd-test -req=cursor -pos=56:15 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK23 %s
382-
// CHECK23-NOT: <Declaration>func swiftUnavailable()</Declaration>
383-
// CHECK23-NOT: <decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>swiftUnavailable</decl.name>()</decl.function.method.instance>
382+
// CHECK23: <empty cursor info; internal diagnostic: "Unavailable in the current compilation context.">
384383

385384
// RUN: %sourcekitd-test -req=cursor -pos=57:15 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK24 %s
386-
// CHECK24-NOT: <Declaration>func unavailable()</Declaration>
387-
// CHECK24-NOT: <decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>unavailable</decl.name>()</decl.function.method.instance>
385+
// CHECK24: <empty cursor info; internal diagnostic: "Unavailable in the current compilation context.">
388386

389387
// RUN: %sourcekitd-test -req=cursor -pos=58:15 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK25 %s
390388
// CHECK25: <Declaration>func availabilityIntroducedMsg()</Declaration>
391389
// CHECK25: <decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityIntroducedMsg</decl.name>()</decl.function.method.instance>
392390

393391
// RUN: %sourcekitd-test -req=cursor -pos=59:15 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK26 %s
394-
// CHECK26-NOT: <Declaration>func availabilityDeprecated()</Declaration>
395-
// CHECK26-NOT: <decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>availabilityDeprecated</decl.name>()</decl.function.method.instance>
392+
// CHECK26: <empty cursor info; internal diagnostic: "Unavailable in the current compilation context.">
396393

397394
// RUN: %sourcekitd-test -req=cursor -pos=69:14 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK27 %s
398395
// CHECK27: <Declaration>public subscript(i: <Type usr="s:Si">Int</Type>) -&gt; <Type usr="s:Si">Int</Type> { get }</Declaration>

test/SourceKit/CursorInfo/cursor_invalid.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ func resyncParser2() {}
4444
// CHECK4: bad
4545
// CHECK4: <Declaration>var bad: IDontExist</Declaration>
4646

47-
// RUN: %sourcekitd-test -req=cursor -pos=7:12 %s -- %s | %FileCheck -check-prefix=EMPTY %s
48-
// RUN: %sourcekitd-test -req=cursor -pos=9:7 %s -- %s | %FileCheck -check-prefix=EMPTY %s
49-
// EMPTY: <empty cursor info>
47+
// RUN: %sourcekitd-test -req=cursor -pos=7:12 %s -- %s | %FileCheck -check-prefix=DIAG %s
48+
// RUN: %sourcekitd-test -req=cursor -pos=9:7 %s -- %s | %FileCheck -check-prefix=DIAG %s
49+
// DIAG: <empty cursor info; internal diagnostic: "Unable to resolve cursor info.">
5050

5151
// RUN: %sourcekitd-test -req=cursor -pos=18:6 %s -- %s | %FileCheck -check-prefix=EQEQ1 %s
5252
// RUN: %sourcekitd-test -req=cursor -pos=19:6 %s -- %s | %FileCheck -check-prefix=EQEQ1 %s

test/SourceKit/CursorInfo/cursor_unavailable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ find([1,2,3],1)
55
// RUN: %sourcekitd-test -req=cursor -pos=2:1 %s -- %s | %FileCheck -check-prefix=CHECK2 %s
66

77
// CHECK1: source.lang.swift.ref.function.free
8-
// CHECK2-NOT: source.lang.swift.ref.function.free
8+
// CHECK2: <empty cursor info; internal diagnostic: "Resolved to incomplete expression or statement.">

test/SourceKit/CursorInfo/cursor_usr.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,15 @@ func foo(x: FooStruct1) -> S1 {}
2525
// CHECK_SANITY1-NEXT: <decl.struct><syntaxtype.keyword>struct</syntaxtype.keyword> <decl.name>S1</decl.name></decl.struct>
2626

2727
// Bogus USR.
28-
// RUN: %sourcekitd-test -req=cursor -usr "s:blahblahblah" %s -- -I %t -F %S/../Inputs/libIDE-mock-sdk %mcp_opt %s | %FileCheck %s -check-prefix=EMPTY
28+
// RUN: %sourcekitd-test -req=cursor -usr "s:blahblahblah" %s -- -I %t -F %S/../Inputs/libIDE-mock-sdk %mcp_opt %s | %FileCheck %s -check-prefix=RESOLVE
2929
// Missing s: prefix.
30-
// RUN: %sourcekitd-test -req=cursor -usr "10cursor_usr6globalSivp" %s -- -I %t -F %S/../Inputs/libIDE-mock-sdk %mcp_opt %s | %FileCheck %s -check-prefix=EMPTY
30+
// RUN: %sourcekitd-test -req=cursor -usr "10cursor_usr6globalSivp" %s -- -I %t -F %S/../Inputs/libIDE-mock-sdk %mcp_opt %s | %FileCheck %s -check-prefix=RESOLVE
31+
// RESOLVE: <empty cursor info; internal diagnostic: "Unable to resolve type from USR.">
32+
3133
// FIXME: no support for clang USRs.
32-
// RUN: %sourcekitd-test -req=cursor -usr "c:@S@FooStruct1" %s -- -I %t -F %S/../Inputs/libIDE-mock-sdk %mcp_opt %s | %FileCheck %s -check-prefix=EMPTY
33-
// EMPTY: <empty cursor info>
34+
// RUN: %sourcekitd-test -req=cursor -usr "c:@S@FooStruct1" %s -- -I %t -F %S/../Inputs/libIDE-mock-sdk %mcp_opt %s | %FileCheck %s -check-prefix=CSUPPORT
35+
// CSUPPORT: <empty cursor info; internal diagnostic: "Lookup for C/C++/ObjC USRs not implemented.">
36+
3437
// RUN: %sourcekitd-test -req=cursor -usr "s:10cursor_usr2S1V" %s -- -I %t -F %S/../Inputs/libIDE-mock-sdk %mcp_opt %s | %FileCheck %s -check-prefix=CHECK1
3538
// CHECK1: source.lang.swift.decl.struct (5:8-5:10)
3639
// CHECK1: s1

test/SourceKit/CursorInfo/ignore-llvm-args.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ _ = ""
33
// rdar://problem/38314383
44
// RUN: %sourcekitd-test -req=cursor -offset=0 %s -- -Xllvm -aarch64-use-tbi %s | %FileCheck %s
55

6-
// CHECK: <empty cursor info>
6+
// CHECK: <empty cursor info; internal diagnostic: "Resolved to incomplete expression or statement.">

test/SourceKit/CursorInfo/invalid_offset.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ let a = 12
33
// rdar://problem/30346106
44
// Invalid offset should trigger a crash.
55

6-
// RUN: %sourcekitd-test \
6+
// RUN: not %sourcekitd-test 2>&1 \
77
// RUN: -req=open %s -- %s == \
88
// RUN: -req=edit -async -offset=0 -length=200 -replace='' %s -- %s == \
99
// RUN: -req=cursor -offset=250 %s -- %s \
@@ -12,4 +12,4 @@ let a = 12
1212
// rdar://problem/38162017
1313
// REQUIRES: OS=macosx
1414

15-
// CHECK: <empty cursor info>
15+
// CHECK: (Request Failed): Unable to resolve the start of the token

test/SourceKit/CursorInfo/rdar_18677108-1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Checks that we don't crash.
22
// RUN: %sourcekitd-test -req=cursor -pos=7:5 %s -- %s | %FileCheck %s
3-
// CHECK: <empty cursor info>
3+
// CHECK: <empty cursor info; internal diagnostic: "Unable to resolve cursor info.">
44

55
class CameraViewController
66
{

0 commit comments

Comments
 (0)