mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 11:51:07 +07:00
Add support for Xdebug3 on stable PHP
This commit is contained in:
parent
b9404683e1
commit
52691651dc
@ -1,15 +1,9 @@
|
||||
import * as coverage from '../src/coverage';
|
||||
|
||||
jest.mock('../src/extensions', () => ({
|
||||
addExtension: jest.fn().mockImplementation(extension => {
|
||||
return 'add_extension ' + extension + '\n';
|
||||
})
|
||||
}));
|
||||
|
||||
describe('Config tests', () => {
|
||||
it('checking addCoverage with PCOV on windows', async () => {
|
||||
let win32: string = await coverage.addCoverage('PCOV', '7.4', 'win32');
|
||||
expect(win32).toContain('add_extension pcov');
|
||||
expect(win32).toContain('Add-Extension pcov');
|
||||
expect(win32).toContain('Remove-Extension xdebug');
|
||||
|
||||
win32 = await coverage.addCoverage('pcov', '7.0', 'win32');
|
||||
@ -33,14 +27,26 @@ describe('Config tests', () => {
|
||||
|
||||
it('checking addCoverage with Xdebug on windows', async () => {
|
||||
const win32: string = await coverage.addCoverage('xdebug', '7.4', 'win32');
|
||||
expect(win32).toContain('add_extension xdebug');
|
||||
expect(win32).toContain('Add-Extension xdebug');
|
||||
});
|
||||
|
||||
it('checking addCoverage with Xdebug on linux', async () => {
|
||||
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
|
||||
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
|
||||
expect(linux).toContain('add_extension xdebug');
|
||||
});
|
||||
|
||||
it('checking addCoverage with Xdebug3 on linux', async () => {
|
||||
const linux: string = await coverage.addCoverage('xdebug3', '7.4', 'linux');
|
||||
expect(linux).toContain('add_extension_from_source xdebug');
|
||||
expect(linux).toContain('echo "xdebug.mode=coverage"');
|
||||
});
|
||||
|
||||
it('checking addCoverage with Xdebug3 on linux', async () => {
|
||||
const linux: string = await coverage.addCoverage('xdebug3', '8.0', 'linux');
|
||||
expect(linux).toContain('add_extension xdebug');
|
||||
expect(linux).toContain('echo "xdebug.mode=coverage"');
|
||||
});
|
||||
|
||||
it('checking addCoverage with Xdebug on darwin', async () => {
|
||||
const darwin: string = await coverage.addCoverage(
|
||||
'xdebug',
|
||||
|
@ -56,11 +56,14 @@ describe('Extension tests', () => {
|
||||
|
||||
it('checking addExtensionOnLinux', async () => {
|
||||
let linux: string = await extensions.addExtension(
|
||||
'Xdebug, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||
'Xdebug, xdebug3, pcov, sqlite, :intl, ast, uopz, ast-beta, pdo_mysql, pdo-odbc, xdebug-alpha, grpc-1.2.3',
|
||||
'7.4',
|
||||
'linux'
|
||||
);
|
||||
expect(linux).toContain('update_extension xdebug 2.9.3');
|
||||
expect(linux).toContain('update_extension xdebug 2.9.6');
|
||||
expect(linux).toContain(
|
||||
'add_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension'
|
||||
);
|
||||
expect(linux).toContain('sudo $debconf_fix apt-get install -y php7.4-pcov');
|
||||
expect(linux).toContain(
|
||||
'sudo $debconf_fix apt-get install -y php7.4-sqlite3'
|
||||
@ -76,6 +79,11 @@ describe('Extension tests', () => {
|
||||
'add_unstable_extension xdebug alpha zend_extension'
|
||||
);
|
||||
|
||||
linux = await extensions.addExtension('xdebug3', '8.0', 'linux');
|
||||
expect(linux).toContain(
|
||||
'sudo $debconf_fix apt-get install -y php8.0-xdebug'
|
||||
);
|
||||
|
||||
linux = await extensions.addExtension('gearman', '7.0', 'linux');
|
||||
expect(linux).toContain('gearman.sh 7.0');
|
||||
linux = await extensions.addExtension('gearman', '7.1', 'linux');
|
||||
|
@ -155,6 +155,7 @@ describe('Utils tests', () => {
|
||||
);
|
||||
expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
|
||||
expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
|
||||
expect(await utils.getExtensionPrefix('xdebug3')).toEqual('zend_extension');
|
||||
expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
|
||||
});
|
||||
|
||||
|
52
dist/index.js
vendored
52
dist/index.js
vendored
@ -1218,13 +1218,17 @@ exports.CSVArray = CSVArray;
|
||||
* @param extension
|
||||
*/
|
||||
async function getExtensionPrefix(extension) {
|
||||
const zend = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||
const zend = [
|
||||
'xdebug',
|
||||
'xdebug3',
|
||||
'opcache',
|
||||
'ioncube',
|
||||
'eaccelerator'
|
||||
];
|
||||
switch (zend.indexOf(extension)) {
|
||||
case 0:
|
||||
case 1:
|
||||
default:
|
||||
return 'zend_extension';
|
||||
case -1:
|
||||
default:
|
||||
return 'extension';
|
||||
}
|
||||
}
|
||||
@ -2142,18 +2146,24 @@ const config = __importStar(__webpack_require__(641));
|
||||
/**
|
||||
* Function to setup Xdebug
|
||||
*
|
||||
* @param extension
|
||||
* @param version
|
||||
* @param os_version
|
||||
* @param pipe
|
||||
*/
|
||||
async function addCoverageXdebug(version, os_version, pipe) {
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
async function addCoverageXdebug(extension, version, os_version, pipe) {
|
||||
const xdebug = (await extensions.addExtension(extension, version, os_version, true)) +
|
||||
pipe;
|
||||
const ini = (await config.addINIValues('xdebug.mode=coverage', os_version, true)) +
|
||||
pipe;
|
||||
const log = await utils.addLog('$tick', extension, 'Xdebug enabled as coverage driver', os_version);
|
||||
switch (true) {
|
||||
case /^xdebug3$/.test(extension):
|
||||
case /^8\.0$/.test(version):
|
||||
return '\n' + xdebug + '\n' + ini + '\n' + log;
|
||||
case /^xdebug$/.test(extension):
|
||||
default:
|
||||
return ((await extensions.addExtension('xdebug', version, os_version, true)) +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
|
||||
return '\n' + xdebug + '\n' + log;
|
||||
}
|
||||
}
|
||||
exports.addCoverageXdebug = addCoverageXdebug;
|
||||
@ -2234,7 +2244,9 @@ async function addCoverage(coverage_driver, version, os_version) {
|
||||
case 'pcov':
|
||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
||||
case 'xdebug':
|
||||
return script + (await addCoverageXdebug(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:
|
||||
@ -2280,10 +2292,10 @@ const utils = __importStar(__webpack_require__(163));
|
||||
*/
|
||||
async function addINIValuesUnix(ini_values_csv) {
|
||||
const ini_values = await utils.CSVArray(ini_values_csv);
|
||||
let script = '\n';
|
||||
let script = '';
|
||||
await utils.asyncForEach(ini_values, async function (line) {
|
||||
script +=
|
||||
(await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
|
||||
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
||||
});
|
||||
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||
}
|
||||
@ -2961,10 +2973,20 @@ async function addExtensionLinux(extension_csv, version, pipe) {
|
||||
' ' +
|
||||
version;
|
||||
return;
|
||||
// match 7.2xdebug3..7.4xdebug3
|
||||
case /^7\.[2-4]xdebug3$/.test(version_extension):
|
||||
add_script +=
|
||||
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
|
||||
return;
|
||||
// match 8.0xdebug3
|
||||
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
||||
extension = 'xdebug';
|
||||
command = command_prefix + version + '-' + extension + pipe;
|
||||
break;
|
||||
// match 7.1xdebug..7.4xdebug
|
||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||
add_script +=
|
||||
'\nupdate_extension xdebug 2.9.3' +
|
||||
'\nupdate_extension xdebug 2.9.6' +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||
|
@ -9,10 +9,10 @@ export async function addINIValuesUnix(
|
||||
ini_values_csv: string
|
||||
): Promise<string> {
|
||||
const ini_values: Array<string> = await utils.CSVArray(ini_values_csv);
|
||||
let script = '\n';
|
||||
let script = '';
|
||||
await utils.asyncForEach(ini_values, async function (line: string) {
|
||||
script +=
|
||||
(await utils.addLog('$tick', line, 'Added to php.ini', 'linux')) + '\n';
|
||||
'\n' + (await utils.addLog('$tick', line, 'Added to php.ini', 'linux'));
|
||||
});
|
||||
return 'echo "' + ini_values.join('\n') + '" >> $ini_file' + script;
|
||||
}
|
||||
|
@ -5,29 +5,36 @@ import * as config from './config';
|
||||
/**
|
||||
* Function to setup Xdebug
|
||||
*
|
||||
* @param extension
|
||||
* @param version
|
||||
* @param os_version
|
||||
* @param pipe
|
||||
*/
|
||||
export async function addCoverageXdebug(
|
||||
extension: string,
|
||||
version: string,
|
||||
os_version: string,
|
||||
pipe: string
|
||||
): Promise<string> {
|
||||
switch (version) {
|
||||
case '7.4':
|
||||
const xdebug =
|
||||
(await extensions.addExtension(extension, version, os_version, true)) +
|
||||
pipe;
|
||||
const ini =
|
||||
(await config.addINIValues('xdebug.mode=coverage', os_version, true)) +
|
||||
pipe;
|
||||
const log = await utils.addLog(
|
||||
'$tick',
|
||||
extension,
|
||||
'Xdebug enabled as coverage driver',
|
||||
os_version
|
||||
);
|
||||
switch (true) {
|
||||
case /^xdebug3$/.test(extension):
|
||||
case /^8\.0$/.test(version):
|
||||
return '\n' + xdebug + '\n' + ini + '\n' + log;
|
||||
case /^xdebug$/.test(extension):
|
||||
default:
|
||||
return (
|
||||
(await extensions.addExtension('xdebug', version, os_version, true)) +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog(
|
||||
'$tick',
|
||||
'xdebug',
|
||||
'Xdebug enabled as coverage driver',
|
||||
os_version
|
||||
))
|
||||
);
|
||||
return '\n' + xdebug + '\n' + log;
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +148,11 @@ export async function addCoverage(
|
||||
case 'pcov':
|
||||
return script + (await addCoveragePCOV(version, os_version, pipe));
|
||||
case 'xdebug':
|
||||
return script + (await addCoverageXdebug(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:
|
||||
|
@ -298,10 +298,20 @@ export async function addExtensionLinux(
|
||||
' ' +
|
||||
version;
|
||||
return;
|
||||
// match 7.2xdebug3..7.4xdebug3
|
||||
case /^7\.[2-4]xdebug3$/.test(version_extension):
|
||||
add_script +=
|
||||
'\nadd_extension_from_source xdebug xdebug/xdebug master --enable-xdebug zend_extension';
|
||||
return;
|
||||
// match 8.0xdebug3
|
||||
case /^8\.[0-9]xdebug3$/.test(version_extension):
|
||||
extension = 'xdebug';
|
||||
command = command_prefix + version + '-' + extension + pipe;
|
||||
break;
|
||||
// match 7.1xdebug..7.4xdebug
|
||||
case /^7\.[1-4]xdebug$/.test(version_extension):
|
||||
add_script +=
|
||||
'\nupdate_extension xdebug 2.9.3' +
|
||||
'\nupdate_extension xdebug 2.9.6' +
|
||||
pipe +
|
||||
'\n' +
|
||||
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
|
||||
|
@ -201,6 +201,27 @@ update_extension() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to install extension from source
|
||||
add_extension_from_source() {
|
||||
extension=$1
|
||||
repo=$2
|
||||
release=$3
|
||||
args=$4
|
||||
prefix=$5
|
||||
(
|
||||
add_devtools
|
||||
delete_extension "$extension"
|
||||
curl -o /tmp/"$extension".tar.gz -sSL https://github.com/"$repo"/archive/"$release".tar.gz
|
||||
tar xf /tmp/"$extension".tar.gz -C /tmp
|
||||
cd /tmp/"$extension-$release" || exit 1
|
||||
phpize && ./configure "$args" && make && sudo make install
|
||||
enable_extension "$extension" "$prefix"
|
||||
) >/dev/null 2>&1
|
||||
(
|
||||
check_extension "$extension" && add_log "$tick" "$extension" "Installed and enabled"
|
||||
) || add_log "$cross" "$extension" "Could not install $extension-$release on PHP $semver"
|
||||
}
|
||||
|
||||
# Function to setup a remote tool.
|
||||
add_tool() {
|
||||
url=$1
|
||||
|
12
src/utils.ts
12
src/utils.ts
@ -224,13 +224,17 @@ export async function CSVArray(values_csv: string): Promise<Array<string>> {
|
||||
* @param extension
|
||||
*/
|
||||
export async function getExtensionPrefix(extension: string): Promise<string> {
|
||||
const zend: Array<string> = ['xdebug', 'opcache', 'ioncube', 'eaccelerator'];
|
||||
const zend: Array<string> = [
|
||||
'xdebug',
|
||||
'xdebug3',
|
||||
'opcache',
|
||||
'ioncube',
|
||||
'eaccelerator'
|
||||
];
|
||||
switch (zend.indexOf(extension)) {
|
||||
case 0:
|
||||
case 1:
|
||||
default:
|
||||
return 'zend_extension';
|
||||
case -1:
|
||||
default:
|
||||
return 'extension';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user