mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Add coverage driver version in logs
This commit is contained in:
parent
3fda17f3fa
commit
050cb8061b
@ -4,6 +4,8 @@ describe('Config tests', () => {
|
||||
it.each`
|
||||
driver | php | os | output
|
||||
${'PCOV'} | ${'7.4'} | ${'win32'} | ${'Add-Extension pcov,Disable-Extension xdebug false'}
|
||||
${'pcov'} | ${'7.4'} | ${'win32'} | ${'$pcov_version = php -r "echo phpversion(\'pcov\');"'}
|
||||
${'pcov'} | ${'7.4'} | ${'win32'} | ${'PCOV $pcov_version enabled as coverage driver'}
|
||||
${'pcov'} | ${'7.0'} | ${'win32'} | ${'PHP 7.1 or newer is required'}
|
||||
${'pcov'} | ${'5.6'} | ${'win32'} | ${'PHP 7.1 or newer is required'}
|
||||
${'pcov'} | ${'7.4'} | ${'win32'} | ${'Add-Extension pcov,Disable-Extension xdebug false'}
|
||||
@ -15,6 +17,8 @@ describe('Config tests', () => {
|
||||
${'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'} | ${'linux'} | ${'xdebug_version="$(php -r "echo phpversion(\'xdebug\');")"'}
|
||||
${'xdebug'} | ${'7.4'} | ${'linux'} | ${'Xdebug $xdebug_version enabled as coverage driver'}
|
||||
${'xdebug'} | ${'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'}
|
||||
|
@ -256,4 +256,13 @@ describe('Utils tests', () => {
|
||||
'\nadd_extension_from_source ext https://sub.domain.XN--tld org repo release extension'
|
||||
);
|
||||
});
|
||||
|
||||
it('checking setVariable', async () => {
|
||||
let script: string = await utils.setVariable('var', 'command', 'linux');
|
||||
expect(script).toEqual('\nvar="$(command)"\n');
|
||||
script = await utils.setVariable('var', 'command', 'darwin');
|
||||
expect(script).toEqual('\nvar="$(command)"\n');
|
||||
script = await utils.setVariable('var', 'command', 'win32');
|
||||
expect(script).toEqual('\n$var = command\n');
|
||||
});
|
||||
});
|
||||
|
19
dist/index.js
vendored
19
dist/index.js
vendored
@ -135,7 +135,8 @@ async function addCoverageXdebug(extension, version, os, pipe) {
|
||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||
script +=
|
||||
(await extensions.addExtension(extension, version, os, true)) + pipe;
|
||||
message = 'Xdebug enabled as coverage driver';
|
||||
script += await utils.setVariable('xdebug_version', 'php -r "echo phpversion(\'xdebug\');"', os);
|
||||
message = 'Xdebug $xdebug_version enabled as coverage driver';
|
||||
status = '$tick';
|
||||
}
|
||||
script += await utils.addLog(status, extension, message, os);
|
||||
@ -152,7 +153,8 @@ async function addCoveragePCOV(version, os, pipe) {
|
||||
script +=
|
||||
(await extensions.addExtension('pcov', version, os, true)) + pipe;
|
||||
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
|
||||
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV enabled as coverage driver', os);
|
||||
script += await utils.setVariable('pcov_version', 'php -r "echo phpversion(\'pcov\');"', os);
|
||||
script += await utils.addLog('$tick', 'coverage: pcov', 'PCOV $pcov_version enabled as coverage driver', os);
|
||||
break;
|
||||
case /5\.[3-6]|7\.0/.test(version):
|
||||
script += await utils.addLog('$cross', 'pcov', 'PHP 7.1 or newer is required', os);
|
||||
@ -1013,7 +1015,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.parseExtensionSource = exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseIniFile = exports.parseVersion = exports.getManifestURL = exports.getInput = exports.readEnv = void 0;
|
||||
exports.setVariable = exports.parseExtensionSource = exports.customPackage = exports.scriptTool = exports.scriptExtension = exports.joins = exports.getCommand = exports.getUnsupportedLog = exports.suppressOutput = exports.getExtensionPrefix = exports.CSVArray = exports.extensionArray = exports.addLog = exports.stepLog = exports.log = exports.color = exports.asyncForEach = exports.parseIniFile = exports.parseVersion = exports.getManifestURL = exports.getInput = exports.readEnv = void 0;
|
||||
const path = __importStar(__nccwpck_require__(17));
|
||||
const core = __importStar(__nccwpck_require__(186));
|
||||
const fetch = __importStar(__nccwpck_require__(387));
|
||||
@ -1253,6 +1255,17 @@ async function parseExtensionSource(extension, prefix) {
|
||||
return await joins('\nadd_extension_from_source', ...matches.splice(1, matches.length), prefix);
|
||||
}
|
||||
exports.parseExtensionSource = parseExtensionSource;
|
||||
async function setVariable(variable, command, os) {
|
||||
switch (os) {
|
||||
case 'win32':
|
||||
return '\n$' + variable + ' = ' + command + '\n';
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
default:
|
||||
return '\n' + variable + '="$(' + command + ')"\n';
|
||||
}
|
||||
}
|
||||
exports.setVariable = setVariable;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
|
||||
/***/ }),
|
||||
|
@ -38,7 +38,12 @@ export async function addCoverageXdebug(
|
||||
extension = extension == 'xdebug3' ? 'xdebug' : extension;
|
||||
script +=
|
||||
(await extensions.addExtension(extension, version, os, true)) + pipe;
|
||||
message = 'Xdebug enabled as coverage driver';
|
||||
script += await utils.setVariable(
|
||||
'xdebug_version',
|
||||
'php -r "echo phpversion(\'xdebug\');"',
|
||||
os
|
||||
);
|
||||
message = 'Xdebug $xdebug_version enabled as coverage driver';
|
||||
status = '$tick';
|
||||
}
|
||||
script += await utils.addLog(status, extension, message, os);
|
||||
@ -66,12 +71,16 @@ export async function addCoveragePCOV(
|
||||
script +=
|
||||
(await extensions.addExtension('pcov', version, os, true)) + pipe;
|
||||
script += (await config.addINIValues('pcov.enabled=1', os, true)) + '\n';
|
||||
|
||||
script += await utils.setVariable(
|
||||
'pcov_version',
|
||||
'php -r "echo phpversion(\'pcov\');"',
|
||||
os
|
||||
);
|
||||
// success
|
||||
script += await utils.addLog(
|
||||
'$tick',
|
||||
'coverage: pcov',
|
||||
'PCOV enabled as coverage driver',
|
||||
'PCOV $pcov_version enabled as coverage driver',
|
||||
os
|
||||
);
|
||||
// version is not supported
|
||||
|
23
src/utils.ts
23
src/utils.ts
@ -413,3 +413,26 @@ export async function parseExtensionSource(
|
||||
prefix
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log to console
|
||||
*
|
||||
* @param variable
|
||||
* @param command
|
||||
* @param os
|
||||
*/
|
||||
export async function setVariable(
|
||||
variable: string,
|
||||
command: string,
|
||||
os: string
|
||||
): Promise<string> {
|
||||
switch (os) {
|
||||
case 'win32':
|
||||
return '\n$' + variable + ' = ' + command + '\n';
|
||||
|
||||
case 'linux':
|
||||
case 'darwin':
|
||||
default:
|
||||
return '\n' + variable + '="$(' + command + ')"\n';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user