mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
Add tryserver test_api method
Updates the tryserver recipe module's test_api to support overriding get_footers data. Bug: angleproject:7985 Change-Id: Ie571bc8d1c77cbb1cd4f18955b50d56e377ca903 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4278466 Reviewed-by: Robbie Iannucci <iannucci@chromium.org> Auto-Submit: Brian Sheedy <bsheedy@chromium.org> Commit-Queue: Robbie Iannucci <iannucci@chromium.org> Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
* [tryserver:tests/gerrit_change_owner](#recipes-tryserver_tests_gerrit_change_owner) (Python3 ✅)
|
||||
* [tryserver:tests/gerrit_change_target_ref](#recipes-tryserver_tests_gerrit_change_target_ref) (Python3 ✅)
|
||||
* [tryserver:tests/get_files_affected_by_patch](#recipes-tryserver_tests_get_files_affected_by_patch) (Python3 ✅)
|
||||
* [tryserver:tests/get_footers](#recipes-tryserver_tests_get_footers) (Python3 ✅)
|
||||
* [tryserver:tests/require_is_tryserver](#recipes-tryserver_tests_require_is_tryserver) (Python3 ✅)
|
||||
* [windows_sdk:examples/full](#recipes-windows_sdk_examples_full) (Python3 ✅)
|
||||
## Recipe Modules
|
||||
@@ -1182,6 +1183,13 @@ PYTHON_VERSION_COMPATIBILITY: PY3
|
||||
PYTHON_VERSION_COMPATIBILITY: PY3
|
||||
|
||||
— **def [RunSteps](/recipes/recipe_modules/tryserver/tests/get_files_affected_by_patch.py#18)(api):**
|
||||
### *recipes* / [tryserver:tests/get\_footers](/recipes/recipe_modules/tryserver/tests/get_footers.py)
|
||||
|
||||
[DEPS](/recipes/recipe_modules/tryserver/tests/get_footers.py#9): [tryserver](#recipe_modules-tryserver), [recipe\_engine/assertions][recipe_engine/recipe_modules/assertions], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties]
|
||||
|
||||
PYTHON_VERSION_COMPATIBILITY: PY3
|
||||
|
||||
— **def [RunSteps](/recipes/recipe_modules/tryserver/tests/get_footers.py#19)(api):**
|
||||
### *recipes* / [tryserver:tests/require\_is\_tryserver](/recipes/recipe_modules/tryserver/tests/require_is_tryserver.py)
|
||||
|
||||
[DEPS](/recipes/recipe_modules/tryserver/tests/require_is_tryserver.py#12): [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/properties][recipe_engine/recipe_modules/properties]
|
||||
|
||||
@@ -31,3 +31,18 @@ class TryserverTestApi(recipe_test_api.RecipeTestApi):
|
||||
"""
|
||||
output = self.m.raw_io.stream_output('\n'.join(files))
|
||||
return self.override_step_data(step_name, output)
|
||||
|
||||
def get_footers(self, footers, step_name='parse description'):
|
||||
"""Override test data for the `get_footers` method.
|
||||
|
||||
Args:
|
||||
footers: A dict containing key/value pairs for footers to return. To be
|
||||
accurate to git_footers.py's actual behavior, values should be lists.
|
||||
|
||||
Example:
|
||||
yield api.test(
|
||||
'my_test',
|
||||
api.tryserver.get_footers({'Footer-Key': ['footer_value']}))
|
||||
"""
|
||||
output = self.m.json.output(footers)
|
||||
return self.override_step_data(step_name, output)
|
||||
|
||||
65
recipes/recipe_modules/tryserver/tests/get_footers.py
Normal file
65
recipes/recipe_modules/tryserver/tests/get_footers.py
Normal file
@@ -0,0 +1,65 @@
|
||||
# Copyright 2023 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.
|
||||
|
||||
from recipe_engine import post_process
|
||||
|
||||
PYTHON_VERSION_COMPATIBILITY = 'PY2+3'
|
||||
|
||||
DEPS = [
|
||||
'tryserver',
|
||||
'recipe_engine/assertions',
|
||||
'recipe_engine/buildbucket',
|
||||
'recipe_engine/path',
|
||||
'recipe_engine/platform',
|
||||
'recipe_engine/properties',
|
||||
]
|
||||
|
||||
|
||||
def RunSteps(api):
|
||||
footers = api.tryserver.get_footers()
|
||||
api.assertions.assertCountEqual(footers, api.properties['expected_footers'])
|
||||
|
||||
|
||||
def GenTests(api):
|
||||
yield api.test(
|
||||
'no-footers',
|
||||
api.buildbucket.try_build(
|
||||
'chromium',
|
||||
'linux',
|
||||
),
|
||||
api.properties(expected_footers={}),
|
||||
api.tryserver.get_footers({}),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
api.post_process(post_process.DropExpectation),
|
||||
)
|
||||
|
||||
yield api.test(
|
||||
'single-footer',
|
||||
api.buildbucket.try_build(
|
||||
'chromium',
|
||||
'linux',
|
||||
),
|
||||
api.properties(expected_footers={'Some-Footer': ['True']}),
|
||||
api.tryserver.get_footers({'Some-Footer': ['True']}),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
api.post_process(post_process.DropExpectation),
|
||||
)
|
||||
|
||||
yield api.test(
|
||||
'multiple-footers',
|
||||
api.buildbucket.try_build(
|
||||
'chromium',
|
||||
'linux',
|
||||
),
|
||||
api.properties(expected_footers={
|
||||
'Some-Footer': ['True'],
|
||||
'Another-Footer': ['Foo', 'Bar']
|
||||
}),
|
||||
api.tryserver.get_footers({
|
||||
'Some-Footer': ['True'],
|
||||
'Another-Footer': ['Foo', 'Bar']
|
||||
}),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
api.post_process(post_process.DropExpectation),
|
||||
)
|
||||
Reference in New Issue
Block a user