@@ -31,14 +31,19 @@ suite("TestDiscovery Suite", () => {
31
31
interface SimplifiedTestItem {
32
32
id : string ;
33
33
children : SimplifiedTestItem [ ] ;
34
+ tags : readonly { id : string } [ ] ;
34
35
}
35
36
36
37
function testControllerChildren ( collection : vscode . TestItemCollection ) : SimplifiedTestItem [ ] {
37
38
return reduceTestItemChildren (
38
39
collection ,
39
40
( acc , item ) => [
40
41
...acc ,
41
- { id : item . id , children : testControllerChildren ( item . children ) } ,
42
+ {
43
+ id : item . id ,
44
+ tags : [ ...item . tags . map ( tag => ( { id : tag . id } ) ) ] ,
45
+ children : testControllerChildren ( item . children ) ,
46
+ } ,
42
47
] ,
43
48
[ ] as SimplifiedTestItem [ ]
44
49
) ;
@@ -77,7 +82,7 @@ suite("TestDiscovery Suite", () => {
77
82
updateTests ( testController , [ testItem ( "bar" ) ] ) ;
78
83
79
84
assert . deepStrictEqual ( testControllerChildren ( testController . items ) , [
80
- { id : "bar" , children : [ ] } ,
85
+ { id : "bar" , tags : [ { id : "XCTest" } , { id : "runnable" } ] , children : [ ] } ,
81
86
] ) ;
82
87
} ) ;
83
88
@@ -109,9 +114,10 @@ suite("TestDiscovery Suite", () => {
109
114
assert . deepStrictEqual ( testControllerChildren ( testController . items ) , [
110
115
{
111
116
id : "foo" ,
117
+ tags : [ { id : "XCTest" } , { id : "runnable" } ] ,
112
118
children : [
113
- { id : "baz" , children : [ ] } ,
114
- { id : "bar" , children : [ ] } ,
119
+ { id : "baz" , tags : [ { id : "XCTest" } , { id : "runnable" } ] , children : [ ] } ,
120
+ { id : "bar" , tags : [ { id : "XCTest" } , { id : "runnable" } ] , children : [ ] } ,
115
121
] ,
116
122
} ,
117
123
] ) ;
@@ -140,7 +146,13 @@ suite("TestDiscovery Suite", () => {
140
146
updateTests ( testController , [ newFoo ] ) ;
141
147
142
148
assert . deepStrictEqual ( testControllerChildren ( testController . items ) , [
143
- { id : "foo" , children : [ { id : "bar" , children : [ ] } ] } ,
149
+ {
150
+ id : "foo" ,
151
+ tags : [ { id : "XCTest" } , { id : "runnable" } ] ,
152
+ children : [
153
+ { id : "bar" , tags : [ { id : "XCTest" } , { id : "runnable" } ] , children : [ ] } ,
154
+ ] ,
155
+ } ,
144
156
] ) ;
145
157
assert . deepStrictEqual ( testController . items . get ( "foo" ) ?. uri , newLocation . uri ) ;
146
158
assert . deepStrictEqual ( testController . items . get ( "foo" ) ?. label , "New Label" ) ;
@@ -168,7 +180,57 @@ suite("TestDiscovery Suite", () => {
168
180
updateTestsFromClasses ( testController , swiftPackage , [ item ] ) ;
169
181
170
182
assert . deepStrictEqual ( testControllerChildren ( testController . items ) , [
171
- { id : "TestTarget" , children : [ { id : "bar" , children : [ ] } ] } ,
183
+ {
184
+ id : "TestTarget" ,
185
+ tags : [ { id : "test-target" } , { id : "runnable" } ] ,
186
+ children : [
187
+ { id : "bar" , tags : [ { id : "XCTest" } , { id : "runnable" } ] , children : [ ] } ,
188
+ ] ,
189
+ } ,
190
+ ] ) ;
191
+ } ) ;
192
+
193
+ test ( "Children in suites with tags inherit the suite's tags" , async ( ) => {
194
+ const testSuite = testItem ( "suite" ) ;
195
+ testSuite . tags = [ { id : "rootTag" } ] ;
196
+ const childSuite = testItem ( "childSuite" ) ;
197
+ childSuite . tags = [ { id : "childSuiteTag" } ] ;
198
+ const childTest = testItem ( "childTest" ) ;
199
+ childTest . tags = [ { id : "childTestTag" } ] ;
200
+ childSuite . children = [ childTest ] ;
201
+ testSuite . children = [ childSuite ] ;
202
+
203
+ updateTests ( testController , [ testSuite ] ) ;
204
+
205
+ assert . deepEqual ( testControllerChildren ( testController . items ) , [
206
+ {
207
+ id : "suite" ,
208
+ tags : [ { id : "XCTest" } , { id : "rootTag" } , { id : "runnable" } ] ,
209
+ children : [
210
+ {
211
+ id : "childSuite" ,
212
+ tags : [
213
+ { id : "XCTest" } ,
214
+ { id : "childSuiteTag" } ,
215
+ { id : "rootTag" } ,
216
+ { id : "runnable" } ,
217
+ ] ,
218
+ children : [
219
+ {
220
+ id : "childTest" ,
221
+ children : [ ] ,
222
+ tags : [
223
+ { id : "XCTest" } ,
224
+ { id : "childTestTag" } ,
225
+ { id : "childSuiteTag" } ,
226
+ { id : "rootTag" } ,
227
+ { id : "runnable" } ,
228
+ ] ,
229
+ } ,
230
+ ] ,
231
+ } ,
232
+ ] ,
233
+ } ,
172
234
] ) ;
173
235
} ) ;
174
236
} ) ;
0 commit comments