diff --git a/tests/run-tests.py b/tests/run-tests.py
index ab93029ab622d4c6167fe792fc53dcd73fc86545_dGVzdHMvcnVuLXRlc3RzLnB5..ea7ad8c3988aa27266b24b3cc1a52bcdcb91b0e0_dGVzdHMvcnVuLXRlc3RzLnB5 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -464,6 +464,8 @@
     after = {}
     expected = {}
     for n, l in enumerate(t):
+        if not l.endswith('\n'):
+            l += '\n'
         if l.startswith('  $ '): # commands
             after.setdefault(pos, []).append(l)
             prepos = pos
@@ -480,8 +482,6 @@
             # non-command/result - queue up for merged output
             after.setdefault(pos, []).append(l)
 
-    if script and not script[-1].endswith('\n'):
-        script[-1] = script[-1] + '\n'
     script.append('echo %s %s $?\n' % (salt, n + 1))
 
     fd, name = tempfile.mkstemp(suffix='hg-tst')
diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
index ab93029ab622d4c6167fe792fc53dcd73fc86545_dGVzdHMvdGVzdC1xcmVjb3JkLnQ=..ea7ad8c3988aa27266b24b3cc1a52bcdcb91b0e0_dGVzdHMvdGVzdC1xcmVjb3JkLnQ= 100644
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -302,5 +302,3 @@
 After qrecord b.patch 'diff'
 
   $ hg diff --nodates
-
-End
\ No newline at end of file