You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by rh...@apache.org on 2010/06/21 15:11:55 UTC

svn commit: r956568 - in /subversion/trunk: build/run_tests.py subversion/tests/cmdline/svntest/main.py

Author: rhuijben
Date: Mon Jun 21 13:11:55 2010
New Revision: 956568

URL: http://svn.apache.org/viewvc?rev=956568&view=rev
Log:
Revert r956108, r956106, r956104, r956102, r956101, r956096, r956094, 
r956085 and r956046 to: 
 * fix running tests with different src and build directory
   (= default configuration on Windows)
 * fix running tests in parallel
 and probably other issues that aren't caught because these issues
 broke earlier.

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

Modified: subversion/trunk/build/run_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/build/run_tests.py?rev=956568&r1=956567&r2=956568&view=diff
==============================================================================
--- subversion/trunk/build/run_tests.py (original)
+++ subversion/trunk/build/run_tests.py Mon Jun 21 13:11:55 2010
@@ -42,9 +42,9 @@ separated list of test numbers; the defa
 '''
 
 # A few useful constants
-LINE_LENGTH = 45
+LINE_LENGTH = 40
 
-import os, sys, subprocess, imp
+import os, sys, subprocess
 from datetime import datetime
 
 import getopt
@@ -215,14 +215,43 @@ class TestHarness:
       self.log.close()
       self.log = None
 
-  def _run_c_test(self, prog, test_nums, dot_count):
-    'Run a c test, escaping parameters as required.'
+  def _run_test(self, prog, test_nr, total_tests):
+    "Run a single test. Return the test's exit code."
+
+    if self.log:
+      log = self.log
+    else:
+      log = sys.stdout
+
+    test_nums = None
+    if '#' in prog:
+      prog, test_nums = prog.split('#')
+
     progdir, progbase = os.path.split(prog)
+    if self.log:
+      # Using write here because we don't want even a trailing space
+      test_info = '%s [%d/%d]' % (progbase, test_nr + 1, total_tests)
+      sys.stdout.write('Running tests in %s' % (test_info, ))
+      sys.stdout.write('.'*(LINE_LENGTH - len(test_info)))
+      sys.stdout.flush()
 
-    sys.stdout.write('.' * dot_count)
-    sys.stdout.flush()
+    log.write('START: %s\n' % progbase)
+    log.flush()
 
-    if os.access(progbase, os.X_OK):
+    start_time = datetime.now()
+    if progbase[-3:] == '.py':
+      progname = sys.executable
+      cmdline = [progname,
+                 os.path.join(self.srcdir, prog)]
+      if self.base_url is not None:
+        cmdline.append('--url=' + self.base_url)
+      if self.enable_sasl is not None:
+        cmdline.append('--enable-sasl')
+      if self.parallel is not None:
+        cmdline.append('--parallel')
+      if self.config_file is not None:
+        cmdline.append('--config-file=' + self.config_file)
+    elif os.access(prog, os.X_OK):
       progname = './' + progbase
       cmdline = [progname,
                  '--srcdir=' + os.path.join(self.srcdir, progdir)]
@@ -255,127 +284,10 @@ class TestHarness:
       test_nums = test_nums.split(',')
       cmdline.extend(test_nums)
 
-    return self._run_prog(progname, cmdline)
-
-  def _run_py_test(self, prog, test_nums, dot_count):
-    'Run a python test, passing parameters as needed.'
-    progdir, progbase = os.path.split(prog)
-
-    old_path = sys.path[:]
-    sys.path = [progdir] + sys.path
-
-    try:
-      prog_mod = imp.load_module(progbase[:-3], open(prog, 'r'), prog,
-                                 ('.py', 'U', imp.PY_SOURCE))
-    except:
-      print('Don\'t know what to do about ' + progbase)
-      raise
-
-    import svntest.main
-
-    # set up our options
-    svntest.main.create_default_options()
-    if self.base_url is not None:
-      svntest.main.options.test_area_url = self.base_url
-    if self.enable_sasl is not None:
-      svntest.main.options.enable_sasl = True
-    if self.parallel is not None:
-      svntest.main.options.parallel = True
-    if self.config_file is not None:
-      svntest.main.options.config_file = self.config_file
-    if self.verbose is not None:
-      svntest.main.options.verbose = True
-    if self.cleanup is not None:
-      svntest.main.options.cleanup = True
-    if self.fs_type is not None:
-      svntest.main.options.fs_type = self.fs_type
-    if self.http_library is not None:
-      svntest.main.options.http_library = self.http_library
-    if self.server_minor_version is not None:
-      svntest.main.options.server_minor_version = self.server_minor_version
-    if self.list_tests is not None:
-      svntest.main.options.list_tests = True
-    if self.svn_bin is not None:
-      svntest.main.options.svn_bin = self.svn_bin
-    if self.fsfs_sharding is not None:
-      svntest.main.options.fsfs_sharding = self.fsfs_sharding
-    if self.fsfs_packing is not None:
-      svntest.main.options.fsfs_packing = self.fsfs_packing
-
-    # setup the output pipes
-    if self.log:
-      sys.stdout.flush()
-      sys.stderr.flush()
-      self.log.flush()
-      old_stdout = os.dup(1)
-      old_stderr = os.dup(2)
-      os.dup2(self.log.fileno(), 1)
-      os.dup2(self.log.fileno(), 2)
-
-    # This has to be class-scoped for use in the progress_func()
-    self.dots_written = 0
-    def progress_func(completed, total):
-      dots = (completed * dot_count) / total
-
-      dots_to_write = dots - self.dots_written
-      if self.log:
-        os.write(old_stdout, '.' * dots_to_write)
-      else:
-        sys.stdout.write(old_stdout, '.' * dots_to_write)
-        sys.stdout.flush()
-
-      self.dots_written = dots
-
-    # run the tests
-    svntest.testcase.TextColors.disable()
-    failed = svntest.main.execute_tests(prog_mod.test_list,
-                                        test_name=progbase,
-                                        progress_func=progress_func)
-
-    # restore some values
-    sys.path = old_path
-    if self.log:
-      os.dup2(old_stdout, 1)
-      os.dup2(old_stderr, 2)
-      os.close(old_stdout)
-      os.close(old_stderr)
-
-    return failed
-
-  def _run_test(self, prog, test_nr, total_tests):
-    "Run a single test. Return the test's exit code."
-
-    if self.log:
-      log = self.log
-    else:
-      log = sys.stdout
-
-    test_nums = None
-    if '#' in prog:
-      prog, test_nums = prog.split('#')
-
-    progdir, progbase = os.path.split(prog)
-    if self.log:
-      # Using write here because we don't want even a trailing space
-      test_info = '%s [%d/%d]' % (progbase, test_nr + 1, total_tests)
-      sys.stdout.write('Running tests in %s' % (test_info, ))
-      sys.stdout.flush()
-
-    log.write('START: %s\n' % progbase)
-    log.flush()
-
-    start_time = datetime.now()
-
-    progabs = os.path.abspath(os.path.join(self.srcdir, prog))
     old_cwd = os.getcwd()
     try:
       os.chdir(progdir)
-      if progbase[-3:] == '.py':
-        failed = self._run_py_test(progabs, test_nums,
-                                   (LINE_LENGTH - len(test_info)))
-      else:
-        failed = self._run_c_test(prog, test_nums,
-                                  (LINE_LENGTH - len(test_info)))
+      failed = self._run_prog(progname, cmdline)
     except:
       os.chdir(old_cwd)
       raise

Modified: subversion/trunk/subversion/tests/cmdline/svntest/main.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/svntest/main.py?rev=956568&r1=956567&r2=956568&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/svntest/main.py (original)
+++ subversion/trunk/subversion/tests/cmdline/svntest/main.py Mon Jun 21 13:11:55 2010
@@ -424,7 +424,6 @@ def wait_on_pipe(waiter, binary_mode, st
     if exit_code and options.verbose:
       sys.stderr.write("CMD: %s exited with %d\n"
                        % (command_string, exit_code))
-      sys.stderr.flush()
     return stdout_lines, stderr_lines, exit_code
 
 def spawn_process(command, bufsize=0, binary_mode=0, stdin_lines=None,
@@ -1227,7 +1226,7 @@ def run_one_test(n, test_list, finished_
   exit_code = TestRunner(test_list[n], n).run()
   return exit_code
 
-def _internal_run_tests(test_list, testnums, parallel, progress_func):
+def _internal_run_tests(test_list, testnums, parallel):
   """Run the tests from TEST_LIST whose indices are listed in TESTNUMS.
 
   If we're running the tests in parallel spawn as much parallel processes
@@ -1240,12 +1239,9 @@ def _internal_run_tests(test_list, testn
   tests_started = 0
 
   if not parallel:
-    for i, testnum in enumerate(testnums):
+    for testnum in testnums:
       if run_one_test(testnum, test_list) == 1:
           exit_code = 1
-      # signal progress
-      if progress_func:
-        progress_func(i+1, len(testnums))
   else:
     number_queue = queue.Queue()
     for num in testnums:
@@ -1264,10 +1260,6 @@ def _internal_run_tests(test_list, testn
       results += t.results
     results.sort()
 
-    # signal some kind of progress
-    if progress_func:
-      progress_func(len(testnums), len(testnums))
-
     # terminate the line of dots
     print("")
 
@@ -1379,6 +1371,10 @@ def _parse_options(arglist=sys.argv[1:])
   return (parser, args)
 
 
+# Main func.  This is the "entry point" that all the test scripts call
+# to run their list of tests.
+#
+# This routine parses sys.argv to decide what to do.
 def run_tests(test_list, serial_only = False):
   """Main routine to run all tests in TEST_LIST.
 
@@ -1386,19 +1382,6 @@ def run_tests(test_list, serial_only = F
         appropriate exit code.
   """
 
-  sys.exit(execute_tests(test_list, serial_only))
-
-
-# Main func.  This is the "entry point" that all the test scripts call
-# to run their list of tests.
-#
-# This routine parses sys.argv to decide what to do.
-def execute_tests(test_list, serial_only = False, test_name = None,
-                  progress_func = None):
-  """Similar to run_tests(), but just returns the exit code, rather than
-  exiting the process.  This function can be used when a caller doesn't
-  want the process to die."""
-
   global pristine_url
   global svn_binary
   global svnadmin_binary
@@ -1408,9 +1391,6 @@ def execute_tests(test_list, serial_only
   global svnversion_binary
   global options
 
-  if test_name:
-    sys.argv[0] = test_name
-
   testnums = []
 
   if not options:
@@ -1523,8 +1503,7 @@ def execute_tests(test_list, serial_only
     svntest.actions.setup_pristine_repository()
 
   # Run the tests.
-  exit_code = _internal_run_tests(test_list, testnums, options.parallel,
-                                  progress_func)
+  exit_code = _internal_run_tests(test_list, testnums, options.parallel)
 
   # Remove all scratchwork: the 'pristine' repository, greek tree, etc.
   # This ensures that an 'import' will happen the next time we run.
@@ -1535,4 +1514,4 @@ def execute_tests(test_list, serial_only
   svntest.sandbox.cleanup_deferred_test_paths()
 
   # Return the appropriate exit code from the tests.
-  return exit_code
+  sys.exit(exit_code)