diff --git a/package.json b/package.json index d11a8ec1..d2b4c4d6 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "displayName": "PHPUnit Test Explorer", "icon": "img/icon.png", "publisher": "recca0120", - "version": "3.7.7", + "version": "3.7.8", "private": true, "license": "MIT", "repository": { diff --git a/src/Handler.ts b/src/Handler.ts index d54f1c2f..6541765c 100644 --- a/src/Handler.ts +++ b/src/Handler.ts @@ -35,8 +35,7 @@ export class Handler { const xdebug = new Xdebug(this.configuration); builder.setXdebug(xdebug); - xdebug.setMode(request.profile?.kind); - + await xdebug.setMode(request.profile?.kind); if (xdebug.mode === Mode.debug) { // TODO: perhaps wait for the debug session await debug.startDebugging(wsf, xdebug.name ?? await xdebug.getDebugConfiguration()); diff --git a/src/PHPUnit/CommandBuilder/Xdebug.ts b/src/PHPUnit/CommandBuilder/Xdebug.ts index 307c044d..ef973023 100644 --- a/src/PHPUnit/CommandBuilder/Xdebug.ts +++ b/src/PHPUnit/CommandBuilder/Xdebug.ts @@ -1,5 +1,5 @@ import * as net from 'net'; -import { mkdtempSync } from 'node:fs'; +import { mkdtemp } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { IConfiguration } from '../Configuration'; @@ -54,7 +54,7 @@ export class Xdebug { return this; } - setMode(mode?: Mode | number) { + async setMode(mode?: Mode | number) { if (typeof mode !== 'number') { this.mode = mode; @@ -64,21 +64,18 @@ export class Xdebug { // export enum TestRunProfileKind { Run = 1, Debug = 2, Coverage = 3 } if (mode === 2) { this.mode = Mode.debug; + this.port = this.configuration.get('xdebugPort', 0) as number || await getFreePort(); } if (mode === 3) { this.mode = Mode.coverage; - this.setTemporaryDirectory(mkdtempSync(join(tmpdir(), 'phpunit-'))); + this.setTemporaryDirectory(await mkdtemp(join(tmpdir(), 'phpunit'))); } return this; } private async getPort() { - if (!this.port) { - this.port = this.configuration.get('xdebugPort', await getFreePort()) as number; - } - return this.port; }