From 771b14acb2270ed341fc41b3d77acaa1032f7072 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 13 Mar 2017 20:45:10 -0700 Subject: [PATCH] Sort test messages for deterministic output. (#22581) --- test/runner/lib/test.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/runner/lib/test.py b/test/runner/lib/test.py index 2393a2202c..2d42301308 100644 --- a/test/runner/lib/test.py +++ b/test/runner/lib/test.py @@ -191,12 +191,15 @@ class TestFailure(TestResult): """ :type command: str :type test: str - :type python_version: str - :type messages: list[TestMessage] - :type summary: str + :type python_version: str | None + :type messages: list[TestMessage] | None + :type summary: str | None """ super(TestFailure, self).__init__(command, test, python_version) + if messages: + messages = sorted(messages, key=lambda m: m.sort_key) + self.messages = messages self.summary = summary @@ -338,3 +341,10 @@ class TestMessage(object): msg = self.message return '%s:%s:%s: %s' % (self.path, self.line, self.column, msg) + + @property + def sort_key(self): + """ + :rtype: str + """ + return '%s:%6d:%6d:%s:%s' % (self.path, self.line, self.column, self.code or '', self.message)