summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 22:47:06 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 22:47:06 +0000
commit1c3eb4893d9772c1615fc091f7edc18986051335 (patch)
treefce51a927064aeef13687abd11fa787beb2deb14 /tools
parent5db73a293a2358c29d690bd24f8eceb6b4d9404d (diff)
downloadchromium_src-1c3eb4893d9772c1615fc091f7edc18986051335.zip
chromium_src-1c3eb4893d9772c1615fc091f7edc18986051335.tar.gz
chromium_src-1c3eb4893d9772c1615fc091f7edc18986051335.tar.bz2
Add PRESUBMIT.py to tools/sharding_supervisor/
While it's being deleted relatively soon, it's easier to have checks in. R=csharp@chromium.org BUG= Review URL: https://codereview.chromium.org/12079037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179444 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/sharding_supervisor/PRESUBMIT.py24
-rwxr-xr-xtools/sharding_supervisor/sharding_supervisor.py18
-rw-r--r--tools/sharding_supervisor/stdio_buffer.py12
3 files changed, 37 insertions, 17 deletions
diff --git a/tools/sharding_supervisor/PRESUBMIT.py b/tools/sharding_supervisor/PRESUBMIT.py
new file mode 100644
index 0000000..2e12d77
--- /dev/null
+++ b/tools/sharding_supervisor/PRESUBMIT.py
@@ -0,0 +1,24 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Top-level presubmit script for sharding_supervisor.
+
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
+details on the presubmit API built into gcl.
+"""
+
+def CommonChecks(input_api, output_api):
+ output = []
+ output.extend(input_api.canned_checks.RunPylint(input_api, output_api))
+ return output
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ return CommonChecks(input_api, output_api)
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ output = CommonChecks(input_api, output_api)
+ output.extend(input_api.canned_checks.PanProjectChecks(input_api, output_api))
+ return output
diff --git a/tools/sharding_supervisor/sharding_supervisor.py b/tools/sharding_supervisor/sharding_supervisor.py
index a60598f..717efd0 100755
--- a/tools/sharding_supervisor/sharding_supervisor.py
+++ b/tools/sharding_supervisor/sharding_supervisor.py
@@ -13,8 +13,6 @@ failure for convenience. If only one shard is to be run, a single subprocess
is started for that shard and the output is identical to gtest's output.
"""
-
-import cStringIO
import itertools
import optparse
import os
@@ -31,7 +29,7 @@ from xml.dom import minidom
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(BASE_PATH, ".."))
try:
- import find_depot_tools
+ import find_depot_tools # pylint: disable=F0401,W0611
# Fixes a bug in Windows where some shards die upon starting
# TODO(charleslee): actually fix this bug
import subprocess2 as subprocess
@@ -257,12 +255,12 @@ class ShardRunner(threading.Thread):
shard = RunShard(
self.supervisor.test, self.supervisor.total_shards, index,
self.supervisor.gtest_args, subprocess.PIPE, subprocess.PIPE)
- buffer = StdioBuffer(shard)
+ buf = StdioBuffer(shard)
# Spawn two threads to collect stdio output
- stdout_collector_thread = buffer.handle_pipe(sys.stdout, shard.stdout)
- stderr_collector_thread = buffer.handle_pipe(sys.stderr, shard.stderr)
+ stdout_collector_thread = buf.handle_pipe(sys.stdout, shard.stdout)
+ stderr_collector_thread = buf.handle_pipe(sys.stderr, shard.stderr)
while shard_running:
- pipe, line = buffer.readline()
+ pipe, line = buf.readline()
if pipe is None and line is None:
shard_running = False
if not line and not shard_running:
@@ -432,7 +430,7 @@ class ShardingSupervisor(object):
for shard_index in range(self.num_shards_to_run):
while True:
try:
- pipe, line = self.shard_output[shard_index].get(True, self.timeout)
+ _, line = self.shard_output[shard_index].get(True, self.timeout)
except Queue.Empty:
# Shard timed out, notice failure and move on.
self.LogShardFailure(shard_index)
@@ -440,7 +438,7 @@ class ShardingSupervisor(object):
# processing in the main thread.
# TODO(maruel): Make sure the worker thread terminates.
sys.stdout.write('TIMED OUT\n\n')
- LogTestFailure(
+ self.LogTestFailure(
'FAILURE: SHARD %d TIMED OUT; %d seconds' % (
shard_index, self.timeout))
break
@@ -453,7 +451,7 @@ class ShardingSupervisor(object):
for shard_index in range(self.num_shards_to_run):
while True:
try:
- pipe, line = self.shard_output[shard_index].get(False)
+ _, line = self.shard_output[shard_index].get(False)
except Queue.Empty:
# Shard timed out, notice failure and move on.
self.LogShardFailure(shard_index)
diff --git a/tools/sharding_supervisor/stdio_buffer.py b/tools/sharding_supervisor/stdio_buffer.py
index 50184f4..d16220a 100644
--- a/tools/sharding_supervisor/stdio_buffer.py
+++ b/tools/sharding_supervisor/stdio_buffer.py
@@ -4,8 +4,6 @@
"""Syncronized Standard IO Linebuffer implemented with cStringIO."""
import cStringIO
-import os
-import sys
import threading
import Queue
@@ -20,21 +18,21 @@ class StdioBuffer(object):
"""Helper method for collecting stdio output. Output is collected until
a newline is seen, at which point an event is triggered and the line is
pushed to a buffer as a (stdio, line) tuple."""
- buffer = cStringIO.StringIO()
+ buf = cStringIO.StringIO()
pipe_running = True
while pipe_running:
char = program_pipe.read(1)
if not char and self.shard.poll() is not None:
pipe_running = False
- buffer.write(char)
+ buf.write(char)
if char == '\n' or not pipe_running:
- line = buffer.getvalue()
+ line = buf.getvalue()
if line:
self.queue.put((system_pipe, line))
if not pipe_running:
self.queue.put((system_pipe, None))
- buffer.close()
- buffer = cStringIO.StringIO()
+ buf.close()
+ buf = cStringIO.StringIO()
def handle_pipe(self, system_pipe, program_pipe):
t = threading.Thread(target=self._pipe_handler, args=[system_pipe,