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

Side by Side Diff: unittests/repo_test_util.py

Issue 1997023002: recipe engine: add remote_run command (Closed) Base URL: https://github.com/luci/recipes-py.git@master
Patch Set: trybots Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « unittests/remote_run_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Utilities for testing with real repos (e.g. git).""" 5 """Utilities for testing with real repos (e.g. git)."""
6 6
7 7
8 import contextlib 8 import contextlib
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 """Returns PackageSpec corresponding to given repo.""" 74 """Returns PackageSpec corresponding to given repo."""
75 config_file = os.path.join(repo['root'], 'infra', 'config', 'recipes.cfg') 75 config_file = os.path.join(repo['root'], 'infra', 'config', 'recipes.cfg')
76 return package.PackageSpec.load_proto(package.ProtoFile(config_file)) 76 return package.PackageSpec.load_proto(package.ProtoFile(config_file))
77 77
78 def create_repo(self, name, spec): 78 def create_repo(self, name, spec):
79 """Creates a real git repo with simple recipes.cfg.""" 79 """Creates a real git repo with simple recipes.cfg."""
80 repo_dir = os.path.join(self._root_dir, name) 80 repo_dir = os.path.join(self._root_dir, name)
81 os.mkdir(repo_dir) 81 os.mkdir(repo_dir)
82 with in_directory(repo_dir): 82 with in_directory(repo_dir):
83 subprocess.check_output(['git', 'init']) 83 subprocess.check_output(['git', 'init'])
84 subprocess.check_output(['git', 'remote', 'add', 'origin', repo_dir])
84 with open('recipes.py', 'w') as f: 85 with open('recipes.py', 'w') as f:
85 f.write('import subprocess, sys\n' 86 f.write('import subprocess, sys\n'
86 'sys.exit(subprocess.call(\n' 87 'sys.exit(subprocess.call(\n'
87 ' [sys.executable, %r, "--package", %r] + sys.argv[1:]))' % ( 88 ' [sys.executable, %r, "--package", %r] + sys.argv[1:]))' % (
88 self._recipe_tool, 89 self._recipe_tool,
89 os.path.join(repo_dir, 'infra', 'config', 'recipes.cfg'))) 90 os.path.join(repo_dir, 'infra', 'config', 'recipes.cfg')))
90 subprocess.check_output(['git', 'add', 'recipes.py']) 91 subprocess.check_output(['git', 'add', 'recipes.py'])
91 rev = self.update_recipes_cfg(name, spec) 92 rev = self.update_recipes_cfg(name, spec)
92 return { 93 return {
93 'name': name, 94 'name': name,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 message = ' '.join( 262 message = ' '.join(
262 ['update %r recipe_module: ' % name] + 263 ['update %r recipe_module: ' % name] +
263 ['%s(%s)' % t for t in methods.iteritems()] 264 ['%s(%s)' % t for t in methods.iteritems()]
264 ) 265 )
265 return self.commit_in_repo(repo, message) 266 return self.commit_in_repo(repo, message)
266 267
267 def reset_repo(self, repo, revision): 268 def reset_repo(self, repo, revision):
268 """Resets repo contents to given revision.""" 269 """Resets repo contents to given revision."""
269 with in_directory(repo['root']): 270 with in_directory(repo['root']):
270 subprocess.check_output(['git', 'reset', '--hard', revision]) 271 subprocess.check_output(['git', 'reset', '--hard', revision])
OLDNEW
« no previous file with comments | « unittests/remote_run_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698