public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: analyze-racy-logs.py cleanup
@ 2024-04-25 17:42 Simon Marchi
  2024-06-21 20:00 ` Guinevere Larsen
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2024-04-25 17:42 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

 - Add type annotations
 - Use a raw string in one spot (where we call re.sub), to avoid an
   "invalid escape sequence" warning.
 - Remove unused "os" import.

Change-Id: I0149cbb73ad2b05431f032fa9d9530282cb01e90
---
 gdb/testsuite/analyze-racy-logs.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/analyze-racy-logs.py b/gdb/testsuite/analyze-racy-logs.py
index 152490e7686b..5a3f90ed62d0 100755
--- a/gdb/testsuite/analyze-racy-logs.py
+++ b/gdb/testsuite/analyze-racy-logs.py
@@ -29,7 +29,6 @@
 # This program is invoked when the user runs "make check" and
 # specifies the RACY_ITER environment variable.
 
-import os
 import re
 import sys
 
@@ -45,7 +44,7 @@ import sys
 #                                   }
 #                   }
 
-files_and_tests = dict()
+files_and_tests: dict[str, dict[str, set[str]]] = dict()
 
 # The relatioships between various states of the same tests that
 # should be ignored.  For example, if the same test PASSes on a
@@ -60,7 +59,7 @@ ignore_relations = {"PASS": "KFAIL"}
 sum_matcher = re.compile("^(.?(PASS|FAIL)): (.*)$")
 
 
-def parse_sum_line(line, dic):
+def parse_sum_line(line: str, dic: dict[str, set[str]]):
     """Parse a single LINE from a sumfile, and store the results in the
     dictionary referenced by DIC."""
     global sum_matcher
@@ -72,7 +71,7 @@ def parse_sum_line(line, dic):
         test_name = m.group(3)
         # Remove tail parentheses.  These are likely to be '(timeout)'
         # and other extra information that will only confuse us.
-        test_name = re.sub("(\s+)?\(.*$", "", test_name)
+        test_name = re.sub(r"(\s+)?\(.*$", "", test_name)
         if result not in dic.keys():
             dic[result] = set()
         if test_name in dic[result]:
@@ -93,7 +92,7 @@ def parse_sum_line(line, dic):
         dic[result].add(test_name)
 
 
-def read_sum_files(files):
+def read_sum_files(files: list[str]):
     """Read the sumfiles (passed as a list in the FILES variable), and
     process each one, filling the FILES_AND_TESTS global dictionary with
     information about them."""
@@ -127,8 +126,8 @@ def identify_racy_tests():
     #
     # Each set in ALL_TESTS will contain all tests, racy or not, for
     # that state.
-    nonracy_tests = dict()
-    all_tests = dict()
+    nonracy_tests: dict[str, set[str]] = dict()
+    all_tests: dict[str, set[str]] = dict()
     for f in files_and_tests:
         for state in files_and_tests[f]:
             try:
@@ -144,14 +143,14 @@ def identify_racy_tests():
     # Now, we eliminate the tests that are present in states that need
     # to be ignored.  For example, tests both in the PASS and KFAIL
     # states should not be considered racy.
-    ignored_tests = set()
+    ignored_tests: set[str] = set()
     for s1, s2 in ignore_relations.items():
         try:
             ignored_tests |= all_tests[s1] & all_tests[s2]
         except:
             continue
 
-    racy_tests = set()
+    racy_tests: set[str] = set()
     for f in files_and_tests:
         for state in files_and_tests[f]:
             racy_tests |= files_and_tests[f][state] - nonracy_tests[state]

base-commit: 5b9707eb872ad4cb50c98d396d16f110070a44ca
-- 
2.44.0


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

* Re: [PATCH] gdb/testsuite: analyze-racy-logs.py cleanup
  2024-04-25 17:42 [PATCH] gdb/testsuite: analyze-racy-logs.py cleanup Simon Marchi
@ 2024-06-21 20:00 ` Guinevere Larsen
  2024-06-22  0:56   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Guinevere Larsen @ 2024-06-21 20:00 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 4/25/24 2:42 PM, Simon Marchi wrote:
>   - Add type annotations
>   - Use a raw string in one spot (where we call re.sub), to avoid an
>     "invalid escape sequence" warning.
>   - Remove unused "os" import.
>
> Change-Id: I0149cbb73ad2b05431f032fa9d9530282cb01e90
> ---

Looks like a pretty simple and harmless change.

Reviewed-By: Guinevere Larsen <blarsen@redhat.com>

-- 
Cheers,
Guinevere Larsen
She/Her/Hers

