From 5a40a5875d5dfdb05952a14bf9ca8c453988fc86 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 26 Nov 2020 23:11:52 +0530 Subject: [PATCH] Fix xdebug setup Co-authored-by: Owen Voke Co-authored-by: Shivam Mathur --- __tests__/coverage.test.ts | 2 ++ __tests__/extensions.test.ts | 6 ++++++ dist/index.js | 16 ++++++++-------- src/coverage.ts | 9 +-------- src/extensions.ts | 12 ++++++++++++ 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/__tests__/coverage.test.ts b/__tests__/coverage.test.ts index 0321867e..af25eb8c 100644 --- a/__tests__/coverage.test.ts +++ b/__tests__/coverage.test.ts @@ -28,11 +28,13 @@ describe('Config tests', () => { it('checking addCoverage with Xdebug on windows', async () => { const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32'); expect(win32).toContain('Add-Extension xdebug'); + expect(win32).toContain('xdebug.mode=coverage'); }); it('checking addCoverage with Xdebug on linux', async () => { const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux'); expect(linux).toContain('add_extension xdebug'); + expect(linux).toContain('echo "xdebug.mode=coverage"'); }); it('checking addCoverage with Xdebug3 on linux', async () => { diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index aaac702b..a772ce6e 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -25,6 +25,9 @@ describe('Extension tests', () => { 'Add-Log "$cross" "pcov" "pcov is not supported on PHP 5.6"' ); + win32 = await extensions.addExtension('xdebug', '7.2', 'win32'); + expect(win32).toContain('Add-Extension xdebug stable 2.9.8'); + win32 = await extensions.addExtension('mysql', '7.4', 'win32'); expect(win32).toContain('Add-Extension mysqli'); expect(win32).toContain('Add-Extension mysqlnd'); @@ -96,6 +99,9 @@ describe('Extension tests', () => { linux = await extensions.addExtension('cubrid', '7.4', 'linux'); expect(linux).toContain('add_cubrid cubrid'); + linux = await extensions.addExtension('xdebug', '7.2', 'linux'); + expect(linux).toContain('add_pecl_extension xdebug 2.9.8 zend_extension'); + linux = await extensions.addExtension('xdebug', '7.2', 'openbsd'); expect(linux).toContain('Platform openbsd is not supported'); diff --git a/dist/index.js b/dist/index.js index c1193fa8..c13b7f89 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2328,14 +2328,7 @@ async function addCoverageXdebug(extension, version, os_version, pipe) { pipe; const ini = await config.addINIValues('xdebug.mode=coverage', os_version, true); const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version); - switch (true) { - case /^xdebug3$/.test(extension): - case /^8\.\d$/.test(version): - return '\n' + xdebug + '\n' + ini + '\n' + log; - case /^xdebug$/.test(extension): - default: - return xdebug + '\n' + log; - } + return [xdebug, ini, log].join('\n'); } exports.addCoverageXdebug = addCoverageXdebug; /** @@ -2968,6 +2961,9 @@ async function addExtensionWindows(extension_csv, version) { add_script += await utils.joins('\nAdd-Extension', ext_name, matches[2].replace('preview', 'devel'), matches[1]); break; // match 5.3pcov to 7.0pcov + case /7\.2xdebug/.test(version_extension): + add_script += '\nAdd-Extension xdebug stable 2.9.8'; + break; case /(5\.[3-6]|7\.0)pcov/.test(version_extension): add_script += await utils.getUnsupportedLog('pcov', version, 'win32'); break; @@ -3049,6 +3045,10 @@ async function addExtensionLinux(extension_csv, version) { add_script += '\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'; return; + // match 7.2xdebug + case /^7\.2xdebug$/.test(version_extension): + add_script += await utils.joins('\nadd_pecl_extension', ext_name, '2.9.8', ext_prefix); + break; // match 8.0xdebug3...8.9xdebug3 case /^8\.[0-9]xdebug3$/.test(version_extension): extension = 'xdebug'; diff --git a/src/coverage.ts b/src/coverage.ts index 690c0112..4cbfed09 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -30,14 +30,7 @@ export async function addCoverageXdebug( 'Xdebug enabled as coverage driver', os_version ); - switch (true) { - case /^xdebug3$/.test(extension): - case /^8\.\d$/.test(version): - return '\n' + xdebug + '\n' + ini + '\n' + log; - case /^xdebug$/.test(extension): - default: - return xdebug + '\n' + log; - } + return [xdebug, ini, log].join('\n'); } /** diff --git a/src/extensions.ts b/src/extensions.ts index bb6f9e39..17cdb847 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -164,6 +164,9 @@ export async function addExtensionWindows( ); break; // match 5.3pcov to 7.0pcov + case /7\.2xdebug/.test(version_extension): + add_script += '\nAdd-Extension xdebug stable 2.9.8'; + break; case /(5\.[3-6]|7\.0)pcov/.test(version_extension): add_script += await utils.getUnsupportedLog('pcov', version, 'win32'); break; @@ -269,6 +272,15 @@ export async function addExtensionLinux( add_script += '\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'; return; + // match 7.2xdebug + case /^7\.2xdebug$/.test(version_extension): + add_script += await utils.joins( + '\nadd_pecl_extension', + ext_name, + '2.9.8', + ext_prefix + ); + break; // match 8.0xdebug3...8.9xdebug3 case /^8\.[0-9]xdebug3$/.test(version_extension): extension = 'xdebug';