in src/test-runner/run-tracker.ts [401:482]
private prepareDebugInfo() {
if (this.getRunProfileKind() !== vscode.TestRunProfileKind.Debug) {
return
}
// Determine configured launch configuration name.
const configName = getExtensionSetting(SettingName.LAUNCH_CONFIG_NAME)
if (!configName) {
this.run.appendOutput(
'No launch configuration name is configured. Debugger will not connect automatically for this run.\r\n'
)
this.run.appendOutput(
'Check the `bazelbsp.debug.profileName` VS Code setting to ensure it corresponds to a valid launch configuration.\r\n'
)
return
}
// Store the selected launch configuration.
const launchConfigurations = vscode.workspace.getConfiguration('launch')
const configurations =
launchConfigurations.get<any[]>('configurations') || []
const selectedConfig = configurations.find(
config => config.name !== undefined && config.name === configName
)
if (!selectedConfig) {
this.run.appendOutput(
`Unable to find debug profile ${configName}. Debugger will not connect automatically for this run.\r\n`
)
this.run.appendOutput(
'Check the `bazelbsp.debug.profileName` VS Code setting to ensure it corresponds to a valid launch configuration.\r\n'
)
}
// Ensure that matcher pattern is set for the output.
const readyPattern = getExtensionSetting(SettingName.DEBUG_READY_PATTERN)
if (!readyPattern) {
this.run.appendOutput(
'No matcher pattern is set. Debugger will not connect automatically for this run.\r\n'
)
this.run.appendOutput(
'Check the `bazelbsp.debug.readyPattern` VS Code setting to ensure that a pattern is set.\r\n'
)
}
// Ensure that matcher pattern is set for the output.
let debugFlags = getExtensionSetting(SettingName.DEBUG_BAZEL_FLAGS)
if (!debugFlags) {
this.run.appendOutput(
'No additional debug-specific Bazel flags have been found for this run.\r\n'
)
this.run.appendOutput(
'Check the `bazelbsp.debug.bazelFlags` VS Code setting to ensure that necessary flags are set.\r\n'
)
}
const workspaceRoot = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath
let remoteRoot: string | undefined
let targetUri: string | undefined
let target: BuildTarget | undefined
for (const testCaseInfo of this) {
if (testCaseInfo.target) {
target = testCaseInfo.target
targetUri = testCaseInfo.target.id.uri
break
}
}
if (workspaceRoot && targetUri && target) {
remoteRoot = this.languageToolManager
.getLanguageTools(target)
.getDebugRemoteRoot(workspaceRoot, targetUri)
}
this.debugInfo = {
debugFlags: debugFlags,
launchConfig: selectedConfig,
readyPattern: readyPattern ? new RegExp(readyPattern) : undefined,
localRoot: workspaceRoot,
remoteRoot: remoteRoot,
}
}