Skip to content

Commit 2deaf1d

Browse files
authored
Merge pull request #63590 from bnbarham/reenable-sk-test
[Test] Re-enable and cleanup some cursor info tests
2 parents 86b9700 + d206e1b commit 2deaf1d

7 files changed

+122
-145
lines changed
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
// RUN: %empty-directory(%t/split)
2-
// RUN: %{python} %utils/split_file.py -o %t/split %s
3-
// RUN: %empty-directory(%t/build)
4-
// RUN: %sourcekitd-test -req=cursor -pos=5:9 %t/split/MovieRow.swift -- %t/split/MovieRow.swift %t/split/Color.swift | %FileCheck %s
5-
6-
// BEGIN Color.swift
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file --leading-lines %s %t
73

4+
//--- Color.swift
85
extension Invalid {}
96

10-
// BEGIN MovieRow.swift
11-
7+
//--- MovieRow.swift
128
struct Bar {}
139

1410
fileprivate let bar: Bar = {
15-
let bar = Bar()
16-
return bar
11+
// RUN: %sourcekitd-test -req=cursor -pos=%(line+1):7 %t/MovieRow.swift -- %t/MovieRow.swift %t/Color.swift | %FileCheck %s
12+
let bar = Bar()
13+
// CHECK: source.lang.swift.decl.var.local ([[@LINE-1]]:7-[[@LINE-1]]:10)
14+
// CHECK-NEXT: bar
15+
// CHECK: RELATED BEGIN
16+
// CHECK-NEXT: <RelatedName usr="s:4main3bar33_F48676AE0C86F007C79C860E40EDA2D3LLAA3BarVvp">bar</RelatedName>
17+
// CHECK-NEXT: RELATED END
18+
return bar
1719
}()
18-
19-
20-
// CHECK: source.lang.swift.decl.var.local (5:9-5:12)
21-
// CHECK-NEXT: bar
22-
// CHECK: RELATED BEGIN
23-
// CHECK-NEXT: <RelatedName usr="s:4main3bar33_F48676AE0C86F007C79C860E40EDA2D3LLAA3BarVvp">bar</RelatedName>
24-
// CHECK-NEXT: RELATED END
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
// BEGIN MyModule.swift
2-
public actor MyActor {
3-
public func asyncFunc(fn: () async -> Void) async throws {}
4-
}
5-
6-
func test(act: MyActor) async throws {
7-
try await act.asyncFunc {}
8-
}
9-
10-
// BEGIN App.swift
11-
import MyModule
12-
13-
func test(act: MyActor) async throws {
14-
try await act.asyncFunc {}
15-
}
16-
171
// REQUIRES: concurrency
182

193
// RUN: %empty-directory(%t)
20-
// RUN: %{python} %utils/split_file.py -o %t %s
21-
224
// RUN: %empty-directory(%t/Modules)
5+
// RUN: split-file %s %t
6+
237
// RUN: %target-swift-frontend -emit-module -o %t/Modules/MyModule.swiftmodule -module-name MyModule %t/MyModule.swift -disable-availability-checking
248

