Fix Xdebug coverage

This commit is contained in:
Shivam Mathur 2020-06-19 14:47:34 +05:30
parent fe504c5e23
commit 6b93e48d83
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
3 changed files with 28 additions and 33 deletions

View File

@ -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 () => {

17
dist/index.js vendored
View File

@ -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;

View File

@ -14,30 +14,25 @@ export async function addCoverageXdebug(
os_version: string,
pipe: string
): Promise<string> {
switch (version) {
case '8.0':
return (
'\n' +
(await utils.addLog(
'$cross',
'xdebug',
'Xdebug currently only supports PHP 7.4 or lower',
os_version
))
const xdebug =
(await extensions.addExtension('xdebug', version, os_version, true)) + pipe;
const ini = await config.addINIValues(
'xdebug.mode=coverage',
os_version,
true
);
case '7.4':
default:
return (
(await extensions.addExtension('xdebug', version, os_version, true)) +
pipe +
'\n' +
(await utils.addLog(
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;
}
}