aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules/isolate/test_api.py
blob: e56e60b71a658247e6ce26d39e309f234658b245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


# TODO(borenet): This module was copied from build.git and heavily modified to
# remove dependencies on other modules in build.git.  It belongs in a different
# repo. Remove this once it has been moved.


from recipe_engine import recipe_test_api

class IsolateTestApi(recipe_test_api.RecipeTestApi):
  def output_json(self, targets=None, missing=None):
    """Mocked output of 'find_isolated_tests' and 'isolate_tests' steps.

    Deterministically synthesizes json.output test data for the given targets.
    If |targets| is None, will emit test data with some dummy targets instead,
    emulating find_isolated_tests.py finding some files.

    If |missing| is given it's a subset of |targets| that wasn't isolated in
    'isolate_tests' due to some error.
    """
    missing = missing or ()
    if targets is None:
      targets = ['dummy_target_1', 'dummy_target_2']
    return self.m.json.output({
      target: None if target in missing else '[dummy hash for %s]' % target
      for target in targets
    })