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

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

Issue 2320223002: Revert of Track step nesting in StreamEngine. (Closed) Base URL: https://github.com/luci/recipes-py@emit-initial-properties
Patch Set: Created 4 years, 3 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
11 import unittest 11 import unittest
12 import time 12 import time
13 13
14 import test_env 14 import test_env
15 from test_env import BASE_DIR 15 from test_env import BASE_DIR
16 16
17 import recipe_engine.run 17 import recipe_engine.run
18 import recipe_engine.simulation_test as simulation_test
19 import recipe_engine.step_runner 18 import recipe_engine.step_runner
20 from recipe_engine import requests_ssl 19 from recipe_engine import requests_ssl
21 from recipe_engine import recipe_test_api 20 from recipe_engine import recipe_test_api
22 import mock 21 import mock
23 22
24 class RunTest(unittest.TestCase): 23 class RunTest(unittest.TestCase):
25 def _run_cmd(self, recipe, properties=None): 24 def _run_cmd(self, recipe, properties=None):
26 script_path = os.path.join(BASE_DIR, 'recipes.py') 25 script_path = os.path.join(BASE_DIR, 'recipes.py')
27 26
28 if properties: 27 if properties:
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 with recipe_engine.stream.NoopStreamEngine() as stream_engine: 138 with recipe_engine.stream.NoopStreamEngine() as stream_engine:
140 properties = {} 139 properties = {}
141 140
142 test_data = recipe_engine.recipe_test_api.TestData() 141 test_data = recipe_engine.recipe_test_api.TestData()
143 test_data.expect_exception('SomeException') 142 test_data.expect_exception('SomeException')
144 143
145 api = mock.Mock() 144 api = mock.Mock()
146 api._engine = mock.Mock() 145 api._engine = mock.Mock()
147 api._engine.properties = properties 146 api._engine.properties = properties
148 147
149 annotator = simulation_test.SimulationAnnotatorStreamEngine()
150 engine = recipe_engine.run.RecipeEngine( 148 engine = recipe_engine.run.RecipeEngine(
151 recipe_engine.step_runner.SimulationStepRunner( 149 recipe_engine.step_runner.SimulationStepRunner(
152 stream_engine, test_data, annotator), 150 stream_engine, test_data),
153 properties, 151 properties,
154 None) 152 None)
155 153
156 class FakeScript(object): 154 class FakeScript(object):
157 def run(self, _, __): 155 def run(self, _, __):
158 return None 156 return None
159 157
160 with self.assertRaises(AssertionError): 158 with self.assertRaises(AssertionError):
161 engine.run(FakeScript(), api) 159 engine.run(FakeScript(), api)
162 160
163 def test_subannotations(self): 161 def test_subannotations(self):
164 proc = subprocess.Popen( 162 proc = subprocess.Popen(
165 self._run_cmd('engine_tests/subannotations'), 163 self._run_cmd('engine_tests/subannotations'),
166 stdout=subprocess.PIPE, 164 stdout=subprocess.PIPE,
167 stderr=subprocess.PIPE) 165 stderr=subprocess.PIPE)
168 stdout, _ = proc.communicate() 166 stdout, _ = proc.communicate()
169 self.assertRegexpMatches(stdout, r'(?m)^!@@@BUILD_STEP@steppy@@@$') 167 self.assertRegexpMatches(stdout, r'(?m)^!@@@BUILD_STEP@steppy@@@$')
170 self.assertRegexpMatches(stdout, r'(?m)^@@@BUILD_STEP@pippy@@@$') 168 self.assertRegexpMatches(stdout, r'(?m)^@@@BUILD_STEP@pippy@@@$')
171 # Before 'Subannotate me' we expect an extra STEP_CURSOR to reset the 169 # Before 'Subannotate me' we expect an extra STEP_CURSOR to reset the
172 # state. 170 # state.
173 self.assertRegexpMatches(stdout, 171 self.assertRegexpMatches(stdout,
174 r'(?m)^@@@STEP_CURSOR@Subannotate me@@@\n@@@STEP_CLOSED@@@$') 172 r'(?m)^@@@STEP_CURSOR@Subannotate me@@@\n@@@STEP_CLOSED@@@$')
175 173
176 174
177 if __name__ == '__main__': 175 if __name__ == '__main__':
178 unittest.TestCase.maxDiff = None 176 unittest.TestCase.maxDiff = None
179 unittest.main() 177 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