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" ;
@@ -127,7 +127,12 @@ export class TestRunProxy {
127127 testClass . location = undefined ;
128128
129129 // Results should inherit any tags from the parent.
130- testClass . tags = parent . tags . map ( t => new vscode . TestTag ( t . id ) ) ;
130+ // Until we can rerun a swift-testing test with an individual argument, mark
131+ // the argument test items as not runnable. This should be revisited when
132+ // https://github.com/swiftlang/swift-testing/issues/671 is resolved.
133+ testClass . tags = compactMap ( parent . tags , t =>
134+ t . id === runnableTag . id ? null : new vscode . TestTag ( t . id )
135+ ) ;
131136
132137 const added = upsertTestItem ( this . controller , testClass , parent ) ;
133138
Original file line number Diff line number Diff line change @@ -205,6 +205,26 @@ export function wait(milliseconds: number): Promise<void> {
205205 return new Promise ( resolve => setTimeout ( resolve , milliseconds ) ) ;
206206}
207207
208+ /**
209+ * Returns an array containing the non-null and non-undefined results of calling
210+ * the given transformation with each element of this sequence.
211+ *
212+ * @param arr An array to map
213+ * @param transform A transformation function to apply to each element
214+ * @returns An array containing the non-null and non-undefined results of calling transform on each element
215+ */
216+ export function compactMap < T , U > (
217+ arr : readonly T [ ] ,
218+ transform : ( value : T ) => U | null | undefined
219+ ) : U [ ] {
220+ return arr . reduce < U [ ] > ( ( acc , item ) => {
221+ const result = transform ( item ) ;
222+ if ( result !== null && result !== undefined ) {
223+ acc . push ( result ) ;
224+ }
225+ return acc ;
226+ } , [ ] ) ;
227+ }
208228/**
209229 * Get path to swift executable, or executable in swift bin folder
210230 *
You can’t perform that action at this time.
0 commit comments