Patchwork [4,of,4,runs-per-test-flag] run-tests: ignore ENOENT failures when removing old .err results

login
register
mail settings
Submitter Augie Fackler
Date March 13, 2015, 7:25 p.m.
Message ID <ea4117a487cea1906a86.1426274713@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/8064/
State Accepted
Commit 9612b96730d7309315d15d4ad3d9b20aa1bc29b1
Headers show

Comments

Augie Fackler - March 13, 2015, 7:25 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1426266235 14400
#      Fri Mar 13 13:03:55 2015 -0400
# Node ID ea4117a487cea1906a86214c1961334d5c16f3f3
# Parent  ed7aba51d12b17a655fc5cb57909e427c3079de2
run-tests: ignore ENOENT failures when removing old .err results

When the same test runs in multiple threads and the previous run was a
failure, the threads can race to delete the error output. This fixes
that.
Ryan McElroy - March 14, 2015, 7:22 a.m.
On 3/13/2015 12:25 PM, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1426266235 14400
> #      Fri Mar 13 13:03:55 2015 -0400
> # Node ID ea4117a487cea1906a86214c1961334d5c16f3f3
> # Parent  ed7aba51d12b17a655fc5cb57909e427c3079de2
> run-tests: ignore ENOENT failures when removing old .err results
>
> When the same test runs in multiple threads and the previous run was a
> failure, the threads can race to delete the error output. This fixes
> that.
>
> <snip>
This series looks useful and implementation looked pretty 
straightforward to me. LGTM.
Matt Mackall - March 16, 2015, 7:22 p.m.
On Fri, 2015-03-13 at 15:25 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1426266235 14400
> #      Fri Mar 13 13:03:55 2015 -0400
> # Node ID ea4117a487cea1906a86214c1961334d5c16f3f3
> # Parent  ed7aba51d12b17a655fc5cb57909e427c3079de2
> run-tests: ignore ENOENT failures when removing old .err results

These are queued for default, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -461,7 +461,14 @@  class Test(unittest.TestCase):
 
         # Remove any previous output files.
         if os.path.exists(self.errpath):
-            os.remove(self.errpath)
+            try:
+                os.remove(self.errpath)
+            except OSError, e:
+                # We might have raced another test to clean up a .err
+                # file, so ignore ENOENT when removing a previous .err
+                # file.
+                if e.errno != errno.ENOENT:
+                    raise
 
     def run(self, result):
         """Run this test and report results against a TestResult instance."""