summaryrefslogtreecommitdiff
path: root/testsuite/driver
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-12-02 15:14:42 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-12-05 16:07:49 -0500
commitc4ca29c796fa86ad9d5cd4dfa1a5cdd4e0565fb0 (patch)
treec7d70268cce7574bd1aa3c1c0d57de903f5bd52f /testsuite/driver
parent92a52aaaf48420335c4beda45cf40388d305c3f2 (diff)
downloadhaskell-c4ca29c796fa86ad9d5cd4dfa1a5cdd4e0565fb0.tar.gz
testsuite: Use colors more consistently
Diffstat (limited to 'testsuite/driver')
-rw-r--r--testsuite/driver/perf_notes.py12
-rw-r--r--testsuite/driver/runtests.py9
2 files changed, 12 insertions, 9 deletions
diff --git a/testsuite/driver/perf_notes.py b/testsuite/driver/perf_notes.py
index dcaa3d11ca..6607023622 100644
--- a/testsuite/driver/perf_notes.py
+++ b/testsuite/driver/perf_notes.py
@@ -23,6 +23,7 @@ from collections import namedtuple
from math import ceil, trunc
from testutil import passed, failBecause, testing_metrics
+from term_color import Color, colored
from my_typing import *
@@ -82,6 +83,15 @@ class MetricChange(Enum):
# The metric decreased.
Decrease = 'Decrease'
+ def __str__(self):
+ strings = {
+ MetricChange.NewMetric: colored(Color.BLUE, "new"),
+ MetricChange.NoChange: colored(Color.WHITE, "unchanged"),
+ MetricChange.Increase: colored(Color.RED, "increased"),
+ MetricChange.Decrease: colored(Color.GREEN, "decreased")
+ }
+ return strings[self]
+
AllowedPerfChange = NamedTuple('AllowedPerfChange',
[('direction', MetricChange),
('metrics', List[str]),
@@ -562,7 +572,7 @@ def check_stats_change(actual: PerfStat,
# Print errors and create pass/fail object.
result = passed()
if not change_allowed:
- error = change.value + ' from ' + baseline.perfStat.test_env + \
+ error = str(change) + ' from ' + baseline.perfStat.test_env + \
' baseline @ HEAD~' + str(baseline.commitDepth)
print(actual.metric, error + ':')
result = failBecause('stat ' + error, tag='stat')
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index 0b1f8d69fe..9eed68bc37 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -335,13 +335,6 @@ def cleanup_and_exit(exitcode):
exit(exitcode)
def tabulate_metrics(metrics: List[PerfMetric]) -> None:
- direction_strings = {
- MetricChange.NewMetric: colored(Color.BLUE, "new"),
- MetricChange.NoChange: colored(Color.WHITE, "unchanged"),
- MetricChange.Increase: colored(Color.RED, "increased"),
- MetricChange.Decrease: colored(Color.GREEN, "decreased")
- }
-
for metric in sorted(metrics, key=lambda m: (m.stat.test, m.stat.way)):
print("{test:24} {metric:40} {value:15.3f}".format(
test = "{}({})".format(metric.stat.test, metric.stat.way),
@@ -357,7 +350,7 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None:
herald = "(baseline @ HEAD~{depth})".format(
depth = metric.baseline.commitDepth),
value = val0,
- direction = direction_strings[metric.change],
+ direction = metric.change,
rel = abs(rel)
))