(noDebug: boolean, includeCoverage: boolean, isFlutter: boolean, programPath: string, testSelection: TestSelection[] | undefined, shouldRunTestByLine: boolean, runSkippedTests: boolean | undefined, template: any | undefined, dartTestCapabilities: DartTestCapabilities | undefined, workspacePackageNames?: string[])
| 10 | import { TestOutlineInfo } from "./outline"; |
| 11 | |
| 12 | export function getLaunchConfig(noDebug: boolean, includeCoverage: boolean, isFlutter: boolean, programPath: string, testSelection: TestSelection[] | undefined, shouldRunTestByLine: boolean, runSkippedTests: boolean | undefined, template: any | undefined, dartTestCapabilities: DartTestCapabilities | undefined, workspacePackageNames?: string[]): { program: string } & BasicDebugConfiguration { |
| 13 | let programString = programPath; |
| 14 | let toolArgs: string[] = []; |
| 15 | if (template?.toolArgs) |
| 16 | toolArgs = toolArgs.concat(template?.toolArgs as []); |
| 17 | if (testSelection) { |
| 18 | const execInfo = getTestExecutionInfo(programString, testSelection, shouldRunTestByLine); |
| 19 | programString = getProgramString(execInfo.programUri); |
| 20 | toolArgs.push(...execInfo.args); |
| 21 | } |
| 22 | if (runSkippedTests) |
| 23 | toolArgs.push("--run-skipped"); |
| 24 | if (includeCoverage) { |
| 25 | const coverageFilePath = path.join(os.tmpdir(), `coverage-${getRandomInt(0x1000, 0x10000).toString(16)}.lcov`); |
| 26 | |
| 27 | toolArgs.push("--branch-coverage"); |
| 28 | toolArgs.push("--coverage-path"); |
| 29 | toolArgs.push(coverageFilePath); |
| 30 | |
| 31 | // Flutter requires this additional flag. |
| 32 | if (isFlutter) |
| 33 | toolArgs.push("--coverage"); |
| 34 | |
| 35 | if (workspacePackageNames && (isFlutter || dartTestCapabilities?.supportsCoveragePackage)) { |
| 36 | for (const packageName of workspacePackageNames) { |
| 37 | toolArgs.push("--coverage-package", `^${escapeRegExp(packageName)}$`); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | template ??= {}; |
| 42 | template.coverageFilePath = coverageFilePath; |
| 43 | } |
| 44 | |
| 45 | return Object.assign( |
| 46 | { |
| 47 | // Trailing space is a workaround for https://github.com/microsoft/vscode/issues/100115 |
| 48 | name: "Tests ", |
| 49 | noDebug, |
| 50 | request: "launch", |
| 51 | type: "dart", |
| 52 | }, |
| 53 | template, |
| 54 | { |
| 55 | args: template?.args, |
| 56 | expectSingleTest: testSelection?.length === 1 && !testSelection[0].name.includes("$") && !testSelection[0].isGroup, |
| 57 | program: programString, |
| 58 | toolArgs, |
| 59 | }, |
| 60 | ) as { program: string } & BasicDebugConfiguration; |
| 61 | } |
| 62 | |
| 63 | export interface TestSelection { |
| 64 | /// Whether this node is a test that wasn't discovered inside the top |
no test coverage detected