run-tests: make vlog a proper function stable
authorMatt Mackall <mpm@selenic.com>
Fri, 24 May 2013 14:30:43 -0500
branchstable
changeset 1238 c2b8e0ffffc8
parent 1237 ac098555f410
child 1239 02112fca2ff3
run-tests: make vlog a proper function [ original upstream message ]
tests/run-tests.py
--- a/tests/run-tests.py	Fri May 24 14:30:43 2013 -0500
+++ b/tests/run-tests.py	Fri May 24 14:30:43 2013 -0500
@@ -240,23 +240,12 @@
         parser.error("sorry, coverage options do not work when --local "
                      "is specified")
 
-    global vlog
+    global verbose
     if options.verbose:
         if options.jobs > 1 or options.child is not None:
-            pid = "[%d]" % os.getpid()
+            verbose = "[%d]" % os.getpid()
         else:
-            pid = None
-        def vlog(*msg):
-            iolock.acquire()
-            if pid:
-                print pid,
-            for m in msg:
-                print m,
-            print
-            sys.stdout.flush()
-            iolock.release()
-    else:
-        vlog = lambda *msg: None
+            verbose = ''
 
     if options.tmpdir:
         options.tmpdir = os.path.expanduser(options.tmpdir)
@@ -319,6 +308,18 @@
     for line in difflib.unified_diff(expected, output, ref, err):
         sys.stdout.write(line)
 
+verbose = False
+def vlog(*msg):
+    if verbose is not False:
+        iolock.acquire()
+        if verbose:
+            print verbose,
+        for m in msg:
+            print m,
+        print
+        sys.stdout.flush()
+        iolock.release()
+
 def findprogram(program):
     """Search PATH for a executable program"""
     for p in os.environ.get('PATH', os.defpath).split(os.pathsep):