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

Side by Side Diff: scripts/slave/unittests/annotated_run_test.py

Issue 2062293002: annotated_run: Use builder directory for temp. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « scripts/slave/annotated_run.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Tests that the tools/build annotated_run wrapper actually runs.""" 7 """Tests that the tools/build annotated_run wrapper actually runs."""
8 8
9 import collections 9 import collections
10 import json 10 import json
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 75
76 class AnnotatedRunExecTest(unittest.TestCase): 76 class AnnotatedRunExecTest(unittest.TestCase):
77 def setUp(self): 77 def setUp(self):
78 logging.basicConfig(level=logging.ERROR+1) 78 logging.basicConfig(level=logging.ERROR+1)
79 79
80 self.maxDiff = None 80 self.maxDiff = None
81 self._patchers = [] 81 self._patchers = []
82 map(self._patch, ( 82 map(self._patch, (
83 mock.patch('slave.annotated_run._run_command'), 83 mock.patch('slave.annotated_run._run_command'),
84 mock.patch('slave.annotated_run._build_dir'),
85 mock.patch('slave.annotated_run._builder_dir'),
84 mock.patch('os.path.exists'), 86 mock.patch('os.path.exists'),
85 mock.patch('os.getcwd'),
86 )) 87 ))
87 88
89 # Mock build and builder directories.
90 annotated_run._build_dir.return_value = '/home/user/builder/build'
91 annotated_run._builder_dir.return_value = '/home/user/builder'
92
88 self.rt = robust_tempdir.RobustTempdir(prefix='annotated_run_test') 93 self.rt = robust_tempdir.RobustTempdir(prefix='annotated_run_test')
89 self.basedir = self.rt.tempdir() 94 self.basedir = self.rt.tempdir()
90 self.tdir = self.rt.tempdir() 95 self.tdir = self.rt.tempdir()
91 self.opts = MockOptions( 96 self.opts = MockOptions(
92 dry_run=False) 97 dry_run=False)
93 self.properties = { 98 self.properties = {
94 'recipe': 'example/recipe', 99 'recipe': 'example/recipe',
95 'mastername': 'master.random', 100 'mastername': 'master.random',
96 'buildername': 'builder', 101 'buildername': 'builder',
97 } 102 }
98 self.cwd = os.path.join('home', 'user')
99 self.rpy_path = os.path.join(env.Build, 'scripts', 'slave', 'recipes.py') 103 self.rpy_path = os.path.join(env.Build, 'scripts', 'slave', 'recipes.py')
100 self.recipe_args = [ 104 self.recipe_args = [
101 sys.executable, '-u', self.rpy_path, '--verbose', 'run', 105 sys.executable, '-u', self.rpy_path, '--verbose', 'run',
102 '--workdir=%s' % (self.cwd,), 106 '--workdir=/home/user/builder/build',
103 '--properties-file=%s' % (self._tp('recipe_properties.json'),), 107 '--properties-file=%s' % (self._tp('recipe_properties.json'),),
104 'example/recipe'] 108 'example/recipe']
105 109
106 # Use public recipes.py path. 110 # Use public recipes.py path.
107 os.getcwd.return_value = self.cwd
108 os.path.exists.return_value = False 111 os.path.exists.return_value = False
109 112
110 def tearDown(self): 113 def tearDown(self):
111 self.rt.close() 114 self.rt.close()
112 for p in reversed(self._patchers): 115 for p in reversed(self._patchers):
113 p.stop() 116 p.stop()
114 117
115 def _bp(self, *p): 118 def _bp(self, *p):
116 return os.path.join(*((self.basedir,) + p)) 119 return os.path.join(*((self.basedir,) + p))
117 120
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bootstrap.assert_called_once() 193 bootstrap.assert_called_once()
191 bs_result.assert_called_once() 194 bs_result.assert_called_once()
192 annotated_run._run_command.assert_has_calls([ 195 annotated_run._run_command.assert_has_calls([
193 mock.call(['logdog_bootstrap'] + self.recipe_args, dry_run=False), 196 mock.call(['logdog_bootstrap'] + self.recipe_args, dry_run=False),
194 mock.call(self.recipe_args, dry_run=False), 197 mock.call(self.recipe_args, dry_run=False),
195 ]) 198 ])
196 199
197 200
198 if __name__ == '__main__': 201 if __name__ == '__main__':
199 unittest.main() 202 unittest.main()
OLDNEW
« no previous file with comments | « scripts/slave/annotated_run.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698