Skip to content

Commit

Permalink
Add --showarch option to report command
Browse files Browse the repository at this point in the history
This option adds new Arch column to the report table.
  • Loading branch information
pholica committed Feb 27, 2024
1 parent 0479802 commit 28341d3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Calendar Versioning](https://calver.org).<br>
### Added
- Return code for report command
- Report command option for downloading logs only for non-passed tests
- `--showarch` option in `report` command displaying architecture in the table

### Changed
- `-c/--compose` to `-t/--target`
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,13 @@ Corresponding return code is set based on the results with following logic:
```shell
❯ tesar report --help
usage: tesar report [-h] [-l2] [-s] [-stn SPLIT_TESTNAME] [-spn SPLIT_PLANNAME] [-w] [-d] [--skip-pass] [-lt | -f FILE | -c CMD]
usage: tesar report [-h] [--showarch] [-l2] [-s] [-stn SPLIT_TESTNAME] [-spn SPLIT_PLANNAME] [-w] [-d] [--skip-pass] [-lt | -f FILE | -c CMD]
Parses task IDs, Testing Farm artifact URLs or Testing Farm API request URLs from multiple sources.
options:
-h, --help show this help message and exit
--showarch Display architecture. By default the architecture is not shown.
-l2, --level2 Display test view detail. By default the report shows only plan view.
-s, --short Display short test and plan names.
-stn SPLIT_TESTNAME, --split-testname SPLIT_TESTNAME
Expand Down
5 changes: 5 additions & 0 deletions src/dispatch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ def get_arguments(args=None):
description="Parses task IDs, Testing Farm artifact URLs or Testing Farm API request URLs from multiple sources.",
)

report.add_argument(
"--showarch",
action="store_true",
help="""Display architecture. By default the architecture is not shown.""",
)
report.add_argument(
"-l2",
"--level2",
Expand Down
14 changes: 11 additions & 3 deletions src/report/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def parse_request_xunit(request_url_list=None, tasks_source=None, skip_pass=Fals
request_state = request.json()["state"].upper()
request_uuid = request.json()["id"]
request_target = request.json()["environments_requested"][0]["os"]["compose"]
request_arch = request.json()["environments_requested"][0]['arch']
request_datetime_created = request.json()["created"]
request_datetime_parsed = request_datetime_created.split(".")[0]

Expand Down Expand Up @@ -209,6 +210,7 @@ def parse_request_xunit(request_url_list=None, tasks_source=None, skip_pass=Fals
if request_uuid not in parsed_dict:
parsed_dict[request_uuid] = {
"target_name": request_target,
"arch": request_arch,
"testsuites": [],
}

Expand Down Expand Up @@ -277,7 +279,10 @@ def build_table():
result_table = PrettyTable()
# prepare field names
fields = []
fields += ["UUID", "Target", "Test Plan"]
fields += ["UUID", "Target"]
if ARGS.showarch:
fields += ["Arch"]
fields += ["Test Plan"]
if ARGS.level2:
fields += ["Test Case"]
fields += ["Result"]
Expand All @@ -298,11 +303,14 @@ def build_table():
if ARGS.split_planname:
planname_split_index = ARGS.split_planname

def _gen_row(uuid="", target="", testplan="", testcase="", result=""):

def _gen_row(uuid="", target="", arch="", testplan="", testcase="", result=""):
if "UUID" in fields:
yield uuid
if "Target" in fields:
yield target
if "Arch" in fields:
yield arch
if "Test Plan" in fields:
yield testplan
if "Test Case" in fields:
Expand All @@ -314,7 +322,7 @@ def add_row(*args, **kwargs):
result_table.add_row(tuple(_gen_row(*args, **kwargs)))

for task_uuid, data in parsed_dict.items():
add_row(task_uuid, data["target_name"])
add_row(task_uuid, data["target_name"], data["arch"])
for testsuite_data in data["testsuites"]:
testsuite_name_raw = testsuite_data["testsuite_name"].split("/")
testsuite_name_raw.remove("")
Expand Down

0 comments on commit 28341d3

Please sign in to comment.