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

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: Address comments 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
Index: scripts/slave/annotated_checkout.py
diff --git a/scripts/slave/annotated_checkout.py b/scripts/slave/annotated_checkout.py
index effe18c73fb96834265883c7c99b23f17b510f14..9562be686d6c04524a984d0aa61b018ad459fd51 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):
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):
"""Perform a checkout with the given type and configuration.
Args:
@@ -221,13 +229,20 @@ def run(checkout_type, checkout_spec):
CHECKOUT_TYPE attribute).
checkout_spec: Configuration values needed for the type of checkout
(repository url, etc.).
+ test_mode: If we're in test_mode, just return error code and root without
+ actually doing anything.
Returns:
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()
Isaac (away) 2013/05/12 09:24:56 Would open(os.devnull, 'w') work?
iannucci 2013/05/14 04:31:35 Actually yes, that would work. For some reason I f
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 +250,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 | « PRESUBMIT.py ('k') | scripts/slave/annotated_run.py » ('j') | scripts/slave/annotated_run.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698