(fileUri: vs.Uri, search: string, testName: string | undefined, lineDelta = 0)
| 801 | } |
| 802 | |
| 803 | async function checkRunSingleTestFromCodeLens(fileUri: vs.Uri, search: string, testName: string | undefined, lineDelta = 0) { |
| 804 | const editor = await openFile(fileUri); |
| 805 | await waitForResult(() => !!privateApi.fileTracker.getOutlineFor(fileUri)); |
| 806 | |
| 807 | const fileCodeLens = await getCodeLens(editor.document); |
| 808 | const testPos = positionOf(search); |
| 809 | |
| 810 | const codeLensForTest = fileCodeLens.filter((cl) => cl.range.start.line === testPos.line + lineDelta); |
| 811 | assert.equal(codeLensForTest.length, 2); |
| 812 | |
| 813 | if (!codeLensForTest[0].command) { |
| 814 | // If there's no command, skip the test. This happens very infrequently and appears to be a VS Code |
| 815 | // race condition. Rather than failing our test runs, skip. |
| 816 | // TODO: Remove this if https://github.com/microsoft/vscode/issues/79805 gets a reliable fix. |
| 817 | return; |
| 818 | } |
| 819 | |
| 820 | const runAction = codeLensForTest.find((cl) => cl.command!.title === "Run")!; |
| 821 | assert.equal(runAction.command!.command, "_dart.startWithoutDebuggingTestFromOutline"); |
| 822 | if (testName) { |
| 823 | assert.equal(runAction.command!.arguments![0].fullName, testName); |
| 824 | assert.equal(runAction.command!.arguments![0].isGroup, false); |
| 825 | } |
| 826 | |
| 827 | const customEvents = await captureDebugSessionCustomEvents(async () => { |
| 828 | const didStart = await vs.commands.executeCommand(runAction.command!.command, ...(runAction.command!.arguments ?? [])); // eslint-disable-line @typescript-eslint/no-unsafe-argument |
| 829 | assert.ok(didStart); |
| 830 | }); |
| 831 | |
| 832 | // Ensure we got at least a "testDone" notification so we know the test run started correctly. |
| 833 | const testDoneNotifications = customEvents.filter(isTestDoneSuccessNotification); |
| 834 | assert.equal(testDoneNotifications.length, 1); |
| 835 | const testDoneNotification = testDoneNotifications[0]; |
| 836 | assert.ok(testDoneNotification, JSON.stringify(customEvents.map((e: any) => e.body as unknown), undefined, 4)); |
| 837 | } |
| 838 | |
| 839 | async function runWithoutDebugging(file: vs.Uri, args?: string[], ...otherEvents: Array<Promise<any>>): Promise<void> { |
| 840 | const fileUriWithoutQuery = file.with({ query: "" }); |
no test coverage detected