Fix coverage

This commit is contained in:
Shivam Mathur 2021-03-23 06:50:05 +05:30
parent e6a3eb1258
commit 62aa8428dd
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
2 changed files with 34 additions and 56 deletions

44
dist/index.js vendored
View File

@ -1677,10 +1677,14 @@ const config = __importStar(__nccwpck_require__(373));
* @param pipe * @param pipe
*/ */
async function addCoverageXdebug(extension, version, os_version, pipe) { async function addCoverageXdebug(extension, version, os_version, pipe) {
const xdebug = (await extensions.addExtension(extension, version, os_version, true)) + let script = '\n';
script +=
(await extensions.addExtension(':pcov', version, os_version, true)) + pipe;
script +=
(await extensions.addExtension(extension, version, os_version, true)) +
pipe; pipe;
const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version); script += await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version);
return xdebug + '\n' + log; return script;
} }
exports.addCoverageXdebug = addCoverageXdebug; exports.addCoverageXdebug = addCoverageXdebug;
/** /**
@ -1694,22 +1698,14 @@ async function addCoveragePCOV(version, os_version, pipe) {
let script = '\n'; let script = '\n';
switch (true) { switch (true) {
default: default:
script +=
(await extensions.addExtension(':xdebug', version, os_version, true)) +
pipe;
script += script +=
(await extensions.addExtension('pcov', version, os_version, true)) + (await extensions.addExtension('pcov', version, os_version, true)) +
pipe + pipe;
'\n';
script += script +=
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; (await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
// add command to disable xdebug and enable pcov
switch (os_version) {
case 'linux':
case 'darwin':
script += 'remove_extension xdebug' + pipe + '\n';
break;
case 'win32':
script += 'Remove-Extension xdebug' + pipe + '\n';
break;
}
// success // success
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version); script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os_version);
// version is not supported // version is not supported
@ -1730,17 +1726,11 @@ exports.addCoveragePCOV = addCoveragePCOV;
*/ */
async function disableCoverage(version, os_version, pipe) { async function disableCoverage(version, os_version, pipe) {
let script = '\n'; let script = '\n';
switch (os_version) { script +=
case 'linux': (await extensions.addExtension(':pcov', version, os_version, true)) + pipe;
case 'darwin': script +=
script += 'remove_extension xdebug' + pipe + '\n'; (await extensions.addExtension(':xdebug', version, os_version, true)) +
script += 'remove_extension pcov' + pipe + '\n'; pipe;
break;
case 'win32':
script += 'Remove-Extension xdebug' + pipe + '\n';
script += 'Remove-Extension pcov' + pipe + '\n';
break;
}
script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version); script += await utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version);
return script; return script;
} }
@ -1755,7 +1745,7 @@ exports.disableCoverage = disableCoverage;
async function addCoverage(coverage_driver, version, os_version) { async function addCoverage(coverage_driver, version, os_version) {
coverage_driver = coverage_driver.toLowerCase(); coverage_driver = coverage_driver.toLowerCase();
const script = '\n' + (await utils.stepLog('Setup Coverage', os_version)); const script = '\n' + (await utils.stepLog('Setup Coverage', os_version));
const pipe = await utils.suppressOutput(os_version); const pipe = (await utils.suppressOutput(os_version)) + '\n';
switch (coverage_driver) { switch (coverage_driver) {
case 'pcov': case 'pcov':
return script + (await addCoveragePCOV(version, os_version, pipe)); return script + (await addCoveragePCOV(version, os_version, pipe));

View File

@ -16,16 +16,19 @@ export async function addCoverageXdebug(
os_version: string, os_version: string,
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
const xdebug = let script = '\n';
script +=
(await extensions.addExtension(':pcov', version, os_version, true)) + pipe;
script +=
(await extensions.addExtension(extension, version, os_version, true)) + (await extensions.addExtension(extension, version, os_version, true)) +
pipe; pipe;
const log = await utils.addLog( script += await utils.addLog(
'$tick', '$tick',
extension, extension,
'Xdebug enabled as coverage driver', 'Xdebug enabled as coverage driver',
os_version os_version
); );
return xdebug + '\n' + log; return script;
} }
/** /**
@ -43,24 +46,15 @@ export async function addCoveragePCOV(
let script = '\n'; let script = '\n';
switch (true) { switch (true) {
default: default:
script +=
(await extensions.addExtension(':xdebug', version, os_version, true)) +
pipe;
script += script +=
(await extensions.addExtension('pcov', version, os_version, true)) + (await extensions.addExtension('pcov', version, os_version, true)) +
pipe + pipe;
'\n';
script += script +=
(await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n'; (await config.addINIValues('pcov.enabled=1', os_version, true)) + '\n';
// add command to disable xdebug and enable pcov
switch (os_version) {
case 'linux':
case 'darwin':
script += 'remove_extension xdebug' + pipe + '\n';
break;
case 'win32':
script += 'Remove-Extension xdebug' + pipe + '\n';
break;
}
// success // success
script += await utils.addLog( script += await utils.addLog(
'$tick', '$tick',
@ -97,17 +91,11 @@ export async function disableCoverage(
pipe: string pipe: string
): Promise<string> { ): Promise<string> {
let script = '\n'; let script = '\n';
switch (os_version) { script +=
case 'linux': (await extensions.addExtension(':pcov', version, os_version, true)) + pipe;
case 'darwin': script +=
script += 'remove_extension xdebug' + pipe + '\n'; (await extensions.addExtension(':xdebug', version, os_version, true)) +
script += 'remove_extension pcov' + pipe + '\n'; pipe;
break;
case 'win32':
script += 'Remove-Extension xdebug' + pipe + '\n';
script += 'Remove-Extension pcov' + pipe + '\n';
break;
}
script += await utils.addLog( script += await utils.addLog(
'$tick', '$tick',
'none', 'none',
@ -133,7 +121,7 @@ export async function addCoverage(
coverage_driver = coverage_driver.toLowerCase(); coverage_driver = coverage_driver.toLowerCase();
const script: string = const script: string =
'\n' + (await utils.stepLog('Setup Coverage', os_version)); '\n' + (await utils.stepLog('Setup Coverage', os_version));
const pipe: string = await utils.suppressOutput(os_version); const pipe: string = (await utils.suppressOutput(os_version)) + '\n';
switch (coverage_driver) { switch (coverage_driver) {
case 'pcov': case 'pcov':
return script + (await addCoveragePCOV(version, os_version, pipe)); return script + (await addCoveragePCOV(version, os_version, pipe));