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

Side by Side Diff: unittests/errors_test.py

Issue 2864803003: Minor loader improvements. (Closed)
Patch Set: fix tests Created 3 years, 7 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/unittests/loader_test.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 # 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 shutil 8 import shutil
9 import subprocess 9 import subprocess
10 import tempfile 10 import tempfile
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 def test_engine_failure(self): 286 def test_engine_failure(self):
287 with RecipeRepo() as repo: 287 with RecipeRepo() as repo:
288 repo.make_recipe('print_step_error', """ 288 repo.make_recipe('print_step_error', """
289 DEPS = ['recipe_engine/step'] 289 DEPS = ['recipe_engine/step']
290 290
291 from recipe_engine import step_runner 291 from recipe_engine import step_runner
292 292
293 def bad_print_step(self, step_stream, step, env): 293 def bad_print_step(self, step_stream, step, env):
294 raise Exception("Buh buh buh buh bad to the bone") 294 raise Exception("Buh buh buh buh bad to the bone")
295 295
296 def GenTests(api):
297 pass
298
296 def RunSteps(api): 299 def RunSteps(api):
297 step_runner.SubprocessStepRunner._print_step = bad_print_step 300 step_runner.SubprocessStepRunner._print_step = bad_print_step
298 try: 301 try:
299 api.step('Be good', ['echo', 'Sunshine, lollipops, and rainbows']) 302 api.step('Be good', ['echo', 'Sunshine, lollipops, and rainbows'])
300 finally: 303 finally:
301 api.step.active_result.presentation.status = 'WARNING' 304 api.step.active_result.presentation.status = 'WARNING'
302 """) 305 """)
303 self._test_cmd(repo, ['run', 'print_step_error'], 306 self._test_cmd(repo, ['run', 'print_step_error'],
304 asserts=lambda stdout, stderr: self.assertRegexpMatches( 307 asserts=lambda stdout, stderr: self.assertRegexpMatches(
305 stdout + stderr, 308 stdout + stderr,
306 r'(?s)Recipe engine bug.*Buh buh buh buh bad to the bone'), 309 r'(?s)Recipe engine bug.*Buh buh buh buh bad to the bone'),
307 retcode=2) 310 retcode=2)
308 311
312 def test_missing_method(self):
313 with RecipeRepo() as repo:
314 repo.make_recipe('no_gen_tests', """
315 def RunSteps(api):
316 pass
317 """)
318 repo.make_recipe('no_run_steps', """
319 def GenTests(api):
320 pass
321 """)
322
323 self._test_cmd(repo, ['run', 'no_gen_tests'],
324 asserts=lambda stdout, stderr: self.assertRegexpMatches(
325 stdout + stderr,
326 r'(?s)misspelled GenTests'),
327 retcode=2)
328
329 self._test_cmd(repo, ['run', 'no_run_steps'],
330 asserts=lambda stdout, stderr: self.assertRegexpMatches(
331 stdout + stderr,
332 r'(?s)misspelled RunSteps'),
333 retcode=2)
334
309 def test_unconsumed_assertion(self): 335 def test_unconsumed_assertion(self):
310 # There was a regression where unconsumed exceptions would not be detected 336 # There was a regression where unconsumed exceptions would not be detected
311 # if the exception was AssertionError. 337 # if the exception was AssertionError.
312 338
313 with RecipeRepo() as repo: 339 with RecipeRepo() as repo:
314 repo.make_recipe('unconsumed_assertion', """ 340 repo.make_recipe('unconsumed_assertion', """
315 DEPS = [] 341 DEPS = []
316 342
317 def RunSteps(api): 343 def RunSteps(api):
318 pass 344 pass
(...skipping 21 matching lines...) Expand all
340 stdout, r'from the root of a \'testproj\' checkout') 366 stdout, r'from the root of a \'testproj\' checkout')
341 self.assertRegexpMatches( 367 self.assertRegexpMatches(
342 stdout, r'\./foo/bar/recipes\.py run .* do_nothing') 368 stdout, r'\./foo/bar/recipes\.py run .* do_nothing')
343 369
344 370
345 371
346 372
347 373
348 if __name__ == '__main__': 374 if __name__ == '__main__':
349 unittest.main() 375 unittest.main()
OLDNEW
« no previous file with comments | « recipe_engine/unittests/loader_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698