From 9a0d9ca13b5013e4fc829438fa45ba8cb746bad4 Mon Sep 17 00:00:00 2001 From: ICHINOSE Shogo Date: Fri, 11 Nov 2022 23:45:38 +0900 Subject: [PATCH] ignore commented out error message --- {.github => scripts}/perl.json | 2 +- scripts/t/05_problem_matcher.t | 21 +++++++++++++++++++++ scripts/t/errors.pl | 4 ++++ src/setup-perl.ts | 4 ++-- 4 files changed, 28 insertions(+), 3 deletions(-) rename {.github => scripts}/perl.json (75%) create mode 100644 scripts/t/05_problem_matcher.t create mode 100644 scripts/t/errors.pl diff --git a/.github/perl.json b/scripts/perl.json similarity index 75% rename from .github/perl.json rename to scripts/perl.json index 8d5b09fca..f2cd99e49 100644 --- a/.github/perl.json +++ b/scripts/perl.json @@ -4,7 +4,7 @@ "owner": "perl", "pattern": [ { - "regexp": "^(.+)\\sat\\s(.+)\\sline\\s(\\d+)\\.$", + "regexp": "^\\s*([^#\\s].+)\\sat\\s(.+)\\sline\\s(\\d+)\\.$", "file": 2, "line": 3, "message": 1 diff --git a/scripts/t/05_problem_matcher.t b/scripts/t/05_problem_matcher.t new file mode 100644 index 000000000..1dfac9f5d --- /dev/null +++ b/scripts/t/05_problem_matcher.t @@ -0,0 +1,21 @@ +use Test::More; +use JSON::PP qw/decode_json/; + +open my $fh, '<', 'perl.json' or die "$!"; +my $data = do {local $/; <$fh>}; +close $fh; + +my $matcher = decode_json($data); +my $problem_matcher = $matcher->{problemMatcher}; +my $regexp = $problem_matcher->[0]{pattern}[0]{regexp}; +diag $regexp; + +like 'Bareword "foobar" not allowed while "strict subs" in use at t/errors.pl line 4.', qr/$regexp/, 'systax error'; +like 'some error!! at t/errors.pl line 4.', qr/$regexp/, 'die'; +like 'some # error!! at t/errors.pl line 4.', qr/$regexp/, 'die'; + +# from: https://github.com/shogo82148/actions-setup-perl/issues/1302 +unlike ' # at /home/runner/work/perlTest/perlTest/t/FHEM/98_HELLO/00_define.t line 21.', qr/$regexp/, 'issue 1302'; +unlike "# at /home/runner/work/perlTest/perlTest/t/FHEM/98_HELLO/00_define.t line [22]", qr/$regexp/, 'issue 1302'; +done_testing; + diff --git a/scripts/t/errors.pl b/scripts/t/errors.pl new file mode 100644 index 000000000..3f1b153b9 --- /dev/null +++ b/scripts/t/errors.pl @@ -0,0 +1,4 @@ +use strict; +use warnings; + +die "some # error!!"; diff --git a/src/setup-perl.ts b/src/setup-perl.ts index 8f811c16f..ca48587bb 100644 --- a/src/setup-perl.ts +++ b/src/setup-perl.ts @@ -47,8 +47,8 @@ async function run() { perlHash = await digestOfPerlVersion(result.path); core.setOutput("perl-hash", perlHash); - const matchersPath = path.join(__dirname, "..", ".github"); - console.log(`##[add-matcher]${path.join(matchersPath, "perl.json")}`); + const matchersPath = path.join(__dirname, "..", "scripts"); + console.log(`::add-matcher::${path.join(matchersPath, "perl.json")}`); // for pre-installed scripts core.addPath(path.join(__dirname, "..", "bin"));