Skip to content

Commit

Permalink
experimental: testMate.cmd.get-debug-exec
Browse files Browse the repository at this point in the history
  • Loading branch information
matepek committed Mar 22, 2023
1 parent 3a6584c commit 7fe7bf3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

## [4.3.12]

## [4.3.11] - 2023-03-22

## [4.3.10] - 2022-12-26
Expand Down
6 changes: 3 additions & 3 deletions src/WorkspaceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export class WorkspaceManager implements vscode.Disposable {
test: AbstractTest,
cancellation: vscode.CancellationToken,
run: vscode.TestRun,
setDebugArgs: (args: string[]) => void,
setDebugArgs: (exec: string, args: string[]) => void,
): Promise<void> {
run.enqueued(test.item);

Expand All @@ -398,7 +398,7 @@ export class WorkspaceManager implements vscode.Disposable {
test: AbstractTest,
cancellation: vscode.CancellationToken,
run: vscode.TestRun,
setDebugArgs: (args: string[]) => void,
setDebugArgs: (exec: string, args: string[]) => void,
): Promise<void> {
try {
this._shared.log.info('Using debug');
Expand All @@ -411,7 +411,7 @@ export class WorkspaceManager implements vscode.Disposable {
const configuration = this._getConfiguration(this._shared.log);

const argsArray = executable.getDebugParams([test], configuration.getDebugBreakOnFailure());
setDebugArgs(argsArray);
setDebugArgs(executable.shared.path, argsArray);

const argsArrayFunc = async (): Promise<string[]> => argsArray;

Expand Down
9 changes: 8 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,12 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
);

// https://github.com/matepek/vscode-catch2-test-adapter/issues/375
let currentDebugExec = '';
let currentDebugArgs: string[] = [];
const setCurrentDebugVars = (exec: string, args: string[]) => {
currentDebugExec = exec;
currentDebugArgs = args;
};

const debugProfile = controller.createRunProfile(
'Debug Test',
Expand Down Expand Up @@ -209,7 +214,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
const test = testsToRun.direct[0];
runQueue.push(
manager
.debug(test, cancellation, testRun, (args: string[]) => (currentDebugArgs = args))
.debug(test, cancellation, testRun, setCurrentDebugVars)
.catch(e => {
vscode.window.showErrorMessage('Unexpected error from debug: ' + e);
})
Expand Down Expand Up @@ -251,6 +256,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
vscode.commands.registerCommand('testMate.cmd.reload-workspaces', commandReloadWorkspaces),
);

context.subscriptions.push(vscode.commands.registerCommand('testMate.cmd.get-debug-exec', () => currentDebugExec));

context.subscriptions.push(
vscode.commands.registerCommand('testMate.cmd.get-debug-args', () =>
currentDebugArgs.map(a => a.replaceAll('"', '\\"')).join('" "'),
Expand Down

0 comments on commit 7fe7bf3

Please sign in to comment.