diff --git a/test/automation/src/application.ts b/test/automation/src/application.ts index 14280091027..81acded3853 100644 --- a/test/automation/src/application.ts +++ b/test/automation/src/application.ts @@ -98,11 +98,11 @@ export class Application { } } - async startTracing(name: string): Promise { + async startTracing(name?: string): Promise { await this._code?.startTracing(name); } - async stopTracing(name: string, persist: boolean): Promise { + async stopTracing(name?: string, persist: boolean = false): Promise { await this._code?.stopTracing(name, persist); } diff --git a/test/automation/src/code.ts b/test/automation/src/code.ts index 34c3a0717b4..fe498419122 100644 --- a/test/automation/src/code.ts +++ b/test/automation/src/code.ts @@ -143,11 +143,11 @@ export class Code { return !(this.quality === Quality.Stable && this.version.major === 1 && this.version.minor < 101); } - async startTracing(name: string): Promise { + async startTracing(name?: string): Promise { return await this.driver.startTracing(name); } - async stopTracing(name: string, persist: boolean): Promise { + async stopTracing(name?: string, persist: boolean = false): Promise { return await this.driver.stopTracing(name, persist); } diff --git a/test/automation/src/playwrightDriver.ts b/test/automation/src/playwrightDriver.ts index 5c95e977117..26e2a465c84 100644 --- a/test/automation/src/playwrightDriver.ts +++ b/test/automation/src/playwrightDriver.ts @@ -51,19 +51,19 @@ export class PlaywrightDriver { return this.page; } - async startTracing(name: string): Promise { + async startTracing(name?: string): Promise { if (!this.options.tracing) { return; // tracing disabled } try { - await measureAndLog(() => this.context.tracing.startChunk({ title: name }), `startTracing for ${name}`, this.options.logger); + await measureAndLog(() => this.context.tracing.startChunk({ title: name }), `startTracing${name ? ` for ${name}` : ''}`, this.options.logger); } catch (error) { // Ignore } } - async stopTracing(name: string, persist: boolean): Promise { + async stopTracing(name?: string, persist: boolean = false): Promise { if (!this.options.tracing) { return; // tracing disabled } @@ -71,10 +71,11 @@ export class PlaywrightDriver { try { let persistPath: string | undefined = undefined; if (persist) { - persistPath = join(this.options.logsPath, `playwright-trace-${PlaywrightDriver.traceCounter++}-${name.replace(/\s+/g, '-')}.zip`); + const nameSuffix = name ? `-${name.replace(/\s+/g, '-')}` : ''; + persistPath = join(this.options.logsPath, `playwright-trace-${PlaywrightDriver.traceCounter++}${nameSuffix}.zip`); } - await measureAndLog(() => this.context.tracing.stopChunk({ path: persistPath }), `stopTracing for ${name}`, this.options.logger); + await measureAndLog(() => this.context.tracing.stopChunk({ path: persistPath }), `stopTracing${name ? ` for ${name}` : ''}`, this.options.logger); // To ensure we have a screenshot at the end where // it failed, also trigger one explicitly. Tracing @@ -168,9 +169,10 @@ export class PlaywrightDriver { return await this._cdpSession.send('Runtime.getProperties', parameters); } - private async takeScreenshot(name: string): Promise { + private async takeScreenshot(name?: string): Promise { try { - const persistPath = join(this.options.logsPath, `playwright-screenshot-${PlaywrightDriver.screenShotCounter++}-${name.replace(/\s+/g, '-')}.png`); + const nameSuffix = name ? `-${name.replace(/\s+/g, '-')}` : ''; + const persistPath = join(this.options.logsPath, `playwright-screenshot-${PlaywrightDriver.screenShotCounter++}${nameSuffix}.png`); await measureAndLog(() => this.page.screenshot({ path: persistPath, type: 'png' }), 'takeScreenshot', this.options.logger); } catch (error) { diff --git a/test/mcp/src/application.ts b/test/mcp/src/application.ts index fe64d941b4d..a60c7b9764d 100644 --- a/test/mcp/src/application.ts +++ b/test/mcp/src/application.ts @@ -260,7 +260,7 @@ export async function getApplication({ recordVideo }: { recordVideo?: boolean } verbose: opts.verbose, remote: opts.remote, web: opts.web, - tracing: opts.tracing, + tracing: true, headless: opts.headless, browser: opts.browser, extraArgs: (opts.electronArgs || '').split(' ').map(arg => arg.trim()).filter(arg => !!arg), diff --git a/test/mcp/src/automation.ts b/test/mcp/src/automation.ts index 8e4f84a25fe..9163af43e89 100644 --- a/test/mcp/src/automation.ts +++ b/test/mcp/src/automation.ts @@ -24,6 +24,7 @@ export async function getServer(appService: ApplicationService): Promise }, async ({ recordVideo }) => { const app = await appService.getOrCreateApplication({ recordVideo }); + await app.startTracing(); return { content: [{ type: 'text' as const, diff --git a/test/mcp/src/automationTools/core.ts b/test/mcp/src/automationTools/core.ts index 3f9e34cf1e6..591d7437896 100644 --- a/test/mcp/src/automationTools/core.ts +++ b/test/mcp/src/automationTools/core.ts @@ -37,6 +37,7 @@ export function applyCoreTools(server: McpServer, appService: ApplicationService 'Stop the VS Code application', async () => { const app = await appService.getOrCreateApplication(); + await app.stopTracing(undefined, true); await app.stop(); return { content: [{ diff --git a/test/mcp/src/options.ts b/test/mcp/src/options.ts index ac4ded14760..eb81d9982d6 100644 --- a/test/mcp/src/options.ts +++ b/test/mcp/src/options.ts @@ -19,7 +19,6 @@ export const opts = minimist(args, { 'remote', 'web', 'headless', - 'tracing', 'video', 'autostart' ], @@ -31,7 +30,6 @@ export const opts = minimist(args, { remote?: boolean; headless?: boolean; web?: boolean; - tracing?: boolean; build?: string; 'stable-build'?: string; browser?: 'chromium' | 'webkit' | 'firefox' | 'chromium-msedge' | 'chromium-chrome' | undefined;