blob: 6fa3c31ef6dbb71b97ac4d7fee75bf5542bda195 [file] [log] [blame]
# Copyright 2019 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 FuchsiaTestingRequestsTestApi(recipe_test_api.RecipeTestApi):
EXAMPLE_TESTS_JSON = [
{
'test': {
'name': 'hello',
'label': '//a/b/c:hello_test(//toolchain)',
'os': 'fuchsia',
'path': '/path/to/hello',
'package_url': 'fuchsia-pkg://fuchsia.com/hello',
}
},
{
'test': {
'name': 'goodbye',
'label': '//a/b/c:goodbye_test(//toolchain)',
'os': 'fuchsia',
'path': '/path/to/goodbye',
'package_url': 'fuchsia-pkg://fuchsia.com/goodbye',
}
},
]
def default_tests(self):
"""Returns mock step data for the output of testsharder.
Returns:
list(testsharder.Test)
"""
return [
self.m.testsharder.test(**t['test']) for t in self.EXAMPLE_TESTS_JSON
]
def task_request_jsonish(self, legacy_qemu):
ret = self.m.swarming.example_task_request_jsonish()
ret['tags'] = ['uses_legacy_qemu:%s' % str(legacy_qemu).lower()]
return ret
def task_requests_step_data(self, task_requests, step_name):
"""Returns mock step data for swarming task requests.
This should be used by any test which calls api.testing_requests.shard_requests() and expects
to shard tests.
Args:
shards (seq[dict]): A set of example shards which should
be used as step data for the result of invoking the testsharder.
step_name (str): name to use for step data
Returns:
RecipeTestApi.step_data for the extract_results step.
"""
return self.step_data(step_name, self.m.json.output(task_requests))