diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-29 17:51:30 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-29 17:51:30 +0200 |
commit | 77891f7dbad2c05aaffc54b4f1e26c060480201c (patch) | |
tree | edc92ea6208ccba0879da56a66b775722e7ce350 | |
parent | 39e9a2d9f0f370b744f74b14223b29e783f30ce7 (diff) | |
parent | 5a365857fb8edb719b687b989351287b0ae09532 (diff) | |
download | rules-cc-77891f7dbad2c05aaffc54b4f1e26c060480201c.tar.gz |
Merge subtree 'rules' into rules-cc
-rwxr-xr-x | rules/CC/auto/runner | 18 | ||||
-rwxr-xr-x | rules/CC/test/runner | 12 | ||||
-rwxr-xr-x | rules/shell/test/summarizer | 39 |
3 files changed, 35 insertions, 34 deletions
diff --git a/rules/CC/auto/runner b/rules/CC/auto/runner index f938c27..27aef0c 100755 --- a/rules/CC/auto/runner +++ b/rules/CC/auto/runner @@ -24,7 +24,6 @@ param_file = argv[2] magic_string = argv[3] at_only = argv[4] == "true" - with open(param_file) as f: param = json.loads(f.read()) @@ -41,8 +40,8 @@ with open(input_file) as i: with open("out", "w") as o: for line in i.readlines(): if x := re.search( - r"#(.*)(" + magic_string + r" )([ \t]*)([a-zA-Z0-9_]+)", line - ): + r"#(.*)(" + magic_string + r" )([ \t]*)([a-zA-Z0-9_]+)", + line): # get the VAR key = x.groups()[-1] if key in param: @@ -52,16 +51,16 @@ with open(input_file) as i: line, ) else: - line = f"/* #undef {x.groups()[-1]} */\n" + line = f"/* #undef {x.groups()[-1]} */\n" if x := re.search( - r"#(.*)(" + magic_string + "01 )([ \t]*)([a-zA-Z0-9_]+)", line - ): + r"#(.*)(" + magic_string + "01 )([ \t]*)([a-zA-Z0-9_]+)", + line): # get the VAR key = x.groups()[-1] line = sub( f"{x.group()[1:]}", - f"{x.groups()[0]}define {x.groups()[2]}{key} " - + str(1 if key in param else 0), + f"{x.groups()[0]}define {x.groups()[2]}{key} " + + str(1 if key in param else 0), line, ) if match("#[ \t]*define", line): @@ -71,6 +70,7 @@ with open(input_file) as i: if not at_only: if x := re.search(r"\${([a-zA-Z0-9-_]+)}", line): key = x.groups()[0] - line = sub(r"\${" + key + r"}", param.get(key, ""), line) + line = sub(r"\${" + key + r"}", param.get(key, ""), + line) print(line, end="", file=o) diff --git a/rules/CC/test/runner b/rules/CC/test/runner index 0647621..fc1f04c 100755 --- a/rules/CC/test/runner +++ b/rules/CC/test/runner @@ -18,14 +18,14 @@ import os import subprocess import time -time_start = time.time() -time_stop = 0 -result = "UNKNOWN" -stderr = "" -stdout = "" +time_start: float = time.time() +time_stop: float = 0 +result: str = "UNKNOWN" +stderr: str = "" +stdout: str = "" -def dump_results(): +def dump_results() -> None: with open("result", "w") as f: f.write("%s\n" % (result, )) with open("time-start", "w") as f: diff --git a/rules/shell/test/summarizer b/rules/shell/test/summarizer index 0b5e656..5fb0311 100755 --- a/rules/shell/test/summarizer +++ b/rules/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 |