>   gdb/testsuite/analyze-racy-logs.py | 17 ++++++++---------
>   1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/gdb/testsuite/analyze-racy-logs.py b/gdb/testsuite/analyze-racy-logs.py
> index 152490e7686b..5a3f90ed62d0 100755
> --- a/gdb/testsuite/analyze-racy-logs.py
> +++ b/gdb/testsuite/analyze-racy-logs.py
> @@ -29,7 +29,6 @@
>   # This program is invoked when the user runs "make check" and
>   # specifies the RACY_ITER environment variable.
>   
> -import os
>   import re
>   import sys
>   
> @@ -45,7 +44,7 @@ import sys
>   #                                   }
>   #                   }
>   
> -files_and_tests = dict()
> +files_and_tests: dict[str, dict[str, set[str]]] = dict()
>   
>   # The relatioships between various states of the same tests that
>   # should be ignored.  For example, if the same test PASSes on a
> @@ -60,7 +59,7 @@ ignore_relations = {"PASS": "KFAIL"}
>   sum_matcher = re.compile("^(.?(PASS|FAIL)): (.*)$")
>   
>   
> -def parse_sum_line(line, dic):
> +def parse_sum_line(line: str, dic: dict[str, set[str]]):
>       """Parse a single LINE from a sumfile, and store the results in the
>       dictionary referenced by DIC."""
>       global sum_matcher
> @@ -72,7 +71,7 @@ def parse_sum_line(line, dic):
>           test_name = m.group(3)
>           # Remove tail parentheses.  These are likely to be '(timeout)'
>           # and other extra information that will only confuse us.
> -        test_name = re.sub("(\s+)?\(.*$", "", test_name)
> +        test_name = re.sub(r"(\s+)?\(.*$", "", test_name)
>           if result not in dic.keys():
>               dic[result] = set()
>           if test_name in dic[result]:
> @@ -93,7 +92,7 @@ def parse_sum_line(line, dic):
>           dic[result].add(test_name)
>   
>   
> -def read_sum_files(files):
> +def read_sum_files(files: list[str]):
>       """Read the sumfiles (passed as a list in the FILES variable), and
>       process each one, filling the FILES_AND_TESTS global dictionary with
>       information about them."""
> @@ -127,8 +126,8 @@ def identify_racy_tests():
>       #
>       # Each set in ALL_TESTS will contain all tests, racy or not, for
>       # that state.
> -    nonracy_tests = dict()
> -    all_tests = dict()
> +    nonracy_tests: dict[str, set[str]] = dict()
> +    all_tests: dict[str, set[str]] = dict()
>       for f in files_and_tests:
>           for state in files_and_tests[f]:
>               try:
> @@ -144,14 +143,14 @@ def identify_racy_tests():
>       # Now, we eliminate the tests that are present in states that need
>       # to be ignored.  For example, tests both in the PASS and KFAIL
>       # states should not be considered racy.
> -    ignored_tests = set()
> +    ignored_tests: set[str] = set()
>       for s1, s2 in ignore_relations.items():
>           try:
>               ignored_tests |= all_tests[s1] & all_tests[s2]
>           except:
>               continue
>   
> -    racy_tests = set()
> +    racy_tests: set[str] = set()
>       for f in files_and_tests:
>           for state in files_and_tests[f]:
>               racy_tests |= files_and_tests[f][state] - nonracy_tests[state]
>
> base-commit: 5b9707eb872ad4cb50c98d396d16f110070a44ca


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

* Re: [PATCH] gdb/testsuite: analyze-racy-logs.py cleanup
  2024-06-21 20:00 ` Guinevere Larsen
@ 2024-06-22  0:56   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2024-06-22  0:56 UTC (permalink / raw)
  To: Guinevere Larsen, Simon Marchi, gdb-patches



On 2024-06-21 16:00, Guinevere Larsen wrote:
> On 4/25/24 2:42 PM, Simon Marchi wrote:
>>   - Add type annotations
>>   - Use a raw string in one spot (where we call re.sub), to avoid an
>>     "invalid escape sequence" warning.
>>   - Remove unused "os" import.
>>
>> Change-Id: I0149cbb73ad2b05431f032fa9d9530282cb01e90
>> ---
> 
> Looks like a pretty simple and harmless change.
> 
> Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
> 

Thanks, pushed.

Simon

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

end of thread, other threads:[~2024-06-22  0:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 17:42 [PATCH] gdb/testsuite: analyze-racy-logs.py cleanup Simon Marchi
2024-06-21 20:00 ` Guinevere Larsen
2024-06-22  0:56   ` Simon Marchi

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).