run-tests: minor cleanups stable
authorMatt Mackall <mpm@selenic.com>
Thu, 03 Nov 2011 15:18:10 -0500
branchstable
changeset 1003 59bd7f017103
parent 1002 9a8202faebb3
child 1004 b675519e2a5b
child 1005 d86b26020b48
run-tests: minor cleanups [ original upstream message ]
tests/run-tests.py
--- a/tests/run-tests.py	Thu Nov 03 15:08:45 2011 -0500
+++ b/tests/run-tests.py	Thu Nov 03 15:18:10 2011 -0500
@@ -559,10 +559,6 @@
     return False
 
 def tsttest(test, wd, options, replacements):
-    t = open(test)
-    out = []
-    script = []
-
     # We generate a shell script which outputs unique markers to line
     # up script results with our source. These markers include input
     # line number and the last return code
@@ -584,6 +580,11 @@
     # can generate the surrounding doctest magic
     inpython = False
 
+    f = open(test)
+    t = f.readlines()
+    f.close()
+
+    script = []
     for n, l in enumerate(t):
         if not l.endswith('\n'):
             l += '\n'
@@ -623,12 +624,11 @@
             # non-command/result - queue up for merged output
             after.setdefault(pos, []).append(l)
 
-    t.close()
-
     if inpython:
         script.append("EOF\n")
     addsalt(n + 1)
 
+    # Write out the script and execute it
     fd, name = tempfile.mkstemp(suffix='hg-tst')
     try:
         for l in script: