mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-26 13:23:05 +07:00
Add problem matcher for PHP native errors
This commit is contained in:
parent
17241e2689
commit
3a2ca44a8a
@ -18,10 +18,10 @@ describe('Matchers', () => {
|
|||||||
process.env['RUNNER_TOOL_CACHE'] = __dirname;
|
process.env['RUNNER_TOOL_CACHE'] = __dirname;
|
||||||
await matchers.addMatchers();
|
await matchers.addMatchers();
|
||||||
const spy = jest.spyOn(io, 'cp');
|
const spy = jest.spyOn(io, 'cp');
|
||||||
expect(spy).toHaveBeenCalledTimes(1);
|
expect(spy).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Test Regex', async () => {
|
it('Test PHPUnit Regex', async () => {
|
||||||
const regex1 = /^\d+\)\s.*$/;
|
const regex1 = /^\d+\)\s.*$/;
|
||||||
const regex2 = /^(.*Failed\sasserting\sthat.*)$/;
|
const regex2 = /^(.*Failed\sasserting\sthat.*)$/;
|
||||||
const regex3 = /^\s*$/;
|
const regex3 = /^\s*$/;
|
||||||
@ -31,4 +31,21 @@ describe('Matchers', () => {
|
|||||||
expect(regex3.test('\n')).toBe(true);
|
expect(regex3.test('\n')).toBe(true);
|
||||||
expect(regex4.test('/path/to/file.php:42')).toBe(true);
|
expect(regex4.test('/path/to/file.php:42')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Test PHP Regex', async () => {
|
||||||
|
const regex1 = /^(.*error):\s+\s+(.+) in (.+) on line (\d+)$/;
|
||||||
|
const regex2 = /^(.*Warning|.*Deprecated|.*Notice):\s+\s+(.+) in (.+) on line (\d+)$/;
|
||||||
|
expect(
|
||||||
|
regex1.test('PHP Parse error: error_message in file.php on line 10')
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
regex2.test('PHP Notice: info_message in file.php on line 10')
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
regex2.test('PHP Warning: warning_message in file.php on line 10')
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
regex2.test('PHP Deprecated: deprecated_message in file.php on line 10')
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
5
dist/index.js
vendored
5
dist/index.js
vendored
@ -964,9 +964,10 @@ const io = __importStar(__webpack_require__(1));
|
|||||||
*/
|
*/
|
||||||
function addMatchers() {
|
function addMatchers() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const config_path = path.join(__dirname, '..', 'src', 'configs', 'phpunit.json');
|
const config_path = path.join(__dirname, '..', 'src', 'configs');
|
||||||
const runner_dir = yield utils.getInput('RUNNER_TOOL_CACHE', false);
|
const runner_dir = yield utils.getInput('RUNNER_TOOL_CACHE', false);
|
||||||
yield io.cp(config_path, runner_dir);
|
yield io.cp(path.join(config_path, 'phpunit.json'), runner_dir);
|
||||||
|
yield io.cp(path.join(config_path, 'php.json'), runner_dir);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.addMatchers = addMatchers;
|
exports.addMatchers = addMatchers;
|
||||||
|
29
src/configs/php.json
Normal file
29
src/configs/php.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "php_native_error",
|
||||||
|
"severity": "error",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(.*error):\\s+\\s+(.+) in (.+) on line (\\d+)$",
|
||||||
|
"code": 1,
|
||||||
|
"message": 2,
|
||||||
|
"file": 3,
|
||||||
|
"line": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
"owner": "php_native_warning",
|
||||||
|
"severity": "warning",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(.*Warning|.*Deprecated|.*Notice):\\s+\\s+(.+) in (.+) on line (\\d+)$",
|
||||||
|
"code": 1,
|
||||||
|
"message": 2,
|
||||||
|
"file": 3,
|
||||||
|
"line": 4
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -6,13 +6,8 @@ import * as io from '@actions/io';
|
|||||||
* Cache json files for problem matchers
|
* Cache json files for problem matchers
|
||||||
*/
|
*/
|
||||||
export async function addMatchers(): Promise<void> {
|
export async function addMatchers(): Promise<void> {
|
||||||
const config_path = path.join(
|
const config_path = path.join(__dirname, '..', 'src', 'configs');
|
||||||
__dirname,
|
|
||||||
'..',
|
|
||||||
'src',
|
|
||||||
'configs',
|
|
||||||
'phpunit.json'
|
|
||||||
);
|
|
||||||
const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false);
|
const runner_dir: string = await utils.getInput('RUNNER_TOOL_CACHE', false);
|
||||||
await io.cp(config_path, runner_dir);
|
await io.cp(path.join(config_path, 'phpunit.json'), runner_dir);
|
||||||
|
await io.cp(path.join(config_path, 'php.json'), runner_dir);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user