run-tests: move newline out of colorized message
authorMartin von Zweigbergk <martinvonz@google.com>
Tue, 17 Oct 2017 10:33:27 -0700
changeset 34842 8bce3e51b101
parent 34841 6bfe43dd20eb
child 34843 df871c41bd00
run-tests: move newline out of colorized message The leading newline before "ERROR:" led to an incorrect lexing of the message and the newline got lost. The fixed formatting can be seen in the test case. The reason we didn't notice before was that the bad formatting just led to the loss of a blank line in the test. However, there are other cases where it would be joined with a line saying "Accept this change? [n]" or "Reference output has changed (run again to prompt changes)". Differential Revision: https://phab.mercurial-scm.org/D1159
tests/run-tests.py
tests/test-run-tests.t
--- a/tests/run-tests.py	Tue Oct 17 11:07:18 2017 -0700
+++ b/tests/run-tests.py	Tue Oct 17 10:33:27 2017 -0700
@@ -1663,7 +1663,9 @@
                     self.stream.write('t')
                 else:
                     if not self._options.nodiff:
-                        formatted = '\nERROR: %s output changed\n' % test
+                        self.stream.write('\n')
+                        # Exclude the '\n' from highlighting to lex correctly
+                        formatted = 'ERROR: %s output changed\n' % test
                         self.stream.write(highlightmsg(formatted, self.color))
                     self.stream.write('!')
 
--- a/tests/test-run-tests.t	Tue Oct 17 11:07:18 2017 -0700
+++ b/tests/test-run-tests.t	Tue Oct 17 10:33:27 2017 -0700
@@ -131,6 +131,7 @@
   \x1b[38;5;34m+  bar*baz (glob)\x1b[39m (esc)
      bar*bad (glob)
   \x1b[38;5;124m-  bar*baz (glob)\x1b[39m (esc)
+  
   \x1b[38;5;88mERROR: \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m output changed\x1b[39m (esc)
   !
   \x1b[38;5;88mFailed \x1b[39m\x1b[38;5;9mtest-failure.t\x1b[39m\x1b[38;5;88m: output changed\x1b[39m (esc)