| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # 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 | 13 |
| 13 BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname( | 14 BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname( |
| 14 os.path.abspath(__file__)))) | 15 os.path.abspath(__file__)))) |
| 15 THIRD_PARTY = os.path.join(BASE_DIR, 'recipe_engine', 'third_party') | 16 THIRD_PARTY = os.path.join(BASE_DIR, 'recipe_engine', 'third_party') |
| 16 sys.path.insert(0, os.path.join(THIRD_PARTY, 'mock-1.0.1')) | 17 sys.path.insert(0, os.path.join(THIRD_PARTY, 'mock-1.0.1')) |
| 17 sys.path.insert(0, BASE_DIR) | 18 sys.path.insert(0, BASE_DIR) |
| 18 | 19 |
| 19 import recipe_engine.run | 20 import recipe_engine.run |
| 20 import recipe_engine.step_runner | 21 import recipe_engine.step_runner |
| 21 from recipe_engine import recipe_test_api | 22 from recipe_engine import recipe_test_api |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return None | 137 return None |
| 137 | 138 |
| 138 with self.assertRaises(AssertionError): | 139 with self.assertRaises(AssertionError): |
| 139 engine.run(FakeScript(), api) | 140 engine.run(FakeScript(), api) |
| 140 | 141 |
| 141 def test_subannotations(self): | 142 def test_subannotations(self): |
| 142 proc = subprocess.Popen( | 143 proc = subprocess.Popen( |
| 143 self._run_cmd('engine_tests/subannotations'), | 144 self._run_cmd('engine_tests/subannotations'), |
| 144 stdout=subprocess.PIPE, | 145 stdout=subprocess.PIPE, |
| 145 stderr=subprocess.PIPE) | 146 stderr=subprocess.PIPE) |
| 146 stdout, stderr = proc.communicate() | 147 stdout, _ = proc.communicate() |
| 147 self.assertRegexpMatches(stdout, r'(?m)^!@@@BUILD_STEP@steppy@@@$') | 148 self.assertRegexpMatches(stdout, r'(?m)^!@@@BUILD_STEP@steppy@@@$') |
| 148 self.assertRegexpMatches(stdout, r'(?m)^@@@BUILD_STEP@pippy@@@$') | 149 self.assertRegexpMatches(stdout, r'(?m)^@@@BUILD_STEP@pippy@@@$') |
| 149 # Before 'Subannotate me' we expect an extra STEP_CURSOR to reset the | 150 # Before 'Subannotate me' we expect an extra STEP_CURSOR to reset the |
| 150 # state. | 151 # state. |
| 151 self.assertRegexpMatches(stdout, | 152 self.assertRegexpMatches(stdout, |
| 152 r'(?m)^@@@STEP_CURSOR@Subannotate me@@@\n@@@STEP_CLOSED@@@$') | 153 r'(?m)^@@@STEP_CURSOR@Subannotate me@@@\n@@@STEP_CLOSED@@@$') |
| 153 | 154 |
| 155 def test_bad_subprocess(self): |
| 156 now = time.time() |
| 157 self._test_recipe('engine_tests/bad_subprocess') |
| 158 after = time.time() |
| 159 |
| 160 # Test has an internal 10s timeout for the bad daemon step, but the daemon's |
| 161 # parent process quits immediately. If this takes longer than 5 seconds to |
| 162 # run, we consider it failed. |
| 163 self.assertLess(after - now, 5) |
| 164 |
| 154 | 165 |
| 155 if __name__ == '__main__': | 166 if __name__ == '__main__': |
| 156 unittest.TestCase.maxDiff = None | 167 unittest.TestCase.maxDiff = None |
| 157 unittest.main() | 168 unittest.main() |
| OLD | NEW |