File tree Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Expand file tree Collapse file tree 3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,13 @@ export function upsertTestItem(
231
231
// parent tags down the tree as children are upserted.
232
232
testItem = applyTagsToChildren ( testItem ) ;
233
233
234
- // Manually add the test style as a tag so we can filter by test type.
235
- newItem . tags = [ { id : testItem . style } , ...testItem . tags ] ;
234
+ const hasTestStyleTag = testItem . tags . find ( tag => tag . id === testItem . style ) ;
235
+
236
+ // Manually add the test style as a tag if it isn't already in the tags list.
237
+ // This lets the user filter by test type.
238
+ newItem . tags = hasTestStyleTag
239
+ ? [ ...testItem . tags ]
240
+ : [ { id : testItem . style } , ...testItem . tags ] ;
236
241
237
242
if ( testItem . disabled === false ) {
238
243
newItem . tags = [ ...newItem . tags , runnableTag ] ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import * as stream from "stream";
18
18
import * as os from "os" ;
19
19
import * as asyncfs from "fs/promises" ;
20
20
import { FolderContext } from "../FolderContext" ;
21
- import { execFile , getErrorDescription } from "../utilities/utilities" ;
21
+ import { compactMap , execFile , getErrorDescription } from "../utilities/utilities" ;
22
22
import { createSwiftTask } from "../tasks/SwiftTaskProvider" ;
23
23
import configuration from "../configuration" ;
24
24
import { WorkspaceContext } from "../WorkspaceContext" ;
@@ -135,7 +135,12 @@ export class TestRunProxy {
135
135
testClass . location = undefined ;
136
136
137
137
// Results should inherit any tags from the parent.
138
- testClass . tags = parent . tags . map ( t => new vscode . TestTag ( t . id ) ) ;
138
+ // Until we can rerun a swift-testing test with an individual argument, mark
139
+ // the argument test items as not runnable. This should be revisited when
140
+ // https://github.com/swiftlang/swift-testing/issues/671 is resolved.
141
+ testClass . tags = compactMap ( parent . tags , t =>
142
+ t . id === runnableTag . id ? null : new vscode . TestTag ( t . id )
143
+ ) ;
139
144
140
145
const added = upsertTestItem ( this . controller , testClass , parent ) ;
141
146
Original file line number Diff line number Diff line change @@ -219,6 +219,26 @@ export function wait(milliseconds: number): Promise<void> {
219
219
return new Promise ( resolve => setTimeout ( resolve , milliseconds ) ) ;
220
220
}
221
221
222
+ /**
223
+ * Returns an array containing the non-null and non-undefined results of calling
224
+ * the given transformation with each element of this sequence.
225
+ *
226
+ * @param arr An array to map
227
+ * @param transform A transformation function to apply to each element
228
+ * @returns An array containing the non-null and non-undefined results of calling transform on each element
229
+ */
230
+ export function compactMap < T , U > (
231
+ arr : readonly T [ ] ,
232
+ transform : ( value : T ) => U | null | undefined
233
+ ) : U [ ] {
234
+ return arr . reduce < U [ ] > ( ( acc , item ) => {
235
+ const result = transform ( item ) ;
236
+ if ( result !== null && result !== undefined ) {
237
+ acc . push ( result ) ;
238
+ }
239
+ return acc ;
240
+ } , [ ] ) ;
241
+ }
222
242
/**
223
243
* Get path to swift executable, or executable in swift bin folder
224
244
*
You can’t perform that action at this time.
0 commit comments