259
// RUN: %sourcekitd-test -req=cursor -pos=1:15 %t/MyModule.swift -- %t/MyModule.swift -target %target-triple | %FileCheck -check-prefix=ACTOR %s
@@ -41,3 +25,19 @@ func test(act: MyActor) async throws {
4125

4226
// FUNC_XMOD: <Declaration>func asyncFunc(fn: () async -&gt; <Type usr="s:s4Voida">Void</Type>) async throws</Declaration>
4327
// FUNC_XMOD: <decl.function.method.instance><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>asyncFunc</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>fn</decl.var.parameter.argument_label>: <decl.var.parameter.type>() <syntaxtype.keyword>async</syntaxtype.keyword> -&gt; <decl.function.returntype><ref.typealias usr="s:s4Voida">Void</ref.typealias></decl.function.returntype></decl.var.parameter.type></decl.var.parameter>) <syntaxtype.keyword>async</syntaxtype.keyword> <syntaxtype.keyword>throws</syntaxtype.keyword></decl.function.method.instance>
28+
29+
//--- MyModule.swift
30+
public actor MyActor {
31+
public func asyncFunc(fn: () async -> Void) async throws {}
32+
}
33+
34+
func test(act: MyActor) async throws {
35+
try await act.asyncFunc {}
36+
}
37+
38+
//--- App.swift
39+
import MyModule
40+
41+
func test(act: MyActor) async throws {
42+
try await act.asyncFunc {}
43+
}

test/SourceKit/CursorInfo/cursor_swiftonly_systemmodule.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
// BEGIN SomeModule.swift
2-
3-
/// Doc comment for 'someFunc()'
4-
public func someFunc() {}
5-
6-
// BEGIN main.swift
7-
import SomeModule
8-
9-
func test() {
10-
someFunc()
11-
}
12-
131
// RUN: %empty-directory(%t)
14-
// RUN: %{python} %utils/split_file.py -o %t %s
2+
// RUN: split-file %s %t
153

164
// RUN: mkdir -p %t/SDK/Frameworks/SomeModule.framework/Modules/SomeModule.swiftmodule
175
// RUN: %target-swift-frontend \
@@ -38,3 +26,14 @@ func test() {
3826
// CHECK-NEXT: SYSTEM
3927
// CHECK-NEXT: <Declaration>func someFunc()</Declaration>
4028
// CHECK-NEXT: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>someFunc</decl.name>()</decl.function.free>
29+
30+
//--- SomeModule.swift
31+
/// Doc comment for 'someFunc()'
32+
public func someFunc() {}
33+
34+
//--- main.swift
35+
import SomeModule
36+
37+
func test() {
38+
someFunc()
39+
}

test/SourceKit/CursorInfo/cursor_uses_swiftsourceinfo.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
// RUN: %empty-directory(%t/split)
2-
// RUN: %{python} %utils/split_file.py -o %t/split %s
1+
// RUN: %empty-directory(%t)
32
// RUN: %empty-directory(%t/build)
4-
// RUN: %target-swift-frontend -emit-module -module-name MyModule -emit-module-path %t/build/MyModule.swiftmodule -emit-module-source-info-path %t/build/MyModule.swiftsourceinfo %t/split/Action.swift
5-
// RUN: %sourcekitd-test -req=cursor -req-opts=retrieve_symbol_graph=1 -pos=5:14 %t/split/test.swift -- %t/split/test.swift -I %t/build -target %target-triple | %FileCheck %s
3+
// RUN: split-file %s %t
4+
5+
// RUN: %target-swift-frontend -emit-module -module-name MyModule -emit-module-path %t/build/MyModule.swiftmodule -emit-module-source-info-path %t/build/MyModule.swiftsourceinfo %t/Action.swift
6+
// RUN: %sourcekitd-test -req=cursor -req-opts=retrieve_symbol_graph=1 -pos=5:14 %t/test.swift -- %t/test.swift -I %t/build -target %target-triple | %FileCheck %s
67

78
// We should also get source doc info if we execute a code completion request (which doesn't need source doc info) first
89
// RUN: %sourcekitd-test \
9-
// RUN: -req=complete %t/split/test.swift -pos=5:14 -- %t/split/test.swift -I %t/build -target %target-triple == \
10-
// RUN: -req=cursor -req-opts=retrieve_symbol_graph=1 -pos=5:14 %t/split/test.swift -- %t/split/test.swift -I %t/build -target %target-triple
10+
// RUN: -req=complete %t/test.swift -pos=5:14 -- %t/test.swift -I %t/build -target %target-triple == \
11+
// RUN: -req=cursor -req-opts=retrieve_symbol_graph=1 -pos=5:14 %t/test.swift -- %t/test.swift -I %t/build -target %target-triple
12+
13+
// CHECK: REFERENCED DECLS BEGIN
14+
// CHECK-NEXT: s:8MyModule6ActionP | public | {{.*}}Action.swift | MyModule | User | NonSPI | source.lang.swift
15+
// CHECK-NEXT: Action swift.protocol s:8MyModule6ActionP
16+
// CHECK-NEXT: REFERENCED DECLS END
1117

12-
// BEGIN Action.swift
18+
//--- Action.swift
1319
public protocol Action {}
1420

15-
// BEGIN test.swift
21+
//--- test.swift
1622
import MyModule
1723

1824
func test(action: Action) {
1925
switch action {
2026
case let action
2127

22-
// CHECK: REFERENCED DECLS BEGIN
23-
// CHECK-NEXT: s:8MyModule6ActionP | public | {{.*}}/split/Action.swift | MyModule | User | NonSPI | source.lang.swift
24-
// CHECK-NEXT: Action swift.protocol s:8MyModule6ActionP
25-
// CHECK-NEXT: REFERENCED DECLS END
Lines changed: 46 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,80 @@
1-
// BEGIN State1.swift
2-
3-
func foo() {
4-
let inFunctionA = 1
5-
let inFunctionB = "hi"
6-
}
7-
8-
// BEGIN State2.swift
9-
10-
func foo() {
11-
let newlyAddedMember = 3
12-
let inFunctionA = 1
13-
let inFunctionB = "hi"
14-
}
15-
16-
// BEGIN State3.swift
17-
18-
func foo() {
19-
let inFunctionB = "hi"
20-
}
21-
22-
// BEGIN State4.swift
23-
24-
func foo() {
25-
let myNewName = "hi"
26-
}
27-
28-
// BEGIN State5.swift
29-
30-
func foo(param: Int) {
31-
let myNewName = "hi"
32-
}
33-
34-
// BEGIN State6.swift
35-
36-
func foo(param: Int) {
37-
let myNewName = 7
38-
}
39-
40-
41-
// BEGIN Dummy.swift
42-
431
// RUN: %empty-directory(%t)
44-
// RUN: %{python} %utils/split_file.py -o %t %s
45-
46-
// RUN: cp %t/State1.swift %t/file.swift
2+
// RUN: split-file %s %t
473

484
// RUN: %sourcekitd-test \
495
// RUN: -shell -- echo '## State 1' == \
50-
// RUN: -req=cursor -pos=4:7 %t/file.swift -- %t/file.swift == \
6+
// RUN: -req=cursor -pos=3:7 %t/file.swift -- %t/file.swift == \
517
// RUN: -shell -- echo '## State 2' == \
528
// RUN: -shell -- cp %t/State2.swift %t/file.swift == \
53-
// RUN: -req=cursor -pos=5:7 %t/file.swift -- %t/file.swift == \
9+
// RUN: -req=cursor -pos=4:7 %t/file.swift -- %t/file.swift == \
5410
// RUN: -shell -- echo '## State 3' == \
5511
// RUN: -shell -- cp %t/State3.swift %t/file.swift == \
56-
// RUN: -req=cursor -pos=3:7 %t/file.swift -- %t/file.swift == \
12+
// RUN: -req=cursor -pos=2:7 %t/file.swift -- %t/file.swift == \
5713
// RUN: -shell -- echo '## State 4' == \
5814
// RUN: -shell -- cp %t/State4.swift %t/file.swift == \
59-
// RUN: -req=cursor -pos=3:7 %t/file.swift -- %t/file.swift == \
15+
// RUN: -req=cursor -pos=2:7 %t/file.swift -- %t/file.swift == \
6016
// RUN: -shell -- echo '## State 5' == \
6117
// RUN: -shell -- cp %t/State5.swift %t/file.swift == \
62-
// RUN: -req=cursor -pos=3:7 %t/file.swift -- %t/file.swift == \
18+
// RUN: -req=cursor -pos=2:7 %t/file.swift -- %t/file.swift == \
6319
// RUN: -shell -- echo '## State 6' == \
6420
// RUN: -shell -- cp %t/State6.swift %t/file.swift == \
65-
// RUN: -req=cursor -pos=3:7 %t/file.swift -- %t/file.swift > %t/response.txt
21+
// RUN: -req=cursor -pos=2:7 %t/file.swift -- %t/file.swift > %t/response.txt
6622
// RUN: %FileCheck %s < %t/response.txt
6723

6824
// CHECK-LABEL: ## State 1
69-
// CHECK: source.lang.swift.decl.var.local (4:7-4:18)
25+
// CHECK: source.lang.swift.decl.var.local (3:7-3:18)
7026
// CHECK: <Declaration>let inFunctionB: <Type usr="s:SS">String</Type></Declaration>
7127
// CHECK: DID REUSE AST CONTEXT: 0
7228
// CHECK-LABEL: ## State 2
73-
// CHECK: source.lang.swift.decl.var.local (5:7-5:18)
29+
// CHECK: source.lang.swift.decl.var.local (4:7-4:18)
7430
// CHECK: <Declaration>let inFunctionB: <Type usr="s:SS">String</Type></Declaration>
7531
// CHECK: DID REUSE AST CONTEXT: 1
7632
// CHECK-LABEL: ## State 3
77-
// CHECK: source.lang.swift.decl.var.local (3:7-3:18)
33+
// CHECK: source.lang.swift.decl.var.local (2:7-2:18)
7834
// CHECK: <Declaration>let inFunctionB: <Type usr="s:SS">String</Type></Declaration>
7935
// CHECK: DID REUSE AST CONTEXT: 1
8036
// CHECK-LABEL: ## State 4
81-
// CHECK: source.lang.swift.decl.var.local (3:7-3:16)
37+
// CHECK: source.lang.swift.decl.var.local (2:7-2:16)
8238
// CHECK: <Declaration>let myNewName: <Type usr="s:SS">String</Type></Declaration>
8339
// CHECK: DID REUSE AST CONTEXT: 1
8440
// CHECK-LABEL: ## State 5
85-
// CHECK: source.lang.swift.decl.var.local (3:7-3:16)
41+
// CHECK: source.lang.swift.decl.var.local (2:7-2:16)
8642
// CHECK: <Declaration>let myNewName: <Type usr="s:SS">String</Type></Declaration>
8743
// CHECK: DID REUSE AST CONTEXT: 0
8844
// CHECK-LABEL: ## State 6
89-
// CHECK: source.lang.swift.decl.var.local (3:7-3:16)
45+
// CHECK: source.lang.swift.decl.var.local (2:7-2:16)
9046
// CHECK: <Declaration>let myNewName: <Type usr="s:Si">Int</Type></Declaration>
9147
// CHECK: DID REUSE AST CONTEXT: 1
48+
49+
//--- file.swift
50+
func foo() {
51+
let inFunctionA = 1
52+
let inFunctionB = "hi"
53+
}
54+
55+
//--- State2.swift
56+
func foo() {
57+
let newlyAddedMember = 3
58+
let inFunctionA = 1
59+
let inFunctionB = "hi"
60+
}
61+
62+
//--- State3.swift
63+
func foo() {
64+
let inFunctionB = "hi"
65+
}
66+
67+
//--- State4.swift
68+
func foo() {
69+
let myNewName = "hi"
70+
}
71+
72+
//--- State5.swift
73+
func foo(param: Int) {
74+
let myNewName = "hi"
75+
}
76+
77+
//--- State6.swift
78+
func foo(param: Int) {
79+
let myNewName = 7
80+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %{python} %utils/split_file.py -o %t %s
2+
// RUN: split-file %s %t
3+
34
// RUN: %sourcekitd-test -req=cursor -pos=8:37 %t/first.swift -- %t/first.swift %t/second.swift | %FileCheck %s
45

56
// CHECK: source.lang.swift.ref.var.instance (6:9-6:12)
67

7-
8-
// BEGIN first.swift
8+
//--- first.swift
99
protocol ChatDataSourceDelegateProtocol {
1010
func chatDataSourceDidUpdate()
1111
}
@@ -17,7 +17,7 @@ class BaseChatViewController {
1717
}
1818
}
1919

20-
// BEGIN second.swift
20+
//--- second.swift
2121
extension BaseChatViewController: ChatDataSourceDelegateProtocol {
2222
func chatDataSourceDidUpdate() { fatalError() }
2323
}
Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
1-
// REQUIRES: rdar105287822
2-
31
// RUN: %empty-directory(%t)
42
// RUN: %empty-directory(%t/Modules)
5-
// RUN: %{python} %utils/split_file.py -o %t %s
6-
7-
8-
// BEGIN MyModule.swift
9-
10-
public class UserCollection {
11-
public static let sharedStatic = UserCollection()
12-
public class var sharedComputedClass: UserCollection { UserCollection() }
13-
}
3+
// RUN: split-file --leading-lines %s %t
144

155
// RUN: %target-swift-frontend \
166
// RUN: -emit-module \
177
// RUN: -module-name MyModule \
188
// RUN: -emit-module-path %t/Modules/MyModule.swiftmodule \
19-
// RUN: -emit-module-doc-path %t/Modules/MyModule.swiftdoc \
209
// RUN: %t/MyModule.swift
2110

22-
// BEGIN test.swift
11+
//--- MyModule.swift
12+
public class UserCollection {
13+
public static let sharedStatic = UserCollection()
14+
public class var sharedComputedClass: UserCollection { UserCollection() }
15+
}
16+
17+
//--- test.swift
2318
import MyModule
2419

2520
func application() {
21+
// RUN: %sourcekitd-test -req=cursor -pos=%(line+1):18 %t/test.swift -- %t/test.swift -I %t/Modules -target %target-triple | %FileCheck %s --check-prefix=SHARED_STATIC
2622
UserCollection.sharedStatic
23+
// FIXME: This should be reported as 'static var' rdar://105239467
24+
// SHARED_STATIC: <Declaration>class let sharedStatic: <Type usr="s:8MyModule14UserCollectionC">UserCollection</Type></Declaration>
25+
// SHARED_STATIC: <decl.var.class><syntaxtype.keyword>class</syntaxtype.keyword> <syntaxtype.keyword>let</syntaxtype.keyword> <decl.name>sharedStatic</decl.name>: <decl.var.type><ref.class usr="s:8MyModule14UserCollectionC">UserCollection</ref.class></decl.var.type></decl.var.class>
26+
27+
// RUN: %sourcekitd-test -req=cursor -pos=%(line+1):18 %t/test.swift -- %t/test.swift -I %t/Modules -target %target-triple | %FileCheck %s --check-prefix=SHARED_COMPUTED_CLASS
2728
UserCollection.sharedComputedClass
29+
// SHARED_COMPUTED_CLASS: <Declaration>class var sharedComputedClass: <Type usr="s:8MyModule14UserCollectionC">UserCollection</Type> { get }</Declaration>
30+
// SHARED_COMPUTED_CLASS: <decl.var.class><syntaxtype.keyword>class</syntaxtype.keyword> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>sharedComputedClass</decl.name>: <decl.var.type><ref.class usr="s:8MyModule14UserCollectionC">UserCollection</ref.class></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.class>
2831
}
29-
30-
// RUN: %sourcekitd-test -req=cursor -pos=4:18 %t/test.swift -- %t/test.swift -I %t/Modules | %FileCheck %s --check-prefix=SHARED_STATIC
31-
32-
// FIXME: This should be reported as 'static var' rdar://105239467
33-
// SHARED_STATIC: <Declaration>class let sharedStatic: <Type usr="s:8MyModule14UserCollectionC">UserCollection</Type></Declaration>
34-
// SHARED_STATIC: <decl.var.class><syntaxtype.keyword>class</syntaxtype.keyword> <syntaxtype.keyword>let</syntaxtype.keyword> <decl.name>sharedStatic</decl.name>: <decl.var.type><ref.class usr="s:8MyModule14UserCollectionC">UserCollection</ref.class></decl.var.type></decl.var.class>
35-
36-
// RUN: %sourcekitd-test -req=cursor -pos=5:18 %t/test.swift -- %t/test.swift -I %t/Modules| %FileCheck %s --check-prefix=SHARED_COMPUTED_CLASS
37-
38-
// SHARED_COMPUTED_CLASS: <Declaration>class var sharedComputedClass: <Type usr="s:8MyModule14UserCollectionC">UserCollection</Type> { get }</Declaration>
39-
// SHARED_COMPUTED_CLASS: <decl.var.class><syntaxtype.keyword>class</syntaxtype.keyword> <syntaxtype.keyword>var</syntaxtype.keyword> <decl.name>sharedComputedClass</decl.name>: <decl.var.type><ref.class usr="s:8MyModule14UserCollectionC">UserCollection</ref.class></decl.var.type> { <syntaxtype.keyword>get</syntaxtype.keyword> }</decl.var.class>

0 commit comments

Comments
 (0)