Skip to content

Commit

Permalink
Fix xdebug setup
Browse files Browse the repository at this point in the history
Co-authored-by: Owen Voke <development@voke.dev>
Co-authored-by: Shivam Mathur <shivam_jpr@hotmail.com>
  • Loading branch information
shivammathur and owenvoke committed Nov 27, 2020
1 parent 790a41a commit 5a40a58
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
2 changes: 2 additions & 0 deletions __tests__/coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
6 changes: 6 additions & 0 deletions __tests__/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');

Expand Down
16 changes: 8 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand Down
9 changes: 1 addition & 8 deletions src/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down
12 changes: 12 additions & 0 deletions src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 5a40a58

Please sign in to comment.