| # Copyright 2018 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| from recipe_engine import recipe_test_api |
| |
| |
| class CheckoutTestApi(recipe_test_api.RecipeTestApi): |
| |
| def test(self, name, properties=None, patchfile=None): |
| """Creates a CheckoutApi test case |
| |
| Args: |
| name (str): The name of this test case. |
| properties: Recipe properties. These will overwrite any defaults. |
| patchfile (Dict): JSON object representing the contents of a patchfile. If unset, |
| no patchfile will be present in this test. |
| """ |
| if not properties: |
| properties = dict() |
| tryjob = properties.get('tryjob', False) |
| project = properties.get('project', 'garnet') |
| |
| # Create return value. |
| ret = super(CheckoutTestApi, self).test(name) |
| |
| # Overwrite default properties with input properties. |
| ret += self.m.properties(**properties) |
| |
| # Set buildbucket properties. |
| git_repo = "https://fuchsia.googlesource.com/" + project |
| if tryjob: |
| ret += self.m.buildbucket.try_build(project=project, git_repo=git_repo) |
| else: |
| ret += self.m.buildbucket.ci_build(project=project, git_repo=git_repo) |
| |
| # Add test patchfile if specified. |
| if patchfile is not None: |
| patchfile_path = self.m.path['start_dir'].join(project, 'patches.json') |
| ret += self.m.path.exists(patchfile_path) |
| ret += self.step_data('read patches-json', self.m.json.output(patchfile)) |
| |
| return ret |