diff --git a/__tests__/coverage.test.ts b/__tests__/coverage.test.ts index 150a45c0..121d04c2 100644 --- a/__tests__/coverage.test.ts +++ b/__tests__/coverage.test.ts @@ -11,7 +11,10 @@ describe('Config tests', () => { let win32: string = await coverage.addCoverage('pcov', '7.4', 'win32'); expect(win32).toContain('addExtension pcov'); expect(win32).toContain( - 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php' + 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir' + ); + expect(win32).toContain( + 'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' ); win32 = await coverage.addCoverage('pcov', '7.0', 'win32'); @@ -24,13 +27,18 @@ describe('Config tests', () => { it('checking addCoverage with PCOV on linux', async () => { const linux: string = await coverage.addCoverage('pcov', '7.4', 'linux'); expect(linux).toContain('addExtension pcov'); - expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file'); + expect(linux).toContain('sudo sed -i "/xdebug/d" "$ini_file"'); expect(linux).toContain('sudo phpdismod -v 7.4 xdebug'); + expect(linux).toContain( + 'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug' + ); }); it('checking addCoverage with PCOV on darwin', async () => { const darwin: string = await coverage.addCoverage('pcov', '7.4', 'darwin'); expect(darwin).toContain('addExtension pcov'); + expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" "$ini_file"'); + expect(darwin).toContain('sudo rm -rf "$ext_dir"/xdebug.so'); }); it('checking addCoverage with Xdebug on windows', async () => { @@ -75,20 +83,31 @@ describe('Config tests', () => { const win32 = await coverage.addCoverage('none', '7.4', 'win32'); expect(win32).toContain('Disable-PhpExtension xdebug'); expect(win32).toContain('Disable-PhpExtension pcov'); + expect(win32).toContain( + 'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + ); + expect(win32).toContain( + 'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' + ); }); it('checking disableCoverage on linux', async () => { const linux: string = await coverage.addCoverage('none', '7.4', 'linux'); expect(linux).toContain('sudo phpdismod -v 7.4 xdebug'); expect(linux).toContain('sudo phpdismod -v 7.4 pcov'); - expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file'); - expect(linux).toContain('sudo sed -i "/pcov/d" $ini_file'); + expect(linux).toContain('sudo sed -i "/xdebug/d" "$ini_file"'); + expect(linux).toContain('sudo sed -i "/pcov/d" "$ini_file"'); + expect(linux).toContain( + 'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov' + ); }); it('checking disableCoverage on darwin', async () => { const darwin: string = await coverage.addCoverage('none', '7.4', 'darwin'); - expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file'); - expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" $ini_file'); + expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" "$ini_file"'); + expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" "$ini_file"'); + expect(darwin).toContain('sudo rm -rf "$ext_dir"/xdebug.so'); + expect(darwin).toContain('sudo rm -rf "$ext_dir"/pcov.so'); }); it('checking no or invalid coverage driver', async () => { diff --git a/dist/index.js b/dist/index.js index e943c162..f9d5c02d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1613,14 +1613,26 @@ function addCoveragePCOV(version, os_version) { '/mods-available/xdebug.ini ]; then sudo phpdismod -v ' + version + ' xdebug; fi\n'; - script += 'sudo sed -i "/xdebug/d" $ini_file\n'; + script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; + script += + 'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug -y ' + + (yield utils.suppressOutput('linux')) + + '\n'; break; case 'darwin': - script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n'; + script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; + script += + 'sudo rm -rf "$ext_dir"/xdebug.so ' + + (yield utils.suppressOutput('darwin')) + + '\n'; break; case 'win32': script += - 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n'; + 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; + script += + 'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + + (yield utils.suppressOutput('win32')) + + '\n'; break; } // success @@ -1659,18 +1671,38 @@ function disableCoverage(version, os_version) { '/mods-available/pcov.ini ]; then sudo phpdismod -v ' + version + ' pcov; fi\n'; - script += 'sudo sed -i "/xdebug/d" $ini_file\n'; - script += 'sudo sed -i "/pcov/d" $ini_file\n'; + script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; + script += 'sudo sed -i "/pcov/d" "$ini_file"\n'; + script += + 'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov -y ' + + (yield utils.suppressOutput('linux')) + + '\n'; break; case 'darwin': - script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n'; - script += 'sudo sed -i \'\' "/pcov/d" $ini_file\n'; + script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; + script += 'sudo sed -i \'\' "/pcov/d" "$ini_file"\n'; + script += + 'sudo rm -rf "$ext_dir"/xdebug.so ' + + (yield utils.suppressOutput('darwin')) + + '\n'; + script += + 'sudo rm -rf "$ext_dir"/pcov.so ' + + (yield utils.suppressOutput('darwin')) + + '\n'; break; case 'win32': script += - 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n'; + 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; script += - 'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n'; + 'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov $php_dir }\n'; + script += + 'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + + (yield utils.suppressOutput('win32')) + + '\n'; + script += + 'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' + + (yield utils.suppressOutput('win32')) + + '\n'; break; } script += yield utils.addLog('$tick', 'none', 'Disabled Xdebug and PCOV', os_version); diff --git a/package-lock.json b/package-lock.json index 83d564e9..7fef2da4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2287,12 +2287,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2307,17 +2309,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2434,7 +2439,8 @@ "inherits": { "version": "2.0.4", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2446,6 +2452,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2460,6 +2467,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2467,12 +2475,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.9.0", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2491,6 +2501,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2580,7 +2591,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2592,6 +2604,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2713,6 +2726,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/coverage.ts b/src/coverage.ts index 7528d854..4b6e0275 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -68,14 +68,26 @@ export async function addCoveragePCOV( '/mods-available/xdebug.ini ]; then sudo phpdismod -v ' + version + ' xdebug; fi\n'; - script += 'sudo sed -i "/xdebug/d" $ini_file\n'; + script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; + script += + 'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug -y ' + + (await utils.suppressOutput('linux')) + + '\n'; break; case 'darwin': - script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n'; + script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; + script += + 'sudo rm -rf "$ext_dir"/xdebug.so ' + + (await utils.suppressOutput('darwin')) + + '\n'; break; case 'win32': script += - 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n'; + 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; + script += + 'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + + (await utils.suppressOutput('win32')) + + '\n'; break; } @@ -127,18 +139,38 @@ export async function disableCoverage( '/mods-available/pcov.ini ]; then sudo phpdismod -v ' + version + ' pcov; fi\n'; - script += 'sudo sed -i "/xdebug/d" $ini_file\n'; - script += 'sudo sed -i "/pcov/d" $ini_file\n'; + script += 'sudo sed -i "/xdebug/d" "$ini_file"\n'; + script += 'sudo sed -i "/pcov/d" "$ini_file"\n'; + script += + 'sudo DEBIAN_FRONTEND=noninteractive apt-fast remove php-xdebug php-pcov -y ' + + (await utils.suppressOutput('linux')) + + '\n'; break; case 'darwin': - script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n'; - script += 'sudo sed -i \'\' "/pcov/d" $ini_file\n'; + script += 'sudo sed -i \'\' "/xdebug/d" "$ini_file"\n'; + script += 'sudo sed -i \'\' "/pcov/d" "$ini_file"\n'; + script += + 'sudo rm -rf "$ext_dir"/xdebug.so ' + + (await utils.suppressOutput('darwin')) + + '\n'; + script += + 'sudo rm -rf "$ext_dir"/pcov.so ' + + (await utils.suppressOutput('darwin')) + + '\n'; break; case 'win32': script += - 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n'; + 'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug $php_dir }\n'; script += - 'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n'; + 'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov $php_dir }\n'; + script += + 'if (Test-Path $ext_dir\\php_xdebug.dll) { Remove-Item $ext_dir\\php_xdebug.dll }' + + (await utils.suppressOutput('win32')) + + '\n'; + script += + 'if (Test-Path $ext_dir\\php_pcov.dll) { Remove-Item $ext_dir\\php_pcov.dll }' + + (await utils.suppressOutput('win32')) + + '\n'; break; } script += await utils.addLog(