From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id DBAAD385B50D; Sat, 22 Jun 2024 00:56:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBAAD385B50D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1719017806; bh=Czqg9bs42ZcfuKy9/i1PZnrIzTb1bFtRtEll9kQ6OXs=; h=From:To:Subject:Date:From; b=HqR/5zI+wuRgYBxo7dyRnPMhVivcxnTcK4bAgaU+HuThOKBaBT8QQJWed+iawTHCA 47V7br5brTqIxSMzLTYbrjulec1YVmy9tWZ0P+bHDc8A/NIfXEQEUhBWFnVF/3Vu0V Zl6ork6m0netv9mRpWvh0dcNbIpQEVe5al0yoS14= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: analyze-racy-logs.py cleanup X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 4c8d6351ccccd836833a414e3c8042a166438fba X-Git-Newrev: 59cd16533b971358363c95ef1870c85e03dc15a8 Message-Id: <20240622005646.DBAAD385B50D@sourceware.org> Date: Sat, 22 Jun 2024 00:56:46 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D59cd16533b97= 1358363c95ef1870c85e03dc15a8 commit 59cd16533b971358363c95ef1870c85e03dc15a8 Author: Simon Marchi Date: Thu Apr 25 13:42:42 2024 -0400 gdb/testsuite: analyze-racy-logs.py cleanup =20 - 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. =20 Change-Id: I0149cbb73ad2b05431f032fa9d9530282cb01e90 Reviewed-By: Guinevere Larsen Diff: --- 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-rac= y-logs.py index 152490e7686..5a3f90ed62d 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. =20 -import os import re import sys =20 @@ -45,7 +44,7 @@ import sys # } # } =20 -files_and_tests =3D dict() +files_and_tests: dict[str, dict[str, set[str]]] =3D dict() =20 # 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 =3D {"PASS": "KFAIL"} sum_matcher =3D re.compile("^(.?(PASS|FAIL)): (.*)$") =20 =20 -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 =3D m.group(3) # Remove tail parentheses. These are likely to be '(timeout)' # and other extra information that will only confuse us. - test_name =3D re.sub("(\s+)?\(.*$", "", test_name) + test_name =3D re.sub(r"(\s+)?\(.*$", "", test_name) if result not in dic.keys(): dic[result] =3D set() if test_name in dic[result]: @@ -93,7 +92,7 @@ def parse_sum_line(line, dic): dic[result].add(test_name) =20 =20 -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 =3D dict() - all_tests =3D dict() + nonracy_tests: dict[str, set[str]] =3D dict() + all_tests: dict[str, set[str]] =3D 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 =3D set() + ignored_tests: set[str] =3D set() for s1, s2 in ignore_relations.items(): try: ignored_tests |=3D all_tests[s1] & all_tests[s2] except: continue =20 - racy_tests =3D set() + racy_tests: set[str] =3D set() for f in files_and_tests: for state in files_and_tests[f]: racy_tests |=3D files_and_tests[f][state] - nonracy_tests[stat= e]