| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """A continious builder for build repo which simulates recipes.""" | 4 """A continuous builder which runs recipe tests.""" |
| 5 |
| 6 from recipe_engine.recipe_api import Property |
| 5 | 7 |
| 6 DEPS = [ | 8 DEPS = [ |
| 7 'depot_tools/bot_update', | 9 'depot_tools/bot_update', |
| 8 'depot_tools/gclient', | 10 'depot_tools/gclient', |
| 9 'recipe_engine/path', | 11 'recipe_engine/path', |
| 10 'recipe_engine/properties', | 12 'recipe_engine/properties', |
| 11 'recipe_engine/python', | 13 'recipe_engine/python', |
| 14 'recipe_engine/step', |
| 15 'luci_config', |
| 12 ] | 16 ] |
| 13 | 17 |
| 18 PROPERTIES = { |
| 19 'project_under_test': Property( |
| 20 default='build', kind=str, help='luci-config project to run tests for') |
| 21 } |
| 14 | 22 |
| 15 def RunSteps(api): | |
| 16 api.gclient.set_config('build') | |
| 17 api.bot_update.ensure_checkout(force=True) | |
| 18 recipes_py = api.path['checkout'].join('scripts', 'slave', 'recipes.py') | |
| 19 api.python('recipe fetch deps', recipes_py, ['fetch']) | |
| 20 # In theory, this should work too. But in practice, this fails to import | |
| 21 # coverage module (http://crbug.com/577049). | |
| 22 # api.python('recipe simulation test', recipes_py, ['simulation_test']) | |
| 23 recipe_simulation_test = api.path['checkout'].join( | |
| 24 'scripts', 'slave', 'unittests', 'recipe_simulation_test.py') | |
| 25 api.python('recipe simulation test', recipe_simulation_test, ['test']) | |
| 26 | 23 |
| 24 def RunSteps(api, project_under_test): |
| 25 root_dir = api.path['slave_build'] |
| 26 cache_dir = root_dir.join('_cache_dir') |
| 27 |
| 28 c = api.gclient.make_config(CACHE_DIR=cache_dir) |
| 29 soln = c.solutions.add() |
| 30 soln.name = project_under_test |
| 31 soln.url = api.luci_config.get_project_metadata( |
| 32 project_under_test)['repo_url'] |
| 33 |
| 34 api.bot_update.ensure_checkout( |
| 35 force=True, gclient_config=c, |
| 36 cwd=root_dir) |
| 37 |
| 38 # TODO(martiniss): allow recipes.cfg patches to take affect |
| 39 # This requires getting the refs.cfg from luci_config, reading the local |
| 40 # patched version, etc. |
| 41 result = api.luci_config.get_project_config(project_under_test, 'recipes.cfg') |
| 42 recipes_cfg = api.luci_config.parse_textproto(result['content'].split('\n')) |
| 43 path = recipes_cfg['recipes_path'][0].split('/') |
| 44 |
| 45 api.step( |
| 46 'recipe simulation test', [ |
| 47 root_dir.join(*([project_under_test] + path + ['recipes.py'])), |
| 48 '--use-bootstrap', 'simulation_test' |
| 49 ]) |
| 27 | 50 |
| 28 def GenTests(api): | 51 def GenTests(api): |
| 29 yield ( | 52 yield ( |
| 30 api.test('normal') + | 53 api.test('normal') + |
| 31 api.properties.generic( | 54 api.properties.generic( |
| 32 mastername='chromium.tools.build', | 55 mastername='chromium.tools.build', |
| 33 buildername='recipe simulation tester', | 56 buildername='recipe simulation tester', |
| 34 revision='deadbeaf', | 57 revision='deadbeaf', |
| 35 ) | 58 project_under_test='build', |
| 59 ) + |
| 60 api.luci_config.get_projects(('build',)) + |
| 61 api.luci_config.get_project_config( |
| 62 'build', 'recipes.cfg', |
| 63 'recipes_path: "foobar"') |
| 36 ) | 64 ) |
| OLD | NEW |