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 () => { it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux'); 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 () => { 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 * @param pipe
*/ */
async function addCoverageXdebug(version, os_version, pipe) { async function addCoverageXdebug(version, os_version, pipe) {
switch (version) { const xdebug = (await extensions.addExtension('xdebug', version, os_version, true)) + pipe;
case '8.0': const ini = await config.addINIValues('xdebug.mode=coverage', os_version, true);
return ('\n' + const log = await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version);
(await utils.addLog('$cross', 'xdebug', 'Xdebug currently only supports PHP 7.4 or lower', os_version))); switch (true) {
case '7.4': case /8.[0-9]/.test(version):
return xdebug + '\n' + ini + '\n' + log;
case /5\.[3-6]|7.[0-4]/.test(version):
default: default:
return ((await extensions.addExtension('xdebug', version, os_version, true)) + return xdebug + '\n' + log;
pipe +
'\n' +
(await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
} }
} }
exports.addCoverageXdebug = addCoverageXdebug; exports.addCoverageXdebug = addCoverageXdebug;

View File

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