Skip to content

Commit

Permalink
Improved report visuals. Added timing stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictraut committed Dec 26, 2023
1 parent 89d41d3 commit 448fffe
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 39 deletions.
1 change: 1 addition & 0 deletions conformance/results/mypy/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "mypy 1.8.0"
test_duration = 0.31742215156555176
1 change: 1 addition & 0 deletions conformance/results/pyre/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "pyre 0.9.19"
test_duration = 1.2770380973815918
1 change: 1 addition & 0 deletions conformance/results/pyright/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "pyright 1.1.343"
test_duration = 0.7825243473052979
1 change: 1 addition & 0 deletions conformance/results/pytype/version.toml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
version = "pytype 2023.12.18"
test_duration = 18.681317806243896
83 changes: 54 additions & 29 deletions conformance/results/results.html

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions conformance/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
from pathlib import Path
import sys
from time import time
from typing import Sequence

import tomli
Expand All @@ -21,15 +22,19 @@ def run_tests(
test_cases: Sequence[Path],
):
print(f"Running tests for {type_checker.name}")

test_start_time = time()
tests_output = type_checker.run_tests([file.name for file in test_cases])
test_duration = time() - test_start_time

results_dir = root_dir / "results" / type_checker.name

for test_case in test_cases:
update_output_for_test(
type_checker, results_dir, test_case, tests_output.get(test_case.name, "")
)

update_type_checker_version(type_checker, root_dir)
update_type_checker_info(type_checker, root_dir, test_duration)


def update_output_for_test(
Expand Down Expand Up @@ -74,7 +79,7 @@ def update_output_for_test(
tomlkit.dump(existing_results, f)


def update_type_checker_version(type_checker: TypeChecker, root_dir: Path):
def update_type_checker_info(type_checker: TypeChecker, root_dir: Path, test_duration: float):
# Record the version of the type checker used for the latest run.
version_file = root_dir / "results" / type_checker.name / "version.toml"

Expand All @@ -86,6 +91,7 @@ def update_type_checker_version(type_checker: TypeChecker, root_dir: Path):
existing_info = {}

existing_info["version"] = type_checker.get_version()
existing_info["test_duration"] = test_duration

version_file.parent.mkdir(parents=True, exist_ok=True)
with open(version_file, "w") as f:
Expand Down
11 changes: 8 additions & 3 deletions conformance/src/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ def generate_summary_html(root_dir: Path):
existing_info = {}

version = existing_info["version"] or "Unknown version"
test_duration = existing_info.get("test_duration")

summary_html += f"<div><h4>{version}</h4></div>\n"
summary_html += f"<div class='tc-header'><span class='tc-name'>{version}"
if test_duration is not None:
summary_html += f"<span class='tc-time'>({test_duration:.2f}sec)</span>\n"
summary_html += '</div>\n'
summary_html += '<div class="table_container"><table>\n'
summary_html += '<tr><th class="column spacer" colspan="4"></th></tr>\n'

for test_group_name, test_group in test_groups.items():
tests_in_group = [
Expand Down Expand Up @@ -91,8 +96,8 @@ def generate_summary_html(root_dir: Path):
summary_html += f'<th class="column col2 {conformance_class}">{conformance}</th>'
summary_html += f'<th class="column col3">{notes}</th></tr>\n'

# Add a spacer row after this group to help with readability.
summary_html += '<tr><th class="column" colspan="4"></th></tr>\n'
# Add spacer row after this group to help with readability.
summary_html += '<tr><th class="column spacer" colspan="4"></th></tr>\n'

summary_html += "</table></div>\n"

Expand Down
27 changes: 22 additions & 5 deletions conformance/src/results_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
font-weight: normal;
}

th {
background-color: #f8f8f8;
}

.content_container {
margin: 20px;
}
Expand All @@ -57,7 +53,6 @@
}

.column {
background-color: #f8f8f8;
padding-left: 8px;
padding-right: 8px;
padding-top: 4px;
Expand All @@ -71,6 +66,12 @@
border: 0px solid #000;
}

.spacer {
border-color: #f0f0f0;
border-style: solid;
border-bottom-width: 1px;
}

.col1 {
width: 25%;
vertical-align: top;
Expand All @@ -86,6 +87,22 @@
vertical-align: top;
}

.tc-header {
margin-top: 20px;
margin-bottom: 8px;
}

.tc-name {
font-size: 18px;
font-weight: bold;
}

.tc-time {
margin-left: 8px;
font-size: 12px;
font-weight: normal;
}

.test_group {
font-size: 10pt;
font-weight: bold;
Expand Down

0 comments on commit 448fffe

Please sign in to comment.