testing: manually remove .err files
authorGregory Szorc <gps@mozilla.com>
Thu, 09 Apr 2015 12:35:37 -0700
changeset 360683 bf7d5b81119042c96a83cab33207ba36a338ee1f
parent 360682 b2f42c234e8a43c5eef617ce61aff58fcc88fb41
child 360684 561a26e437bb6febb5faed8a10e43547536cbe67
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
testing: manually remove .err files run-tests.py is supposed to do this for us. But it appears it isn't always working.
run-tests
testing/vcttesting/testing.py
--- a/run-tests
+++ b/run-tests
@@ -29,16 +29,17 @@ if __name__ == '__main__':
     import vcttesting.docker as vctdocker
     from vcttesting.testing import (
         get_docker_state,
         get_extensions,
         get_hg_version,
         get_test_files,
         run_nose_tests,
         produce_coverage_reports,
+        remove_err_files,
     )
 
     # Unbuffer stdout.
     sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
 
     parser = argparse.ArgumentParser()
     parser.add_argument('--with-hg')
     parser.add_argument('-C', '--cover', action='store_true')
@@ -163,16 +164,21 @@ if __name__ == '__main__':
     if hgversion is None:
         print('Unable to determine Mercurial version')
         sys.exit(1)
 
     os.environ['HGVERSION'] = hgversion
 
     res = 0
     if run_hg_tests:
+        # The Mercurial test harness has been observed to not remove the .err
+        # files after execution. This is probably a result of us using
+        # separate directories. Manually remove .err files.
+        remove_err_files(run_hg_tests)
+
         # We should ideally not leak containers and images. But until
         # the Mercurial test harness allows tests to register cleanup
         # actions, there is only so much we can do.
         with docker.auto_clean_orphans():
             res = subprocess.call(hg_harness_args, cwd=HERE)
 
     if options.no_unit:
         run_unit_tests = []
@@ -222,16 +228,18 @@ if __name__ == '__main__':
 
         def run_hg_tests(version, tests):
             if requested_tests:
                 tests = [t for t in tests if t in requested_tests]
 
             if not tests:
                 return
 
+            remove_err_files(tests)
+
             args = list(orig_args) + [
                 '--with-hg',
                 os.path.join(mercurials_dir, version, 'bin', 'hg'),
             ] + sorted(tests)
             args[0] = RUNTESTS
 
             print('Testing with Mercurial %s' % version)
             sys.stdout.flush()
--- a/testing/vcttesting/testing.py
+++ b/testing/vcttesting/testing.py
@@ -1,21 +1,21 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, unicode_literals
 
+import errno
 import os
 import re
 import subprocess
 import sys
 import time
 
-import concurrent.futures as futures
 from coverage import coverage
 
 
 HERE = os.path.dirname(os.path.abspath(__file__))
 ROOT = os.path.normpath(os.path.join(HERE, '..', '..'))
 
 
 PYTHON_COVERAGE_DIRS = (
@@ -239,8 +239,18 @@ def get_hg_version(hg):
     out = subprocess.check_output('%s --version' % hg,
                                   env=env, shell=True)
     out = out.splitlines()[0]
     match = re.search('version ([^\+\)]+)', out)
     if not match:
         return None
 
     return match.group(1)
+
+
+def remove_err_files(tests):
+    for t in tests:
+        err = '%s.err' % t
+        try:
+            os.remove(err)
+        except OSError as e:
+            if e.errno != errno.ENOENT:
+                raise