Skip to content

Commit ed0c7da

Browse files
author
Thomas Preud'homme
committed
[LNT] Python 3 support: print unknown metric with str
Summary: When encountering an unknown metric, LNT throws a ValueError with a message indicating the problem. That message uses %r and thus `__repr__` to print the metric name which leads to difference between Python 2 and Python 3 since the former prefix unicode string with a 'u' but the latter do not. This leads to a failure of server/db/yamlschema.shtest. This commit uses %s and thus `__str__` to get a consistent display and adapt the test accordingly. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls, leandron, PrzemekWirkus Reviewed By: PrzemekWirkus Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D68801
1 parent 860a51b commit ed0c7da

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lnt/server/db/testsuitedb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ def _importSampleValues(self, session, tests_data, run, config):
10541054
continue
10551055
field = field_dict.get(key)
10561056
if field is None and key != 'profile':
1057-
raise ValueError("test %r: Metric %r unknown in suite " %
1057+
raise ValueError("test %s: Metric '%s' unknown in suite " %
10581058
(name, key))
10591059

10601060
if not isinstance(values, list):

tests/server/db/yamlschema.shtest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#
2121
# Inserting with an extra field shouldn't work just yet
2222
# RUN: not lnt import "%t.install" -s my_suite "%S/Inputs/customschema-report2.json" 2>&1 | FileCheck %s --check-prefix=NOTUPGRADED
23-
# NOTUPGRADED: Metric u'newfield' unknown in suite
23+
# NOTUPGRADED: Metric 'newfield' unknown in suite
2424

2525
# Upgrading to a schema with metrics/fields removed should fail
2626
# RUN: rm -f "%t.install/schemas/my_suite.yaml"

0 commit comments

Comments
 (0)