From 6b93e48d83ff08b3e0bb76467140bb34a9ed5bdd Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Fri, 19 Jun 2020 14:47:34 +0530 Subject: [PATCH] Fix Xdebug coverage --- __tests__/coverage.test.ts | 3 ++- dist/index.js | 17 ++++++++-------- src/coverage.ts | 41 +++++++++++++++++--------------------- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/__tests__/coverage.test.ts b/__tests__/coverage.test.ts index ad9a9bb6..fbed2d38 100644 --- a/__tests__/coverage.test.ts +++ b/__tests__/coverage.test.ts @@ -48,7 +48,8 @@ describe('Config tests', () => { it('checking addCoverage with Xdebug on linux', async () => { const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux'); - expect(linux).toContain('Xdebug currently only supports PHP 7.4 or lower'); + expect(linux).toContain('add_extension xdebug'); + expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug on darwin', async () => { diff --git a/dist/index.js b/dist/index.js index 5058f35d..fa7e33b4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2106,16 +2106,15 @@ const config = __importStar(__webpack_require__(641)); * @param pipe */ async function addCoverageXdebug(version, os_version, pipe) { - switch (version) { - case '8.0': - return ('\n' + - (await utils.addLog('$cross', 'xdebug', 'Xdebug currently only supports PHP 7.4 or lower', os_version))); - case '7.4': + const xdebug = (await extensions.addExtension('xdebug', version, os_version, true)) + pipe; + const ini = await config.addINIValues('xdebug.mode=coverage', os_version, true); + const log = await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version); + switch (true) { + case /8.[0-9]/.test(version): + return xdebug + '\n' + ini + '\n' + log; + case /5\.[3-6]|7.[0-4]/.test(version): default: - return ((await extensions.addExtension('xdebug', version, os_version, true)) + - pipe + - '\n' + - (await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version))); + return xdebug + '\n' + log; } } exports.addCoverageXdebug = addCoverageXdebug; diff --git a/src/coverage.ts b/src/coverage.ts index 74bc5ab8..49e6bfea 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -14,30 +14,25 @@ export async function addCoverageXdebug( os_version: string, pipe: string ): Promise { - switch (version) { - case '8.0': - return ( - '\n' + - (await utils.addLog( - '$cross', - 'xdebug', - 'Xdebug currently only supports PHP 7.4 or lower', - os_version - )) - ); - case '7.4': + const xdebug = + (await extensions.addExtension('xdebug', version, os_version, true)) + pipe; + const ini = await config.addINIValues( + 'xdebug.mode=coverage', + os_version, + true + ); + const log = await utils.addLog( + '$tick', + 'xdebug', + 'Xdebug enabled as coverage driver', + os_version + ); + switch (true) { + case /8.[0-9]/.test(version): + return xdebug + '\n' + ini + '\n' + log; + case /5\.[3-6]|7.[0-4]/.test(version): default: - return ( - (await extensions.addExtension('xdebug', version, os_version, true)) + - pipe + - '\n' + - (await utils.addLog( - '$tick', - 'xdebug', - 'Xdebug enabled as coverage driver', - os_version - )) - ); + return xdebug + '\n' + log; } }