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

Side by Side Diff: unittests/autoroll_test.py

Issue 2756503003: [autoroll] make autoroller propagate changes to recipes.py. (Closed)
Patch Set: add comment Created 3 years, 9 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2016 The LUCI Authors. All rights reserved. 2 # Copyright 2016 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 import json 6 import json
7 import os 7 import os
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 import unittest 10 import unittest
11 11
12 import repo_test_util 12 import repo_test_util
13 13
14 14
15 class TestAutoroll(repo_test_util.RepoTest): 15 class TestAutoroll(repo_test_util.RepoTest):
16 def run_roll(self, repo, *args): 16 def run_roll(self, repo, *args):
17 """Runs the autoroll command and returns JSON. 17 """Runs the autoroll command and returns JSON.
18 Does not commit the resulting roll. 18 Does not commit the resulting roll.
19 """ 19 """
20 with repo_test_util.in_directory(repo['root']), \ 20 with repo_test_util.in_directory(repo['root']), \
21 repo_test_util.temporary_file() as tempfile_path: 21 repo_test_util.temporary_file() as tempfile_path:
22 subprocess.check_output([ 22 try:
23 subprocess.check_output([
23 sys.executable, self._recipe_tool, 24 sys.executable, self._recipe_tool,
24 '--package', os.path.join( 25 '--package', os.path.join(
25 repo['root'], 'infra', 'config', 'recipes.cfg'), 26 repo['root'], 'infra', 'config', 'recipes.cfg'),
26 '--use-bootstrap', 27 '--use-bootstrap',
27 'autoroll', 28 'autoroll',
28 '--output-json', tempfile_path 29 '--output-json', tempfile_path
29 ] + list(args), stderr=subprocess.STDOUT) 30 ] + list(args) , stderr=subprocess.STDOUT)
30 with open(tempfile_path) as f: 31 with open(tempfile_path) as f:
31 return json.load(f) 32 return json.load(f)
33 except subprocess.CalledProcessError as e:
34 print e.output
35 raise
32 36
33 def test_empty(self): 37 def test_empty(self):
34 """Tests the scenario where there are no roll candidates. 38 """Tests the scenario where there are no roll candidates.
35 """ 39 """
36 repos = self.repo_setup({ 40 repos = self.repo_setup({
37 'a': [], 41 'a': [],
38 }) 42 })
39 43
40 roll_result = self.run_roll(repos['a']) 44 roll_result = self.run_roll(repos['a'])
41 self.assertFalse(roll_result['success']) 45 self.assertFalse(roll_result['success'])
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 '--project=c', 507 '--project=c',
504 '--project=d', 508 '--project=d',
505 ) 509 )
506 self.assertFalse(roll_result['success']) 510 self.assertFalse(roll_result['success'])
507 self.assertFalse(bool(roll_result['roll_details'])) 511 self.assertFalse(bool(roll_result['roll_details']))
508 self.assertFalse(bool(roll_result['rejected_candidates_details'])) 512 self.assertFalse(bool(roll_result['rejected_candidates_details']))
509 513
510 514
511 if __name__ == '__main__': 515 if __name__ == '__main__':
512 sys.exit(unittest.main()) 516 sys.exit(unittest.main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698