Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Unified Diff: scripts/slave/annotated_checkout.py

Issue 14988009: First cut of testing infrastructure for recipes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Add coverage to third_party. The C module is a speed-only optimization. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/annotated_run.py » ('j') | scripts/slave/annotated_run.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/annotated_checkout.py
diff --git a/scripts/slave/annotated_checkout.py b/scripts/slave/annotated_checkout.py
index effe18c73fb96834265883c7c99b23f17b510f14..d236a5fd0170c3c7da340b2ca7a7f6e8e4462eea 100755
--- a/scripts/slave/annotated_checkout.py
+++ b/scripts/slave/annotated_checkout.py
@@ -12,11 +12,12 @@ point. If that builder's factory_properties include a spec for a checkout, then
the work of actually performing that checkout is done here.
"""
+import cStringIO as StringIO
import optparse
import os
+import pipes
import subprocess
import sys
-import pipes
from common import annotator
from common import chromium_utils
@@ -75,6 +76,9 @@ class Checkout(object):
def __init__(self, spec):
self.spec = spec
+ def setup(self):
+ pass
+
def clean(self):
pass
@@ -104,6 +108,13 @@ class GclientCheckout(Checkout):
def __init__(self, *args, **kwargs):
super(GclientCheckout, self).__init__(*args, **kwargs)
assert 'solutions' in self.spec
+
+ @classmethod
+ def run_gclient(cls, *cmd):
+ print 'Running: gclient %s' % ' '.join(pipes.quote(x) for x in cmd)
+ subprocess.check_call((cls.gclient_path,)+cmd)
+
+ def setup(self):
spec_string = ''
for key in self.spec:
# We should be using json.dumps here, but gclient directly execs the dict
@@ -112,11 +123,6 @@ class GclientCheckout(Checkout):
spec_string += '%s = %s\n' % (key, str(self.spec[key]))
self.run_gclient('config', '--spec', spec_string)
- @classmethod
- def run_gclient(cls, *cmd):
- print 'Running: gclient %s' % ' '.join(pipes.quote(x) for x in cmd)
- subprocess.check_call((cls.gclient_path,)+cmd)
-
def clean(self):
self.run_gclient('revert', '--nohooks')
@@ -172,6 +178,8 @@ class GitCheckout(Checkout):
if not dir_path: # ex: ssh://host:repo/foobar/.git
dir_path = dir_path.rsplit('/', 1)[-1]
self.cwd = os.path.abspath(os.path.join(os.curdir, dir_path))
+
+ def setup(self, *args, **kwargs):
Vadim Shtayura 2013/05/11 00:33:32 Why 'args' and 'kwargs' are here considering they
iannucci 2013/05/11 04:12:27 Done. Not sure how that got there...
if not os.path.exists(self.cwd):
os.makedirs(self.cwd)
@@ -213,7 +221,7 @@ class SvnCheckout(Checkout):
CHECKOUT_TYPE = 'svn'
-def run(checkout_type, checkout_spec):
+def run(checkout_type, checkout_spec, test_mode=False):
Vadim Shtayura 2013/05/11 00:33:32 Update 'Args' section of the doc string to include
iannucci 2013/05/11 04:12:27 Done.
"""Perform a checkout with the given type and configuration.
Args:
@@ -226,8 +234,13 @@ def run(checkout_type, checkout_spec):
Tuple of (<retcode>, <root_path>) where root_path is the absolute path
to the 'root' of the checkout (as defined by |checkout_type|).
"""
+ stream = sys.stdout
+ if test_mode:
+ stream = StringIO.StringIO()
stream = annotator.StructuredAnnotationStream(
- seed_steps=['checkout_setup', 'checkout_clean', 'checkout'])
+ seed_steps=['checkout_setup', 'checkout_clean', 'checkout'],
+ stream=stream)
+
with stream.step('checkout_setup') as s:
try:
checkout = CheckoutFactory(checkout_type, checkout_spec)
@@ -235,6 +248,9 @@ def run(checkout_type, checkout_spec):
s.step_text(e)
s.step_failure()
return (1, None)
+ if test_mode:
+ return (0, checkout.root())
+ checkout.setup()
with stream.step('checkout_clean') as s:
checkout.clean()
with stream.step('checkout') as s:
« no previous file with comments | « no previous file | scripts/slave/annotated_run.py » ('j') | scripts/slave/annotated_run.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698