mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Log error when wrong Xdebug version is requested
This commit is contained in:
parent
92b4784fb6
commit
b33066473d
@ -10,14 +10,15 @@ describe('Config tests', () => {
|
||||
${'pcov'} | ${'7.4'} | ${'linux'} | ${'add_extension pcov,disable_extension xdebug false'}
|
||||
${'pcov'} | ${'7.4'} | ${'darwin'} | ${'add_brew_extension pcov,disable_extension xdebug false'}
|
||||
${'xdebug'} | ${'7.4'} | ${'win32'} | ${'Add-Extension xdebug'}
|
||||
${'xdebug3'} | ${'7.4'} | ${'win32'} | ${'Add-Extension xdebug'}
|
||||
${'xdebug3'} | ${'7.1'} | ${'win32'} | ${'xdebug3 is not supported on PHP 7.1'}
|
||||
${'xdebug2'} | ${'7.4'} | ${'win32'} | ${'Add-Extension xdebug stable 2.9.8'}
|
||||
${'xdebug'} | ${'8.0'} | ${'linux'} | ${'add_extension xdebug'}
|
||||
${'xdebug3'} | ${'8.0'} | ${'linux'} | ${'add_extension xdebug'}
|
||||
${'xdebug2'} | ${'7.4'} | ${'linux'} | ${'add_pecl_extension xdebug 2.9.8 zend_extension'}
|
||||
${'xdebug'} | ${'7.4'} | ${'darwin'} | ${'add_brew_extension xdebug'}
|
||||
${'xdebug3'} | ${'7.4'} | ${'darwin'} | ${'add_brew_extension xdebug'}
|
||||
${'xdebug3'} | ${'7.1'} | ${'darwin'} | ${'xdebug3 is not supported on PHP 7.1'}
|
||||
${'xdebug2'} | ${'7.4'} | ${'darwin'} | ${'add_brew_extension xdebug2'}
|
||||
${'xdebug2'} | ${'8.0'} | ${'darwin'} | ${'xdebug2 is not supported on PHP 8.0'}
|
||||
${'none'} | ${'7.4'} | ${'win32'} | ${'Disable-Extension xdebug false,Disable-Extension pcov false'}
|
||||
${'none'} | ${'7.4'} | ${'linux'} | ${'disable_extension xdebug false,disable_extension pcov false'}
|
||||
${'none'} | ${'7.4'} | ${'darwin'} | ${'disable_extension xdebug false,disable_extension pcov false'}
|
||||
|
36
dist/index.js
vendored
36
dist/index.js
vendored
@ -104,19 +104,33 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.addCoverage = exports.disableCoverage = exports.addCoveragePCOV = exports.addCoverageXdebug = void 0;
|
||||
exports.addCoverage = exports.disableCoverage = exports.addCoveragePCOV = exports.addCoverageXdebug = exports.checkXdebugError = void 0;
|
||||
const utils = __importStar(__nccwpck_require__(918));
|
||||
const extensions = __importStar(__nccwpck_require__(390));
|
||||
const config = __importStar(__nccwpck_require__(88));
|
||||
async function checkXdebugError(extension, version) {
|
||||
if ((/^5\.[3-6]$|^7\.[0-1]$/.test(version) && extension == 'xdebug3') ||
|
||||
(/^8\.[0-9]$/.test(version) && extension == 'xdebug2')) {
|
||||
return extension + ' is not supported on PHP ' + version;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
exports.checkXdebugError = checkXdebugError;
|
||||
async function addCoverageXdebug(extension, version, os_version, pipe) {
|
||||
let script = '\n';
|
||||
script +=
|
||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) +
|
||||
pipe;
|
||||
script +=
|
||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
||||
pipe;
|
||||
script += await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version);
|
||||
let message = await checkXdebugError(extension, version);
|
||||
let status = '$cross';
|
||||
if (!message) {
|
||||
script +=
|
||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) + pipe;
|
||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||
script +=
|
||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
||||
pipe;
|
||||
message = 'Xdebug enabled as coverage driver';
|
||||
status = '$tick';
|
||||
}
|
||||
script += await utils.addLog(status, extension, message, os_version);
|
||||
return script;
|
||||
}
|
||||
exports.addCoverageXdebug = addCoverageXdebug;
|
||||
@ -159,10 +173,10 @@ async function addCoverage(coverage_driver, version, os_version) {
|
||||
case 'pcov':
|
||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
||||
case 'xdebug':
|
||||
case 'xdebug3':
|
||||
return (script + (await addCoverageXdebug('xdebug', version, os_version, pipe)));
|
||||
case 'xdebug2':
|
||||
return (script + (await addCoverageXdebug('xdebug2', version, os_version, pipe)));
|
||||
case 'xdebug3':
|
||||
return (script +
|
||||
(await addCoverageXdebug(coverage_driver, version, os_version, pipe)));
|
||||
case 'none':
|
||||
return script + (await disableCoverage(version, os_version, pipe));
|
||||
default:
|
||||
|
@ -2,6 +2,19 @@ import * as utils from './utils';
|
||||
import * as extensions from './extensions';
|
||||
import * as config from './config';
|
||||
|
||||
export async function checkXdebugError(
|
||||
extension: string,
|
||||
version: string
|
||||
): Promise<string> {
|
||||
if (
|
||||
(/^5\.[3-6]$|^7\.[0-1]$/.test(version) && extension == 'xdebug3') ||
|
||||
(/^8\.[0-9]$/.test(version) && extension == 'xdebug2')
|
||||
) {
|
||||
return extension + ' is not supported on PHP ' + version;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to setup Xdebug
|
||||
*
|
||||
@ -17,18 +30,24 @@ export async function addCoverageXdebug(
|
||||
pipe: string
|
||||
): Promise<string> {
|
||||
let script = '\n';
|
||||
script +=
|
||||
(await extensions.addExtension(':pcov:false', version, os_version, true)) +
|
||||
pipe;
|
||||
script +=
|
||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
||||
pipe;
|
||||
script += await utils.addLog(
|
||||
'$tick',
|
||||
extension,
|
||||
'Xdebug enabled as coverage driver',
|
||||
os_version
|
||||
);
|
||||
let message: string = await checkXdebugError(extension, version);
|
||||
let status = '$cross';
|
||||
if (!message) {
|
||||
script +=
|
||||
(await extensions.addExtension(
|
||||
':pcov:false',
|
||||
version,
|
||||
os_version,
|
||||
true
|
||||
)) + pipe;
|
||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||
script +=
|
||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
||||
pipe;
|
||||
message = 'Xdebug enabled as coverage driver';
|
||||
status = '$tick';
|
||||
}
|
||||
script += await utils.addLog(status, extension, message, os_version);
|
||||
return script;
|
||||
}
|
||||
|
||||
@ -136,13 +155,11 @@ export async function addCoverage(
|
||||
case 'pcov':
|
||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
||||
case 'xdebug':
|
||||
case 'xdebug2':
|
||||
case 'xdebug3':
|
||||
return (
|
||||
script + (await addCoverageXdebug('xdebug', version, os_version, pipe))
|
||||
);
|
||||
case 'xdebug2':
|
||||
return (
|
||||
script + (await addCoverageXdebug('xdebug2', version, os_version, pipe))
|
||||
script +
|
||||
(await addCoverageXdebug(coverage_driver, version, os_version, pipe))
|
||||
);
|
||||
case 'none':
|
||||
return script + (await disableCoverage(version, os_version, pipe));
|
||||
|
Loading…
Reference in New Issue
Block a user