Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DebugSessionOptions.testRun #13939

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .theia/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.formatOnSave": false,
"editor.formatOnSave": true,
"editor.insertSpaces": true,
"[typescript]": {
"editor.tabSize": 4
Expand Down
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

<!-- ## not yet released
## not yet released
- [test] Added `DebugSessionOptions.testRun` [#13939](https://github.com/eclipse-theia/theia/pull/13939) - Contributed on behalf of STMicroelectronics

- [core] introduce `FRONTEND_CONNECTION_TIMEOUT` environment variable to override application connexion settings. [#13936](https://github.com/eclipse-theia/theia/pull/13936) - Contributed on behalf of STMicroelectronics
- [core] tab selected should be adjacent when closing last one [#13912](https://github.com/eclipse-theia/theia/pull/13912) - contributed on behalf of STMicroelectronics
Expand All @@ -13,8 +14,6 @@

<a name="breaking_changes_not_yet_released">[Breaking Changes:](#breaking_changes_not_yet_released)</a>

-->

## 1.50.0 - 06/27/2024

- [application-manager] updated logic to load correct messaging module in browser-only mode [#13827](https://github.com/eclipse-theia/theia/pull/13827)
Expand Down
1 change: 1 addition & 0 deletions packages/debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@theia/output": "1.51.0",
"@theia/process": "1.51.0",
"@theia/task": "1.51.0",
"@theia/test": "1.51.0",
"@theia/terminal": "1.51.0",
"@theia/variable-resolver": "1.51.0",
"@theia/workspace": "1.51.0",
Expand Down
11 changes: 9 additions & 2 deletions packages/debug/src/browser/debug-session-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { FileService } from '@theia/filesystem/lib/browser/file-service';
import { DebugContribution } from './debug-contribution';
import { WorkspaceService } from '@theia/workspace/lib/browser';
import { RemoteConnectionProvider, ServiceConnectionProvider } from '@theia/core/lib/browser/messaging/service-connection-provider';
import { TestService } from '@theia/test/lib/browser/test-service';
import { DebugSessionManager } from './debug-session-manager';

/**
* DebugSessionContribution symbol for DI.
Expand Down Expand Up @@ -90,7 +92,7 @@ export const DebugSessionFactory = Symbol('DebugSessionFactory');
* The [debug session](#DebugSession) factory.
*/
export interface DebugSessionFactory {
get(sessionId: string, options: DebugSessionOptions, parentSession?: DebugSession): DebugSession;
get(manager: DebugSessionManager, sessionId: string, options: DebugSessionOptions, parentSession?: DebugSession): DebugSession;
}

@injectable()
Expand All @@ -115,10 +117,12 @@ export class DefaultDebugSessionFactory implements DebugSessionFactory {
protected readonly fileService: FileService;
@inject(ContributionProvider) @named(DebugContribution)
protected readonly debugContributionProvider: ContributionProvider<DebugContribution>;
@inject(TestService)
protected readonly testService: TestService;
@inject(WorkspaceService)
protected readonly workspaceService: WorkspaceService;

get(sessionId: string, options: DebugConfigurationSessionOptions, parentSession?: DebugSession): DebugSession {
get(manager: DebugSessionManager, sessionId: string, options: DebugConfigurationSessionOptions, parentSession?: DebugSession): DebugSession {
const connection = new DebugSessionConnection(
sessionId,
() => new Promise<DebugChannel>(resolve =>
Expand All @@ -131,6 +135,9 @@ export class DefaultDebugSessionFactory implements DebugSessionFactory {
sessionId,
options,
parentSession,
this.testService,
options.testRun,
manager,
connection,
this.terminalService,
this.editorManager,
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/src/browser/debug-session-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class DebugSessionManager {
const parentSession = options.configuration.parentSessionId ? this._sessions.get(options.configuration.parentSessionId) : undefined;
const contrib = this.sessionContributionRegistry.get(options.configuration.type);
const sessionFactory = contrib ? contrib.debugSessionFactory() : this.debugSessionFactory;
const session = sessionFactory.get(sessionId, options, parentSession);
const session = sessionFactory.get(this, sessionId, options, parentSession);
this._sessions.set(sessionId, session);

this.debugTypeKey.set(session.configuration.type);
Expand Down
6 changes: 6 additions & 0 deletions packages/debug/src/browser/debug-session-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ export class DebugCompoundRoot {
}
}

export interface TestRunReference {
controllerId: string,
runId: string
}

export interface DebugSessionOptionsBase {
workspaceFolderUri?: string,
testRun?: TestRunReference
}

export interface DebugConfigurationSessionOptions extends DebugSessionOptionsBase {
Expand Down
20 changes: 19 additions & 1 deletion packages/debug/src/browser/debug-session.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { DebugSourceBreakpoint } from './model/debug-source-breakpoint';
import debounce = require('p-debounce');
import URI from '@theia/core/lib/common/uri';
import { BreakpointManager } from './breakpoint/breakpoint-manager';
import { DebugConfigurationSessionOptions, InternalDebugSessionOptions } from './debug-session-options';
import { DebugConfigurationSessionOptions, InternalDebugSessionOptions, TestRunReference } from './debug-session-options';
import { DebugConfiguration, DebugConsoleMode } from '../common/debug-common';
import { SourceBreakpoint, ExceptionBreakpoint } from './breakpoint/breakpoint-marker';
import { TerminalWidgetOptions, TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
Expand All @@ -44,6 +44,8 @@ import { Deferred, waitForEvent } from '@theia/core/lib/common/promise-util';
import { WorkspaceService } from '@theia/workspace/lib/browser';
import { DebugInstructionBreakpoint } from './model/debug-instruction-breakpoint';
import { nls } from '@theia/core';
import { TestService, TestServices } from '@theia/test/lib/browser/test-service';
import { DebugSessionManager } from './debug-session-manager';

export enum DebugState {
Inactive,
Expand Down Expand Up @@ -98,6 +100,9 @@ export class DebugSession implements CompositeTreeElement {
readonly id: string,
readonly options: DebugConfigurationSessionOptions,
readonly parentSession: DebugSession | undefined,
testService: TestService,
tsmaeder marked this conversation as resolved.
Show resolved Hide resolved
testRun: TestRunReference | undefined,
sessionManager: DebugSessionManager,
protected readonly connection: DebugSessionConnection,
protected readonly terminalServer: TerminalService,
protected readonly editorManager: EditorManager,
Expand All @@ -124,6 +129,19 @@ export class DebugSession implements CompositeTreeElement {
this.parentSession?.childSessions?.delete(id);
}));
}
if (testRun) {
try {
const run = TestServices.withTestRun(testService, testRun.controllerId, testRun.runId);
run.onDidChangeProperty(evt => {
if (evt.isRunning === false) {
sessionManager.terminateSession(this);
}
});
} catch (err) {
console.error(err);
}
}

this.connection.onDidClose(() => this.toDispose.dispose());
this.toDispose.pushAll([
this.onDidChangeEmitter,
Expand Down
4 changes: 4 additions & 0 deletions packages/debug/src/common/debug-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export interface DebugSessionOptions {
suppressSaveBeforeStart?: boolean;
suppressDebugStatusbar?: boolean;
suppressDebugView?: boolean;
testRun?: {
controllerId: string,
runId: string
}
}

export enum DebugConsoleMode {
Expand Down
3 changes: 3 additions & 0 deletions packages/debug/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
{
"path": "../terminal"
},
{
"path": "../test"
},
{
"path": "../variable-resolver"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/plugin-ext/src/main/browser/debug/debug-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { WorkspaceService } from '@theia/workspace/lib/browser';
import { DebugSessionOptions as TheiaDebugSessionOptions } from '@theia/debug/lib/browser/debug-session-options';
import { DebugStackFrame } from '@theia/debug/lib/browser/model/debug-stack-frame';
import { DebugThread } from '@theia/debug/lib/browser/model/debug-thread';
import { TestService } from '@theia/test/lib/browser/test-service';

export class DebugMainImpl implements DebugMain, Disposable {
private readonly debugExt: DebugExt;
Expand All @@ -77,6 +78,7 @@ export class DebugMainImpl implements DebugMain, Disposable {
private readonly fileService: FileService;
private readonly pluginService: HostedPluginSupport;
private readonly debugContributionProvider: ContributionProvider<DebugContribution>;
private readonly testService: TestService;
private readonly workspaceService: WorkspaceService;

private readonly debuggerContributions = new Map<string, DisposableCollection>();
Expand All @@ -100,6 +102,7 @@ export class DebugMainImpl implements DebugMain, Disposable {
this.debugContributionProvider = container.getNamed(ContributionProvider, DebugContribution);
this.fileService = container.get(FileService);
this.pluginService = container.get(HostedPluginSupport);
this.testService = container.get(TestService);
this.workspaceService = container.get(WorkspaceService);

const fireDidChangeBreakpoints = ({ added, removed, changed }: BreakpointsChangeEvent<SourceBreakpoint | FunctionBreakpoint>) => {
Expand Down Expand Up @@ -165,6 +168,7 @@ export class DebugMainImpl implements DebugMain, Disposable {
this.fileService,
terminalOptionsExt,
this.debugContributionProvider,
this.testService,
this.workspaceService,
);

Expand Down Expand Up @@ -327,6 +331,7 @@ export class DebugMainImpl implements DebugMain, Disposable {
} else {
sessionOptions = { ...sessionOptions, ...options, workspaceFolderUri };
}
sessionOptions.testRun = options.testRun;

// start options
const session = await this.sessionManager.start(sessionOptions);
Expand All @@ -345,7 +350,7 @@ export class DebugMainImpl implements DebugMain, Disposable {
}

private toDebugStackFrameDTO(stackFrame: DebugStackFrame | undefined): DebugStackFrameDTO | undefined {
return stackFrame ? {
return stackFrame ? {
sessionId: stackFrame.session.id,
frameId: stackFrame.frameId,
threadId: stackFrame.thread.threadId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { LabelProvider } from '@theia/core/lib/browser/label-provider';
import { MessageClient } from '@theia/core/lib/common/message-service-protocol';
import { OutputChannelManager } from '@theia/output/lib/browser/output-channel';
import { DebugPreferences } from '@theia/debug/lib/browser/debug-preferences';
import { DebugConfigurationSessionOptions } from '@theia/debug/lib/browser/debug-session-options';
import { DebugConfigurationSessionOptions, TestRunReference } from '@theia/debug/lib/browser/debug-session-options';
import { DebugSession } from '@theia/debug/lib/browser/debug-session';
import { DebugSessionConnection } from '@theia/debug/lib/browser/debug-session-connection';
import { TerminalWidgetOptions, TerminalWidget } from '@theia/terminal/lib/browser/base/terminal-widget';
Expand All @@ -32,12 +32,17 @@ import { DebugContribution } from '@theia/debug/lib/browser/debug-contribution';
import { ContributionProvider } from '@theia/core/lib/common/contribution-provider';
import { WorkspaceService } from '@theia/workspace/lib/browser';
import { PluginChannel } from '../../../common/connection';
import { TestService } from '@theia/test/lib/browser/test-service';
import { DebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';

export class PluginDebugSession extends DebugSession {
constructor(
override readonly id: string,
override readonly options: DebugConfigurationSessionOptions,
override readonly parentSession: DebugSession | undefined,
testService: TestService,
testRun: TestRunReference | undefined,
sessionManager: DebugSessionManager,
protected override readonly connection: DebugSessionConnection,
protected override readonly terminalServer: TerminalService,
protected override readonly editorManager: EditorManager,
Expand All @@ -48,7 +53,8 @@ export class PluginDebugSession extends DebugSession {
protected readonly terminalOptionsExt: TerminalOptionsExt | undefined,
protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>,
protected override readonly workspaceService: WorkspaceService) {
super(id, options, parentSession, connection, terminalServer, editorManager, breakpoints, labelProvider, messages, fileService, debugContributionProvider,
super(id, options, parentSession, testService, testRun, sessionManager, connection, terminalServer, editorManager, breakpoints,
labelProvider, messages, fileService, debugContributionProvider,
workspaceService);
}

Expand All @@ -75,12 +81,13 @@ export class PluginDebugSessionFactory extends DefaultDebugSessionFactory {
protected override readonly fileService: FileService,
protected readonly terminalOptionsExt: TerminalOptionsExt | undefined,
protected override readonly debugContributionProvider: ContributionProvider<DebugContribution>,
protected override readonly testService: TestService,
protected override readonly workspaceService: WorkspaceService,
) {
super();
}

override get(sessionId: string, options: DebugConfigurationSessionOptions, parentSession?: DebugSession): DebugSession {
override get(manager: DebugSessionManager, sessionId: string, options: DebugConfigurationSessionOptions, parentSession?: DebugSession): DebugSession {
const connection = new DebugSessionConnection(
sessionId,
this.connectionFactory,
Expand All @@ -90,6 +97,9 @@ export class PluginDebugSessionFactory extends DefaultDebugSessionFactory {
sessionId,
options,
parentSession,
this.testService,
options.testRun,
manager,
connection,
this.terminalService,
this.editorManager,
Expand Down
17 changes: 13 additions & 4 deletions packages/plugin-ext/src/plugin/debug/debug-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import { DebugAdapter } from '@theia/debug/lib/common/debug-model';
import { PluginDebugAdapterCreator } from './plugin-debug-adapter-creator';
import { NodeDebugAdapterCreator } from '../node/debug/plugin-node-debug-adapter-creator';
import { DebugProtocol } from '@vscode/debugprotocol';
import { DebugConfiguration } from '@theia/debug/lib/common/debug-configuration';
import { DebugConfiguration, DebugSessionOptions } from '@theia/debug/lib/common/debug-configuration';
import { checkTestRunInstance } from '../tests';

interface ConfigurationProviderRecord {
handle: number;
Expand Down Expand Up @@ -193,16 +194,24 @@ export class DebugExtImpl implements DebugExt {
}

startDebugging(folder: theia.WorkspaceFolder | undefined, nameOrConfiguration: string | theia.DebugConfiguration, options: theia.DebugSessionOptions): PromiseLike<boolean> {
return this.proxy.$startDebugging(folder, nameOrConfiguration, {
const optionsDto: DebugSessionOptions = {
parentSessionId: options.parentSession?.id,
compact: options.compact,
consoleMode: options.consoleMode,
suppressSaveBeforeStart: options.suppressSaveBeforeStart,
suppressDebugStatusbar: options.suppressDebugStatusbar,
suppressDebugView: options.suppressDebugView,
lifecycleManagedByParent: options.lifecycleManagedByParent,
noDebug: options.noDebug
});
noDebug: options.noDebug,
};
if (options.testRun) {
const run = checkTestRunInstance(options.testRun);
optionsDto.testRun = {
controllerId: run.controller.id,
runId: run.id
};
}
return this.proxy.$startDebugging(folder, nameOrConfiguration, optionsDto);
}

stopDebugging(session?: theia.DebugSession): PromiseLike<void> {
Expand Down
Loading
Loading