| OLD | NEW |
| 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 Loading... |
| 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() |
| OLD | NEW |