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(
231231 // parent tags down the tree as children are upserted.
232232 testItem = applyTagsToChildren ( testItem ) ;
233233
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 ] ;
236241
237242 if ( testItem . disabled === false ) {
238243 newItem . tags = [ ...newItem . tags , runnableTag ] ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import * as stream from "stream";
1818import * as os from "os" ;
1919import * as asyncfs from "fs/promises" ;
2020import { FolderContext } from "../FolderContext" ;
21- import { execFile , getErrorDescription } from "../utilities/utilities" ;
21+ import { compactMap , execFile , getErrorDescription } from "../utilities/utilities" ;
2222import { createSwiftTask } from "../tasks/SwiftTaskProvider" ;
2323import configuration from "../configuration" ;
2424import { WorkspaceContext } from "../WorkspaceContext" ;
@@ -135,7 +135,12 @@ export class TestRunProxy {
135135 testClass . location = undefined ;
136136
137137 // 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+ ) ;
139144
140145 const added = upsertTestItem ( this . controller , testClass , parent ) ;
141146
Original file line number Diff line number Diff line change @@ -219,6 +219,26 @@ export function wait(milliseconds: number): Promise<void> {
219219 return new Promise ( resolve => setTimeout ( resolve , milliseconds ) ) ;
220220}
221221
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+ }
222242/**
223243 * Get path to swift executable, or executable in swift bin folder
224244 *
You can’t perform that action at this time.
0 commit comments