Skip to content

Commit

Permalink
Refactoring: change how tool-information is passed to HTML tables
Browse files Browse the repository at this point in the history
So far we prerender most of the entries in the table with the benchmark
setup. Now we change that for the row "Tool" because we want to extend
it with richer data.

No actually visible change so far.
  • Loading branch information
PhilippWendler committed Nov 3, 2023
1 parent b19cfbe commit 3809c22
Show file tree
Hide file tree
Showing 56 changed files with 410 additions and 163 deletions.
31 changes: 21 additions & 10 deletions benchexec/tablegenerator/htmltable.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,27 @@ def _prepare_benchmark_setup_data(
# It is used for calculating the column spans of the header cells.
runSetWidths = [len(runSetResult.columns) for runSetResult in runSetResults]

def get_row(rowName, format_string, collapse=False, onlyIf=None, default="Unknown"):
def format_cell(attributes):
if onlyIf and onlyIf not in attributes:
formatStr = default
else:
formatStr = format_string
return formatStr.format_map(collections.defaultdict(str, attributes))

def format_string_cell(attributes, format_string, onlyIf=None, default="Unknown"):
if onlyIf and onlyIf not in attributes:
formatStr = default
else:
formatStr = format_string
return formatStr.format_map(collections.defaultdict(str, attributes))

def tool_data_cell(attributes):
keys = ["tool", "version"]
return {k: str(attributes[k]) for k in keys if attributes.get(k)}

def get_row(
rowName,
*format_args,
cell_format=format_string_cell,
collapse=False,
**format_kwargs,
):
values = [
format_cell(runSetResult.attributes) for runSetResult in runSetResults
cell_format(runSetResult.attributes, *format_args, **format_kwargs)
for runSetResult in runSetResults
]
if not any(values):
return None # skip row without values completely
Expand Down Expand Up @@ -183,7 +194,7 @@ def format_cell(attributes):
)

return {
"tool": get_row("Tool", "{tool} {version}", collapse=True),
"tool": get_row("Tool", cell_format=tool_data_cell, collapse=True),
"displayName": get_row("Benchmark", "{displayName}", collapse=True),
"limit": get_row(
"Limits",
Expand Down
2 changes: 1 addition & 1 deletion benchexec/tablegenerator/react-table/build/main.min.js

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions benchexec/tablegenerator/react-table/src/components/Summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,32 @@ const Summary = (props) => {
));
};

const renderToolNameAndVersion = ({ tool, version }) => {
return (
<>
{tool} {version}
</>
);
};

/* ++++++++++++++ Table render functions ++++++++++++++ */

const renderEnvironmentRow = (row, text, colSpan, j) => {
const renderRow = (row, text, colSpan, j) => {
const isOptionRow = row === "options";
const isToolRow = row === "tool";
return (
<td
colSpan={colSpan}
key={text + j}
className={`header__tool-row${isOptionRow && " options"}`}
>
{isOptionRow ? <ul>{renderOptions(text)}</ul> : text}
{isOptionRow ? (
<ul>{renderOptions(text)}</ul>
) : isToolRow ? (
renderToolNameAndVersion(text)
) : (
text
)}
</td>
);
};
Expand All @@ -57,11 +72,11 @@ const Summary = (props) => {
{infos
.map((row) => props.tableHeader[row])
.filter((row) => row !== null)
.map((row, i) => (
.map((row) => (
<tr key={"tr-" + row.id} className={row.id}>
<th key={"td-" + row.id}>{row.name}</th>
{row.content.map((tool, j) =>
renderEnvironmentRow(row.id, tool[0], tool[1], j),
renderRow(row.id, tool[0], tool[1], j),
)}
</tr>
))}
Expand Down
2 changes: 1 addition & 1 deletion benchexec/tablegenerator/react-table/src/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"name": "benchexec/tablegenerator/test_integration/results/"
},
"tool": {
"content": [["CPAchecker 1.4-svn 15944M", 6]],
"content": [[{"tool": "CPAchecker", "version": "1.4-svn 15944M"}, 6]],
"id": "tool",
"name": "Tool"
}
Expand Down
Loading

0 comments on commit 3809c22

Please sign in to comment.