From 46b357b6c27ea59b06f86811bd6ee1d0a716fe46 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 26 Nov 2020 23:50:49 +0530 Subject: [PATCH] Setup Xdebug 2.9.8 on PHP 7.2 --- __tests__/extensions.test.ts | 6 ++++++ __tests__/utils.test.ts | 23 ++++++++++++----------- dist/index.js | 16 +++++++++------- src/coverage.ts | 8 +------- src/extensions.ts | 8 ++++++++ 5 files changed, 36 insertions(+), 25 deletions(-) diff --git a/__tests__/extensions.test.ts b/__tests__/extensions.test.ts index 6bb00eb0..450c3412 100644 --- a/__tests__/extensions.test.ts +++ b/__tests__/extensions.test.ts @@ -13,6 +13,9 @@ describe('Extension tests', () => { expect(win32).toContain('phalcon.ps1 phalcon4'); expect(win32).toContain('Add-Extension ast beta'); + 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'); @@ -68,6 +71,9 @@ describe('Extension tests', () => { linux = await extensions.addExtension('gearman', '7.4', 'linux'); expect(linux).toContain('gearman.sh 7.4'); + 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/__tests__/utils.test.ts b/__tests__/utils.test.ts index 908b8d08..3008d38c 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -35,11 +35,12 @@ describe('Utils tests', () => { it('checking asyncForEach', async () => { const array: Array = ['a', 'b', 'c']; let concat = ''; - await utils.asyncForEach(array, async function ( - str: string - ): Promise { - concat += str; - }); + await utils.asyncForEach( + array, + async function (str: string): Promise { + concat += str; + } + ); expect(concat).toBe('abc'); }); @@ -76,12 +77,12 @@ describe('Utils tests', () => { const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || ''; const script_path: string = path.join(runner_dir, 'test.sh'); await utils.writeScript('test.sh', testString); - await fs.readFile(script_path, function ( - error: Error | null, - data: Buffer - ) { - expect(testString).toBe(data.toString()); - }); + await fs.readFile( + script_path, + function (error: Error | null, data: Buffer) { + expect(testString).toBe(data.toString()); + } + ); await cleanup(script_path); }); diff --git a/dist/index.js b/dist/index.js index 81df151b..d6b01187 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2152,13 +2152,7 @@ async function addCoverageXdebug(version, os_version, pipe) { 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 xdebug + '\n' + log; - } + return xdebug + '\n' + ini + '\n' + log; } exports.addCoverageXdebug = addCoverageXdebug; /** @@ -2791,6 +2785,10 @@ async function addExtensionWindows(extension_csv, version) { script += '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; break; + // match 7.2xdebug + case /7\.2xdebug/.test(version_extension): + script += '\nAdd-Extension xdebug stable 2.9.8'; + break; // match 7.0mysql..8.0mysql // match 7.0mysqli..8.0mysqli // match 7.0mysqlnd..8.0mysqlnd @@ -2867,6 +2865,10 @@ async function addExtensionLinux(extension_csv, version, pipe) { ' ' + version; return; + // match 7.2xdebug + case /^7\.2xdebug$/.test(version_extension): + script += '\nadd_pecl_extension xdebug 2.9.8 ' + ext_prefix; + return; // match sqlite case /^sqlite$/.test(extension): extension = 'sqlite3'; diff --git a/src/coverage.ts b/src/coverage.ts index 49e6bfea..60a7043f 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -27,13 +27,7 @@ export async function addCoverageXdebug( '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 xdebug + '\n' + log; - } + return xdebug + '\n' + ini + '\n' + log; } /** diff --git a/src/extensions.ts b/src/extensions.ts index 960b1c56..95d4e2ed 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -99,6 +99,10 @@ export async function addExtensionWindows( script += '\nAdd-Extension mysql\nAdd-Extension mysqli\nAdd-Extension mysqlnd'; break; + // match 7.2xdebug + case /7\.2xdebug/.test(version_extension): + script += '\nAdd-Extension xdebug stable 2.9.8'; + break; // match 7.0mysql..8.0mysql // match 7.0mysqli..8.0mysqli // match 7.0mysqlnd..8.0mysqlnd @@ -179,6 +183,10 @@ export async function addExtensionLinux( ' ' + version; return; + // match 7.2xdebug + case /^7\.2xdebug$/.test(version_extension): + script += '\nadd_pecl_extension xdebug 2.9.8 ' + ext_prefix; + return; // match sqlite case /^sqlite$/.test(extension): extension = 'sqlite3';