[PATCH] D68801: [LNT] Python 3 support: print unknown metric with str

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 08:50:09 PDT 2019


thopre created this revision.
thopre added reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls.
thopre added a parent revision: D68800: [LNT] Python 3 support: adapt csv reader open.
thopre added a child revision: D68802: [LNT] Python 3 support: fix writing report to tmp file.

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.


https://reviews.llvm.org/D68801

Files:
  lnt/server/db/testsuitedb.py
  tests/server/db/yamlschema.shtest


Index: tests/server/db/yamlschema.shtest
===================================================================
--- tests/server/db/yamlschema.shtest
+++ tests/server/db/yamlschema.shtest
@@ -20,7 +20,7 @@
 #
 # Inserting with an extra field shouldn't work just yet
 # RUN: not lnt import "%t.install" -s my_suite "%S/Inputs/customschema-report2.json" 2>&1 | FileCheck %s --check-prefix=NOTUPGRADED
-# NOTUPGRADED: Metric u'newfield' unknown in suite
+# NOTUPGRADED: Metric 'newfield' unknown in suite
 
 # Upgrading to a schema with metrics/fields removed should fail
 # RUN: rm -f "%t.install/schemas/my_suite.yaml"
Index: lnt/server/db/testsuitedb.py
===================================================================
--- lnt/server/db/testsuitedb.py
+++ lnt/server/db/testsuitedb.py
@@ -1045,7 +1045,7 @@
                     continue
                 field = field_dict.get(key)
                 if field is None and key != 'profile':
-                    raise ValueError("test %r: Metric %r unknown in suite " %
+                    raise ValueError("test %s: Metric '%s' unknown in suite " %
                                      (name, key))
 
                 if not isinstance(values, list):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68801.224367.patch
Type: text/x-patch
Size: 1201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/a0deaac6/attachment.bin>


More information about the llvm-commits mailing list