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

Side by Side Diff: recipe_engine/unittests/run_test.py

Issue 2052543003: Emit CURRENT_TIMESTAMP annotation (Closed) Base URL: git@github.com:luci/recipes-py.git@master
Patch Set: nit 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 | « recipe_engine/stream.py ('k') | recipe_engine/unittests/stream_test.py » ('j') | 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 # Copyright 2014 The LUCI Authors. All rights reserved. 2 # Copyright 2014 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 re 8 import re
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 bash_output = subprocess.check_output([ 125 bash_output = subprocess.check_output([
126 'bash', '-c', '/bin/echo %s' % quoted]) 126 'bash', '-c', '/bin/echo %s' % quoted])
127 self.assertEqual(bash_output.decode('utf-8'), s + '\n') 127 self.assertEqual(bash_output.decode('utf-8'), s + '\n')
128 128
129 # zsh is untested because zsh isn't provisioned on our bots. (luqui) 129 # zsh is untested because zsh isn't provisioned on our bots. (luqui)
130 # zsh_output = subprocess.check_output([ 130 # zsh_output = subprocess.check_output([
131 # 'zsh', '-c', '/bin/echo %s' % quoted]) 131 # 'zsh', '-c', '/bin/echo %s' % quoted])
132 # self.assertEqual(zsh_output.decode('utf-8'), s + '\n') 132 # self.assertEqual(zsh_output.decode('utf-8'), s + '\n')
133 133
134 def test_run_unconsumed(self): 134 def test_run_unconsumed(self):
135 stream_engine = recipe_engine.stream.NoopStreamEngine() 135 with recipe_engine.stream.NoopStreamEngine() as stream_engine:
136 properties = {} 136 properties = {}
137 137
138 test_data = recipe_engine.recipe_test_api.TestData() 138 test_data = recipe_engine.recipe_test_api.TestData()
139 test_data.expect_exception('SomeException') 139 test_data.expect_exception('SomeException')
140 140
141 api = mock.Mock() 141 api = mock.Mock()
142 api._engine = mock.Mock() 142 api._engine = mock.Mock()
143 api._engine.properties = properties 143 api._engine.properties = properties
144 144
145 engine = recipe_engine.run.RecipeEngine( 145 engine = recipe_engine.run.RecipeEngine(
146 recipe_engine.step_runner.SimulationStepRunner( 146 recipe_engine.step_runner.SimulationStepRunner(
147 stream_engine, test_data), 147 stream_engine, test_data),
148 properties, 148 properties,
149 None) 149 None)
150 150
151 class FakeScript(object): 151 class FakeScript(object):
152 def run(self, _, __): 152 def run(self, _, __):
153 return None 153 return None
154 154
155 with self.assertRaises(AssertionError): 155 with self.assertRaises(AssertionError):
156 engine.run(FakeScript(), api) 156 engine.run(FakeScript(), api)
157 157
158 def test_subannotations(self): 158 def test_subannotations(self):
159 proc = subprocess.Popen( 159 proc = subprocess.Popen(
160 self._run_cmd('engine_tests/subannotations'), 160 self._run_cmd('engine_tests/subannotations'),
161 stdout=subprocess.PIPE, 161 stdout=subprocess.PIPE,
162 stderr=subprocess.PIPE) 162 stderr=subprocess.PIPE)
163 stdout, _ = proc.communicate() 163 stdout, _ = proc.communicate()
164 self.assertRegexpMatches(stdout, r'(?m)^!@@@BUILD_STEP@steppy@@@$') 164 self.assertRegexpMatches(stdout, r'(?m)^!@@@BUILD_STEP@steppy@@@$')
165 self.assertRegexpMatches(stdout, r'(?m)^@@@BUILD_STEP@pippy@@@$') 165 self.assertRegexpMatches(stdout, r'(?m)^@@@BUILD_STEP@pippy@@@$')
166 # Before 'Subannotate me' we expect an extra STEP_CURSOR to reset the 166 # Before 'Subannotate me' we expect an extra STEP_CURSOR to reset the
167 # state. 167 # state.
168 self.assertRegexpMatches(stdout, 168 self.assertRegexpMatches(stdout,
169 r'(?m)^@@@STEP_CURSOR@Subannotate me@@@\n@@@STEP_CLOSED@@@$') 169 r'(?m)^@@@STEP_CURSOR@Subannotate me@@@\n@@@STEP_CLOSED@@@$')
170 170
171 171
172 if __name__ == '__main__': 172 if __name__ == '__main__':
173 unittest.TestCase.maxDiff = None 173 unittest.TestCase.maxDiff = None
174 unittest.main() 174 unittest.main()
OLDNEW
« no previous file with comments | « recipe_engine/stream.py ('k') | recipe_engine/unittests/stream_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698