You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2012/05/03 18:05:50 UTC

svn commit: r1333521 - /subversion/trunk/subversion/tests/cmdline/svntest/main.py

Author: stsp
Date: Thu May  3 16:05:49 2012
New Revision: 1333521

URL: http://svn.apache.org/viewvc?rev=1333521&view=rev
Log:
Disable logging with timestamps in the test suite by default.
Add a new option --log-with-timestamps that enables timestamp logging.

The output with timestamps is often too long to fit in 80 columns and it
makes copy/pasting test output harder (e.g. when fixing up expected output
during test development).

* subversion/tests/cmdline/svntest/main.py
  (log_with_timestamps): Remove this global flag. It is now an option.
  (_create_parser): Add --log-with-timestamps option.
  (execute_tests): Use the timestamp logging formatter if --log-with-timestamps
   was specified on the command line.

Modified:
    subversion/trunk/subversion/tests/cmdline/svntest/main.py

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=1333521&r1=1333520&r2=1333521&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Thu May  3 16:05:49 2012
@@ -78,18 +78,10 @@ SVN_VER_MINOR = 8
 
 default_num_threads = 5
 
-# This enables both a time stamp prefix on all log lines and a
-# '<TIME = 0.042552>' line after running every external command.
-log_with_timestamps = True
-
 # Set up logging
 logger = logging.getLogger()
 handler = logging.StreamHandler(sys.stdout)
-if log_with_timestamps:
-  formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s',
-                                '%Y-%m-%d %H:%M:%S')
-else:
-  formatter = logging.Formatter('[%(levelname)s] %(message)s')
+formatter = logging.Formatter('[%(levelname)s] %(message)s')
 handler.setFormatter(formatter)
 logger.addHandler(handler)
 
@@ -529,9 +521,8 @@ def run_command_stdin(command, error_exp
        and not any(map(lambda arg: 'prop_tests-12' in arg, varargs)):
       raise Failure("Repository diskpath in %s: %r" % (name, lines))
 
-  if log_with_timestamps:
-    stop = time.time()
-    logger.info('<TIME = %.6f>' % (stop - start))
+  stop = time.time()
+  logger.info('<TIME = %.6f>' % (stop - start))
   for x in stdout_lines:
     logger.info(x.rstrip())
   for x in stderr_lines:
@@ -903,9 +894,8 @@ def copy_repos(src_path, dst_path, head_
   load_out.close()
   load_err.close()
 
-  if log_with_timestamps:
-    stop = time.time()
-    logger.info('<TIME = %.6f>' % (stop - start))
+  stop = time.time()
+  logger.info('<TIME = %.6f>' % (stop - start))
 
   if saved_quiet is None:
     del os.environ['SVN_DBG_QUIET']
@@ -1559,6 +1549,8 @@ def _create_parser():
                     help="Set log level (numerically or symbolically). " +
                          "Symbolic levels are: CRITICAL, ERROR, WARNING, " +
                          "INFO, DEBUG")
+  parser.add_option('--log-with-timestamps', action='store_true',
+                    help="Show timestamps in test log.")
   parser.add_option('--keep-local-tmp', action='store_true',
                     help="Don't remove svn-test-work/local_tmp after test " +
                          "run is complete.  Useful for debugging failures.")
@@ -1692,6 +1684,11 @@ def execute_tests(test_list, serial_only
   else:
     parser = _create_parser()
 
+  if options.log_with_timestamps:
+    formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s',
+                                  '%Y-%m-%d %H:%M:%S')
+    handler.setFormatter(formatter)
+
   # parse the positional arguments (test nums, names)
   for arg in test_selection:
     appended = False