public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC Patch] mklog.py: Parse first 10 lines for PR/DR number
@ 2020-09-08  9:47 Tobias Burnus
  2020-09-08 15:50 ` Martin Sebor
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2020-09-08  9:47 UTC (permalink / raw)
  To: Martin Liška, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 671 bytes --]

Hi Martin, hi all,

currently, mklog searches for "PR" (and "DR") only in the
first line of a new 'testsuite' file.

I think in many cases, the PR is listed a bit later than
the first line – although, it is usually in the first few
lines; in my example, it is in line 3 and 4.

Admittedly, I do have cases where later lines are wrong
like
"! Not tested due to PR ...'

How about testing the first, e.g., ten lines?
That's what the attached patch does.

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Attachment #2: mklog.diff --]
[-- Type: text/x-patch, Size: 1213 bytes --]

mklog.py: Parse first 10 lines for PR/DR number

contrib/ChangeLog:

	* mklog.py: Parse first 10 lines for PR/DR number
	not only the first line.

diff --git a/contrib/mklog.py b/contrib/mklog.py
index 243edbb15c5..d334a3875c9 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -137,7 +137,10 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False):
 
         # Extract PR entries from newly added tests
         if 'testsuite' in file.path and file.is_added_file:
-            for line in list(file)[0]:
+            # Only search first ten lines as later lines may
+            # contains commented code which a note that it
+            # has not been tested due to a certain PR or DR.
+            for line in list(file)[0][0:10]:
                 m = pr_regex.search(line.value)
                 if m:
                     pr = m.group('pr')
@@ -149,8 +152,6 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False):
                         dr = m.group('dr')
                         if dr not in prs:
                             prs.append(dr)
-                    else:
-                        break
 
     if fill_pr_titles:
         out += get_pr_titles(prs)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC Patch] mklog.py: Parse first 10 lines for PR/DR number
  2020-09-08  9:47 [RFC Patch] mklog.py: Parse first 10 lines for PR/DR number Tobias Burnus
@ 2020-09-08 15:50 ` Martin Sebor
  2020-09-08 16:20   ` Tobias Burnus
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Sebor @ 2020-09-08 15:50 UTC (permalink / raw)
  To: Tobias Burnus, Martin Liška, gcc-patches

On 9/8/20 3:47 AM, Tobias Burnus wrote:
> Hi Martin, hi all,
> 
> currently, mklog searches for "PR" (and "DR") only in the
> first line of a new 'testsuite' file.
> 
> I think in many cases, the PR is listed a bit later than
> the first line – although, it is usually in the first few
> lines; in my example, it is in line 3 and 4.
> 
> Admittedly, I do have cases where later lines are wrong
> like
> "! Not tested due to PR ...'
> 
> How about testing the first, e.g., ten lines?
> That's what the attached patch does.

I frequently use "prNNNNN" in dg-warning directives xfailed due
to the pr.  They're probably only rarely in the first 10 lines
but stopping the search after the first dg- directive is seen
would help reduce the likelihood of the false positives even
further.

Martin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC Patch] mklog.py: Parse first 10 lines for PR/DR number
  2020-09-08 15:50 ` Martin Sebor
@ 2020-09-08 16:20   ` Tobias Burnus
  2020-09-21  8:05     ` Martin Liška
  0 siblings, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2020-09-08 16:20 UTC (permalink / raw)
  To: Martin Sebor, Tobias Burnus, Martin Liška, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]

On 9/8/20 5:50 PM, Martin Sebor wrote:

> On 9/8/20 3:47 AM, Tobias Burnus wrote:
>> currently, mklog searches for "PR" (and "DR") only in the
>> first line of a new 'testsuite' file.
>>
>> I think in many cases, the PR is listed a bit later than
>> the first line – although, it is usually in the first few
>> lines; in my example, it is in line 3 and 4.
>>
>> Admittedly, I do have cases where later lines are wrong
>> like
>> "! Not tested due to PR ...'
>>
>> How about testing the first, e.g., ten lines?
>> That's what the attached patch does.
>
> I frequently use "prNNNNN" in dg-warning directives xfailed due
> to the pr.

Those won't match pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')

> They're probably only rarely in the first 10 lines
> but stopping the search after the first dg- directive is seen
> would help reduce the likelihood of the false positives even
> further.

I think stopping after the first 'dg-' directive does not make sense;
at least I tend to start testcases with 'dg-do' followed by
'dg-(additional-)options'.

However, the new version of the patch stops after the first
'dg-error/dg-warning'.

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Attachment #2: mklog-v2.diff --]
[-- Type: text/x-patch, Size: 1684 bytes --]

mklog.py: Parse first 10 lines for PR/DR number

contrib/ChangeLog:

	* mklog.py: Parse first 10 lines for PR/DR number
	not only the first line.

diff --git a/contrib/mklog.py b/contrib/mklog.py
index 243edbb15c5..1e85dfe583a 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -38,6 +38,7 @@ from unidiff import PatchSet
 
 pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')
 dr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<dr>DR [0-9]+)')
+dg_regex = re.compile(r'{\s+dg-(error|warning)')
 identifier_regex = re.compile(r'^([a-zA-Z0-9_#].*)')
 comment_regex = re.compile(r'^\/\*')
 struct_regex = re.compile(r'^(class|struct|union|enum)\s+'
@@ -137,7 +138,10 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False):
 
         # Extract PR entries from newly added tests
         if 'testsuite' in file.path and file.is_added_file:
-            for line in list(file)[0]:
+            # Only search first ten lines as later lines may
+            # contains commented code which a note that it
+            # has not been tested due to a certain PR or DR.
+            for line in list(file)[0][0:10]:
                 m = pr_regex.search(line.value)
                 if m:
                     pr = m.group('pr')
@@ -149,7 +153,8 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False):
                         dr = m.group('dr')
                         if dr not in prs:
                             prs.append(dr)
-                    else:
+                    elif dg_regex.search(line.value):
+                        # Found dg-warning/dg-error line
                         break
 
     if fill_pr_titles:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC Patch] mklog.py: Parse first 10 lines for PR/DR number
  2020-09-08 16:20   ` Tobias Burnus
@ 2020-09-21  8:05     ` Martin Liška
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Liška @ 2020-09-21  8:05 UTC (permalink / raw)
  To: Tobias Burnus, Martin Sebor, gcc-patches

On 9/8/20 6:20 PM, Tobias Burnus wrote:
> However, the new version of the patch stops after the first
> 'dg-error/dg-warning'.

LGTM.

Martin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-21  8:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08  9:47 [RFC Patch] mklog.py: Parse first 10 lines for PR/DR number Tobias Burnus
2020-09-08 15:50 ` Martin Sebor
2020-09-08 16:20   ` Tobias Burnus
2020-09-21  8:05     ` Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).