summaryrefslogtreecommitdiff
path: root/buildscripts/simple_report.py
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /buildscripts/simple_report.py
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'buildscripts/simple_report.py')
-rw-r--r--buildscripts/simple_report.py105
1 files changed, 0 insertions, 105 deletions
diff --git a/buildscripts/simple_report.py b/buildscripts/simple_report.py
deleted file mode 100644
index da12326b562..00000000000
--- a/buildscripts/simple_report.py
+++ /dev/null
@@ -1,105 +0,0 @@
-"""Given a test name, path to log file and exit code, generate/append an Evergreen report.json."""
-import json
-import pathlib
-import os
-from typing import List, Dict, Optional
-from typing_extensions import TypedDict
-import click
-
-
-class Result(TypedDict, total=False):
- """Evergreen test result."""
-
- status: str
- exit_code: int
- test_file: str
- start: float
- end: float
- elapsed: float
- log_raw: str
-
-
-class Report(TypedDict):
- """Evergreen report."""
-
- failures: int
- results: List[Result]
-
-
-def _open_and_truncate_log_lines(log_file: pathlib.Path) -> List[str]:
- with open(log_file) as fh:
- lines = fh.read().splitlines()
- for i, line in enumerate(lines):
- if line == "scons: done reading SConscript files.":
- offset = i
- # if possible, also shave off the current and next line
- # as they contain:
- # scons: done reading SConscript files.
- # scons: Building targets ...
- # which is superfluous.
- if len(lines) > i + 2:
- offset = i + 2
- return lines[offset:]
-
- return lines
-
-
-def _clean_log_file(log_file: pathlib.Path, dedup_lines: bool) -> str:
- lines = _open_and_truncate_log_lines(log_file)
- if dedup_lines:
- lines = _dedup_lines(lines)
- return os.linesep.join(lines)
-
-
-def make_report(test_name: str, log_file_contents: str, exit_code: int) -> Report: # noqa: D103
- # pylint: disable=missing-function-docstring
- status = "pass" if exit_code == 0 else "fail"
- return Report({
- 'failures':
- 0 if exit_code == 0 else 1, "results": [
- Result({
- "status": status, "exit_code": exit_code, "test_file": test_name,
- "log_raw": log_file_contents
- })
- ]
- })
-
-
-def try_combine_reports(out: Report): # noqa: D103
- # pylint: disable=missing-function-docstring
- try:
- with open("report.json") as fh:
- report = json.load(fh)
- out["results"] += report["results"]
- out["failures"] += report["failures"]
- except NameError:
- pass
- except IOError:
- pass
-
-
-def _dedup_lines(lines: List[str]) -> List[str]:
- return list(set(lines))
-
-
-def put_report(out: Report): # noqa: D103
- # pylint: disable=missing-function-docstring
- with open("report.json", "w") as fh:
- json.dump(out, fh)
-
-
-@click.command()
-@click.option("--test-name", required=True, type=str)
-@click.option("--log-file", required=True, type=pathlib.Path)
-@click.option("--exit-code", required=True, type=int)
-@click.option("--dedup-lines", is_flag=True)
-def main(test_name: str, log_file: pathlib.Path, exit_code: int, dedup_lines: bool):
- """Given a test name, path to log file and exit code, generate/append an Evergreen report.json."""
- log_file_contents = _clean_log_file(log_file, dedup_lines)
- report = make_report(test_name, log_file_contents, exit_code)
- try_combine_reports(report)
- put_report(report)
-
-
-if __name__ == "__main__":
- main() # pylint: disable=no-value-for-parameter