Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set overflow='fold' for table output #1617

Merged
merged 3 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions buildtest/cli/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def print_discovered_buildspecs(buildspec_dict):
table = Table(
title="Discovered buildspecs", box=box.DOUBLE_EDGE, header_style="blue"
)
table.add_column("buildspec", style="green")
table.add_column("buildspec", style="green", overflow="fold")

for i in buildspec_dict["included"]:
table.add_row(i)
Expand All @@ -263,7 +263,7 @@ def print_discovered_buildspecs(buildspec_dict):
table = Table(
title="Excluded buildspecs", box=box.DOUBLE_EDGE, header_style="blue"
)
table.add_column("buildspec", style="red")
table.add_column("buildspec", style="red", overflow="fold")

for i in buildspec_dict["excluded"]:
table.add_row(i)
Expand All @@ -277,7 +277,7 @@ def print_discovered_buildspecs(buildspec_dict):
box=box.DOUBLE_EDGE,
header_style="blue",
)
table.add_column("buildspec", style="turquoise2")
table.add_column("buildspec", style="turquoise2", overflow="fold")
for row in buildspec_dict["tags"][tagname]:
table.add_row(row)
console.print(table)
Expand All @@ -290,7 +290,7 @@ def print_discovered_buildspecs(buildspec_dict):
box=box.DOUBLE_EDGE,
header_style="blue",
)
table.add_column("buildspecs", style="magenta1")
table.add_column("buildspecs", style="magenta1", overflow="fold")
for row in buildspec_dict["executors"][executorname]:
table.add_row(f"{row}")
console.print(table)
Expand All @@ -303,7 +303,7 @@ def print_discovered_buildspecs(buildspec_dict):
box=box.DOUBLE_EDGE,
header_style="blue",
)
table.add_column("buildspecs", style="yellow2")
table.add_column("buildspecs", style="yellow2", overflow="fold")
for row in buildspec_dict["name"][name]:
table.add_row(f"{row}")
console.print(table)
Expand Down Expand Up @@ -520,8 +520,8 @@ def print_filters():
"""

table = Table(title="Buildtest Filters", header_style="blue")
table.add_column("Field", style="green")
table.add_column("Description", style="red")
table.add_column("Field", style="green", overflow="fold")
table.add_column("Description", style="red", overflow="fold")

table.add_row("tags", "Filter tests by [italic]'tag'[/italic] field")
table.add_row("type", "Filter test by [italic]'type'[/italic] field")
Expand Down Expand Up @@ -1237,11 +1237,11 @@ def _print_test_summary(self, builders):

table = Table(title="Test Summary", show_lines=True, header_style="blue")
table.add_column("builder", overflow="fold")
table.add_column("executor")
table.add_column("status")
table.add_column("executor", overflow="fold")
table.add_column("status", overflow="fold")
table.add_column("checks (ReturnCode, Regex, Runtime)", overflow="fold")
table.add_column("returncode")
table.add_column("runtime")
table.add_column("returncode", overflow="fold")
table.add_column("runtime", overflow="fold")

passed_tests = 0
failed_tests = 0
Expand Down Expand Up @@ -1397,14 +1397,14 @@ def print_builders_by_type(self, builders, builder_type):
builder_type (str): The builder type corresponding to the list of ``builders``. This type corresponds to the ``type`` field in the test
"""
table = Table(
Column(header="builder", style="blue"),
Column(header="type", style="cyan1"),
Column(header="executor", style="green"),
Column(header="compiler", style="red"),
Column(header="nodes", style="orange3"),
Column(header="procs", style="orange3"),
Column(header="description", style="magenta"),
Column(header="buildspecs", style="yellow"),
Column(header="builder", style="blue", overflow="fold"),
Column(header="type", style="cyan1", overflow="fold"),
Column(header="executor", style="green", overflow="fold"),
Column(header="compiler", style="red", overflow="fold"),
Column(header="nodes", style="orange3", overflow="fold"),
Column(header="procs", style="orange3", overflow="fold"),
Column(header="description", style="magenta", overflow="fold"),
Column(header="buildspecs", style="yellow", overflow="fold"),
title=f"Builders by type={builder_type}",
show_lines=True,
header_style="blue",
Expand Down
4 changes: 2 additions & 2 deletions buildtest/cli/buildspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,8 @@ def print_invalid_buildspecs(
# if --error is not specified print list of invalid buildspecs in rich table
if not error:
table = Table(
"Buildspec",
"Exception",
Column("Buildspec", overflow="fold"),
Column("Exception", overflow="fold"),
title="Invalid Buildspecs",
header_style="blue",
style="cyan",
Expand Down
14 changes: 7 additions & 7 deletions buildtest/cli/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ def compiler_test(configuration, compiler_names=None):
compiler_pass = Table(title="Compilers Test Pass")
compiler_fail = Table(title="Compilers Test Fail")

compiler_pass.add_column("No.", style="cyan", no_wrap=True)
compiler_pass.add_column("Compiler Name", style="green")
compiler_pass.add_column("Status", justify="right")
compiler_pass.add_column("No.", style="cyan", no_wrap=True, overflow="fold")
compiler_pass.add_column("Compiler Name", style="green", overflow="fold")
compiler_pass.add_column("Status", justify="right", overflow="fold")

compiler_fail.add_column("No.", style="cyan", no_wrap=True)
compiler_fail.add_column("Compiler Name", style="red")
compiler_fail.add_column("Status", justify="right")
compiler_fail.add_column("No.", style="cyan", no_wrap=True, overflow="fold")
compiler_fail.add_column("Compiler Name", style="red", overflow="fold")
compiler_fail.add_column("Status", justify="right", overflow="fold")

for idx, pass_compiler in enumerate(pass_compilers):
compiler_pass.add_row(str(idx + 1), pass_compiler, "✅")
Expand Down Expand Up @@ -411,7 +411,7 @@ def _validate_modules(self, module_dict):
table = Table(
title="Discovered Modules", show_lines=True, header_style="blue"
)
table.add_column("Name")
table.add_column("Name", overflow="fold")
for modules in module_dict.values():
for name in modules:
table.add_row(name)
Expand Down
6 changes: 3 additions & 3 deletions buildtest/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ def view_system(configuration):

# table = {"system": [], "description": [], "hostnames": [], "moduletool": []}
table = Table(
"system",
"description",
"moduletool",
Column("system", overflow="fold"),
Column("description", overflow="fold"),
Column("moduletool", overflow="fold"),
Column("hostnames", overflow="fold"),
title=f"System Summary (Configuration={configuration.file})",
header_style="blue",
Expand Down
9 changes: 7 additions & 2 deletions buildtest/cli/helpcolor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from rich.color import ANSI_COLOR_NAMES
from rich.table import Table
from rich.table import Column, Table

from buildtest.defaults import console


def print_available_colors(color_names=ANSI_COLOR_NAMES):
"""Print the available color options in a table format on background of the color option."""
table = Table("Number", "Color", header_style="bold", title="Available Colors")
table = Table(
Column("Number", overflow="fold"),
Column("Color", overflow="fold"),
header_style="bold",
title="Available Colors",
)
for color, number in color_names.items():
table.add_row(f"[black]{number}", f"[black]{color}", style="on " + color)
console.print(table)
21 changes: 12 additions & 9 deletions buildtest/cli/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,18 @@ def list_build_history(
history_table = Table(
header_style="blue", show_lines=True, row_styles=[consoleColor]
)
history_table.add_column("id")
history_table.add_column("hostname")
history_table.add_column("user")
history_table.add_column("system")
history_table.add_column("date")
history_table.add_column("pass tests")
history_table.add_column("fail tests")
history_table.add_column("total tests")
history_table.add_column("command", overflow="fold")
for field in [
"id",
"hostname",
"user",
"system",
"date",
"pass tests",
"fail tests",
"total tests",
"command",
]:
history_table.add_column(field, overflow="fold")

for (
build_id,
Expand Down
10 changes: 7 additions & 3 deletions buildtest/cli/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from rich.pretty import pprint
from rich.syntax import Syntax
from rich.table import Table
from rich.table import Column, Table

from buildtest.defaults import console
from buildtest.utils.file import read_file, resolve_path
Expand Down Expand Up @@ -150,7 +150,7 @@ def inspect_list(
row_styles=[consoleColor],
)
for column in table.keys():
inspect_table.add_column(column)
inspect_table.add_column(column, overflow="fold")

for identifier, name, buildspec in zip(
table["id"], table["name"], table["buildspec"]
Expand Down Expand Up @@ -221,7 +221,11 @@ def print_by_query(
console.print(f"[red]Log File: {test['logpath']}")

if test["metrics"]:
table = Table("[blue]Name", "[blue]Value", title="Metrics")
table = Table(
Column("Name", overflow="fold", header_style="blue"),
Column("Value", overflow="fold", header_style="blue"),
title="Metrics",
)
for name, values in test["metrics"].items():
table.add_row(name, values)

Expand Down
22 changes: 13 additions & 9 deletions buildtest/cli/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import random
import sys

from rich.table import Table
from rich.table import Column, Table

from buildtest.defaults import BUILD_REPORT, BUILDTEST_REPORTS, console
from buildtest.exceptions import BuildTestError
Expand Down Expand Up @@ -497,7 +497,11 @@ def process_report(self):

def print_format_fields(self):
"""Displays list of format field which implements command ``buildtest report --helpformat``"""
table = Table("[blue]Field", "[blue]Description", title="Format Fields")
table = Table(
Column("Field", overflow="fold", header_style="blue"),
Column("Description", overflow="fold", header_style="blue"),
title="Format Fields",
)
for field, description in self.format_field_description.items():
table.add_row(f"[red]{field}", f"[green]{description}")

Expand All @@ -507,9 +511,9 @@ def print_filter_fields(self):
"""Displays list of help filters which implements command ``buildtest report --helpfilter``"""

table = Table(
"[blue]Field",
"[blue]Description",
"[blue]Expected Value",
Column("Field", overflow="fold", header_style="blue"),
Column("Description", overflow="fold", header_style="blue"),
Column("Expected Value", overflow="fold", header_style="blue"),
title="Filter Fields",
)

Expand Down Expand Up @@ -915,10 +919,10 @@ def report_summary(report, configuration, detailed=None, color=None):
test_breakdown = report.breakdown_by_test_names()

table = Table(title="Breakdown by test", header_style=consoleColor)
table.add_column("Name", style=consoleColor)
table.add_column("Total Pass", style=consoleColor)
table.add_column("Total Fail", style=consoleColor)
table.add_column("Total Runs", style=consoleColor)
table.add_column("Name", overflow="fold", style=consoleColor)
table.add_column("Total Pass", overflow="fold", style=consoleColor)
table.add_column("Total Fail", overflow="fold", style=consoleColor)
table.add_column("Total Runs", overflow="fold", style=consoleColor)

for k in test_breakdown.keys():
table.add_row(
Expand Down
Loading
Loading