generated from hbenl/vscode-example-test-adapter
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
244 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
export interface IDebugConfiguration { | ||
target?: string; | ||
program?: string; | ||
args?: string[]; | ||
name: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
export interface IWorkspaceConfiguration { | ||
testExecutable: string | undefined; | ||
testExecutablePath: string | undefined; | ||
testLocationFetchMode: any; | ||
logfile: string | undefined; | ||
logpanel: boolean; | ||
debugLaunchConfigurationName: string | undefined; | ||
objDumpExecutable: string | undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
export interface IWorkspaceFolder { | ||
readonly uri: any; | ||
readonly name: string; | ||
readonly index: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { IDebugConfiguration } from "./IDebugConfiguration"; | ||
import { IWorkspaceConfiguration } from "./IWorkspaceConfiguration"; | ||
import { IWorkspaceFolder } from "./IWorkspaceFolder"; | ||
import { SettingsProvider } from "./SettingsProvider"; | ||
import { TestLocationFetchMode } from "./TestLocationFetchMode"; | ||
import { VscodeAdapter } from "./VscodeAdapter"; | ||
|
||
export { IDebugConfiguration }; | ||
export { TestLocationFetchMode }; | ||
export { SettingsProvider }; | ||
export { IWorkspaceConfiguration }; | ||
export { IWorkspaceFolder }; | ||
export { VscodeAdapter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,90 @@ | ||
import { DebugConfiguration, WorkspaceFolder } from 'vscode'; | ||
import glob = require('glob'); | ||
import { Log } from 'vscode-test-adapter-util'; | ||
import { IWorkspaceFolder } from './IWorkspaceFolder'; | ||
import { IDebugConfiguration } from './IDebugConfiguration'; | ||
import { IWorkspaceConfiguration } from './IWorkspaceConfiguration'; | ||
import { TestLocationFetchMode } from './TestLocationFetchMode'; | ||
|
||
export enum TestLocationFetchMode { | ||
Auto, | ||
TestQuery, | ||
DebugDump, | ||
Disabled | ||
} | ||
export abstract class SettingsProvider { | ||
|
||
protected log: Log; | ||
protected config: IWorkspaceConfiguration; | ||
|
||
constructor(log: Log) { | ||
const configSection = "cpputestTestAdapter"; | ||
|
||
this.log = log; | ||
this.config = this.GetConfig(configSection); | ||
} | ||
|
||
protected abstract GetConfig(section: string): IWorkspaceConfiguration; | ||
abstract GetObjDumpPath(): string; | ||
abstract GetTestRunners(): string[]; | ||
abstract GetTestPath(): string; | ||
abstract GetDebugConfiguration(): (IDebugConfiguration | undefined); | ||
abstract GetWorkspaceFolders(): readonly IWorkspaceFolder[] | undefined | ||
protected abstract GetCurrentFilename(): string | ||
protected abstract GetCurrentWorkspaceFolder(): string | ||
|
||
public get TestLocationFetchMode(): TestLocationFetchMode { | ||
switch (this.config.testLocationFetchMode) { | ||
case 'test query': | ||
return TestLocationFetchMode.TestQuery; | ||
case 'debug dump': | ||
return TestLocationFetchMode.DebugDump; | ||
case 'auto': | ||
return TestLocationFetchMode.Auto; | ||
case 'disabled': | ||
default: | ||
return TestLocationFetchMode.Disabled; | ||
} | ||
} | ||
|
||
protected IsCCppDebugger(config: any) { | ||
const isWin = process.platform === "win32"; | ||
// This is my way of saying: If we are using windows check for a config that has an .exe program. | ||
const executionExtension: boolean = isWin ? config.program.endsWith(".exe") : true; | ||
return config.request == 'launch' && | ||
typeof config.type == 'string' && | ||
executionExtension && | ||
(config.type.startsWith('cpp') || | ||
config.type.startsWith('lldb') || | ||
config.type.startsWith('gdb')); | ||
} | ||
|
||
protected SplitRunners(executablesString: string | undefined): string[] { | ||
if (executablesString) { | ||
if (executablesString.indexOf(";") === -1) { | ||
return [this.ResolveSettingsVariable(executablesString)]; | ||
} | ||
return executablesString | ||
.split(";") | ||
.map(r => this.ResolveSettingsVariable(r)) | ||
.map(r => glob.sync(r)) | ||
.reduce((flatten, arr) => [...flatten, ...arr]); | ||
} else { | ||
return []; | ||
} | ||
} | ||
|
||
export interface SettingsProvider { | ||
GetObjDumpPath(): string; | ||
GetTestRunners(): string[]; | ||
GetTestPath(): string; | ||
get TestLocationFetchMode(): TestLocationFetchMode; | ||
GetDebugConfiguration(): (DebugConfiguration | string); | ||
GetWorkspaceFolders(): readonly WorkspaceFolder[] | undefined | ||
/** | ||
* This function converts some of the VSCode variables like workspaceFolder | ||
* into their correspoing values. This is a workaround for https://github.com/microsoft/vscode/issues/46471 | ||
* @param input Input string from settings.json | ||
*/ | ||
protected ResolveSettingsVariable(input: string | undefined): string { | ||
if (input) { | ||
const result: string[] | null = input.match(/\$\{(.*)\}/gmi); | ||
if (result && result.length > 0) { | ||
this.log.info(`replacing config variabe "${input}"`); | ||
input = input.replace(/(\$\{file\})/gmi, this.GetCurrentFilename()); | ||
input = input.replace(/(\$\{workspaceFolder\})/gmi, this.GetCurrentWorkspaceFolder()); | ||
this.log.info(`replaced variable is now "${input}"`); | ||
} | ||
return input; | ||
} | ||
else { | ||
return ""; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
export enum TestLocationFetchMode { | ||
Auto, | ||
TestQuery, | ||
DebugDump, | ||
Disabled | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.