diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-06-27 15:07:59 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-29 17:48:45 +0200 |
commit | f41343abe847fa88a4cbb46d856bfc44efa8595a (patch) | |
tree | 47b4e7f2d5aa43ce85470ac65814339cd96ac864 /shell/test | |
parent | 6398d0947673a75cf15544af34f038ff8b18b51b (diff) | |
download | rules-cc-f41343abe847fa88a4cbb46d856bfc44efa8595a.tar.gz |
python: Add type hints and fix style in rules scripts
Diffstat (limited to 'shell/test')
-rwxr-xr-x | shell/test/summarizer | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/shell/test/summarizer b/shell/test/summarizer index 0b5e656..5fb0311 100755 --- a/shell/test/summarizer +++ b/shell/test/summarizer @@ -13,20 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. - import os import time -RESULTS = {} +from typing import Any, Dict, List + +g_RESULTS: Dict[str, List[Any]] = {} -time_start = time.time() -time_stop = 0 +time_start: float = time.time() +time_stop: float = 0 for attempt in os.listdir("."): if os.path.isdir(attempt): with open(os.path.join(attempt, "result")) as f: result = f.read().strip() - RESULTS[result] = RESULTS.get(result, []) + [int(attempt)] + g_RESULTS[result] = g_RESULTS.get(result, []) + [int(attempt)] try: with open(os.path.join(attempt, "time-start")) as f: time_start = min(time_start, float(f.read().strip())) @@ -38,30 +39,30 @@ for attempt in os.listdir("."): except: pass -result = "UNKNOWN" -if set(RESULTS.keys()) <= set(["PASS", "FAIL"]): - if not RESULTS.get("FAIL"): +result: str = "UNKNOWN" +if set(g_RESULTS.keys()) <= set(["PASS", "FAIL"]): + if not g_RESULTS.get("FAIL"): result = "PASS" - elif not RESULTS.get("PASS"): + elif not g_RESULTS.get("PASS"): result = "FAIL" else: result = "FLAKY" with open("result", "w") as f: - f.write("%s\n" % (result,)) + f.write("%s\n" % (result, )) with open("time-start", "w") as f: - f.write("%d\n" % (time_start,)) + f.write("%d\n" % (time_start, )) with open("time-stop", "w") as f: - f.write("%d\n" % (time_stop,)) + f.write("%d\n" % (time_stop, )) with open("stdout", "w") as f: - f.write("Summary: %s\n\n" % (result,)) - f.write("PASS: %s\n" % (sorted(RESULTS.get("PASS", [])),)) - f.write("FAIL: %s\n" % (sorted(RESULTS.get("FAIL", [])),)) - RESULTS.pop("PASS", None) - RESULTS.pop("FAIL", None) - if RESULTS: - f.write("\nother results: %r\n" % (RESULTS,)) + f.write("Summary: %s\n\n" % (result, )) + f.write("PASS: %s\n" % (sorted(g_RESULTS.get("PASS", [])), )) + f.write("FAIL: %s\n" % (sorted(g_RESULTS.get("FAIL", [])), )) + g_RESULTS.pop("PASS", None) + g_RESULTS.pop("FAIL", None) + if g_RESULTS: + f.write("\nother results: %r\n" % (g_RESULTS, )) with open("stderr", "w") as f: pass |