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

Side by Side Diff: unittests/repo_test_util.py

Issue 2829203002: [autoroller] All commits in updates(), only roll interesting ones. (Closed)
Patch Set: windows fix Created 3 years, 8 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/autoroll_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 LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be 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 logging 9 import logging
10 import os 10 import os
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 '#### PER-REPO CONFIGURATION (editable) ####', 116 '#### PER-REPO CONFIGURATION (editable) ####',
117 'REPO_ROOT = "."', 117 'REPO_ROOT = "."',
118 'RECIPES_CFG = os.path.join("infra", "config", "recipes.cfg")', 118 'RECIPES_CFG = os.path.join("infra", "config", "recipes.cfg")',
119 '#### END PER-REPO CONFIGURATION ####', 119 '#### END PER-REPO CONFIGURATION ####',
120 'if sys.argv[1] != "fetch":', 120 'if sys.argv[1] != "fetch":',
121 ' sys.exit(subprocess.call(', 121 ' sys.exit(subprocess.call(',
122 ' [sys.executable, %r, "--package", %r] + sys.argv[1:]))' % ( 122 ' [sys.executable, %r, "--package", %r] + sys.argv[1:]))' % (
123 self._recipe_tool, 123 self._recipe_tool,
124 os.path.join(repo_dir, 'infra', 'config', 'recipes.cfg')), 124 os.path.join(repo_dir, 'infra', 'config', 'recipes.cfg')),
125 ])) 125 ]))
126 subprocess.check_output(['git', 'add', 'recipes.py']) 126 with open('some_file', 'w') as f:
127 print >> f, 'I\'m a file'
128 subprocess.check_output(['git', 'add', 'recipes.py', 'some_file'])
127 rev = self.update_recipes_cfg(name, spec) 129 rev = self.update_recipes_cfg(name, spec)
128 return { 130 return {
129 'name': name, 131 'name': name,
130 'root': repo_dir, 132 'root': repo_dir,
131 'revision': rev, 133 'revision': rev,
132 'spec': spec, 134 'spec': spec,
133 } 135 }
134 136
135 def repo_setup(self, repo_deps): 137 def repo_setup(self, repo_deps):
136 """Creates a set of repos with recipes.cfg reflecting requested 138 """Creates a set of repos with recipes.cfg reflecting requested
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 190
189 def commit_in_repo(self, repo, message='Empty commit', 191 def commit_in_repo(self, repo, message='Empty commit',
190 author_name='John Doe', 192 author_name='John Doe',
191 author_email='john.doe@example.com'): 193 author_email='john.doe@example.com'):
192 """Creates a commit in given repo.""" 194 """Creates a commit in given repo."""
193 root = repo['root'] 195 root = repo['root']
194 196
195 env = dict(os.environ) 197 env = dict(os.environ)
196 env['GIT_AUTHOR_NAME'] = author_name 198 env['GIT_AUTHOR_NAME'] = author_name
197 env['GIT_AUTHOR_EMAIL'] = author_email 199 env['GIT_AUTHOR_EMAIL'] = author_email
200 with open(os.path.join(root, 'some_file'), 'a') as f:
201 print >> f, message
198 subprocess.check_output( 202 subprocess.check_output(
199 ['git', '-C', root, 'commit', 203 ['git', '-C', root, 'commit',
200 '-a', '--allow-empty', 204 '-a', '-m', message], env=env)
201 '-m', message], env=env)
202 rev = subprocess.check_output( 205 rev = subprocess.check_output(
203 ['git', '-C', root, 'rev-parse', 'HEAD']).strip() 206 ['git', '-C', root, 'rev-parse', 'HEAD']).strip()
204 return { 207 return {
205 'root': repo['root'], 208 'root': repo['root'],
206 'revision': rev, 209 'revision': rev,
207 'spec': repo['spec'], 210 'spec': repo['spec'],
208 'author_name': author_name, 211 'author_name': author_name,
209 'author_email': author_email, 212 'author_email': author_email,
210 'message_lines': message.splitlines(), 213 'message_lines': message.splitlines(),
211 } 214 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 os.unlink(os.path.join(module_dir, 'example.py')) 342 os.unlink(os.path.join(module_dir, 'example.py'))
340 343
341 self.train_recipes(repo) 344 self.train_recipes(repo)
342 345
343 subprocess.check_call(['git', 'add', module_dir]) 346 subprocess.check_call(['git', 'add', module_dir])
344 message = ' '.join( 347 message = ' '.join(
345 ['update %r recipe_module: ' % name] + 348 ['update %r recipe_module: ' % name] +
346 ['%s(%s)' % t for t in methods.iteritems()] 349 ['%s(%s)' % t for t in methods.iteritems()]
347 ) 350 )
348 return self.commit_in_repo(repo, message) 351 return self.commit_in_repo(repo, message)
OLDNEW
« no previous file with comments | « unittests/autoroll_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698