Add method for setting test data for get_files_affected_by_patch.
The get_files_affected_by_patch method on the test API will return a TestData object that determines the output of the "git diff" call. a Test was added specifically for the get_files_affected_by_patch API method to ensure that the test API operates as expected. Change-Id: Ia1846700461757a72ed518894a5a38a8ca54fcc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3422006 Auto-Submit: Garrett Beaty <gbeaty@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Garrett Beaty <gbeaty@google.com>changes/06/3422006/2
parent
0dc69c4e79
commit
dd93ebcac8
@ -0,0 +1,24 @@
|
||||
[
|
||||
{
|
||||
"cmd": [
|
||||
"git",
|
||||
"-c",
|
||||
"core.quotePath=false",
|
||||
"diff",
|
||||
"--cached",
|
||||
"--name-only"
|
||||
],
|
||||
"cwd": "[START_DIR]/test/patch/root",
|
||||
"infra_step": true,
|
||||
"name": "git diff to analyze patch",
|
||||
"~followup_annotations": [
|
||||
"@@@STEP_LOG_LINE@files@test/patch/root/baz/shaz.cc@@@",
|
||||
"@@@STEP_LOG_LINE@files@test/patch/root/foo/bar.cc@@@",
|
||||
"@@@STEP_LOG_END@files@@@",
|
||||
"@@@SET_BUILD_PROPERTY@affected-files@{\"first_100\": [\"test/patch/root/baz/shaz.cc\", \"test/patch/root/foo/bar.cc\"], \"total_count\": 2}@@@"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "$result"
|
||||
}
|
||||
]
|
@ -0,0 +1,92 @@
|
||||
# Copyright 2022 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/path',
|
||||
'recipe_engine/platform',
|
||||
'recipe_engine/properties',
|
||||
]
|
||||
|
||||
|
||||
def RunSteps(api):
|
||||
files = api.tryserver.get_files_affected_by_patch(
|
||||
api.properties['patch_root'],
|
||||
report_files_via_property=api.properties.get('report_files_via_property'))
|
||||
api.assertions.assertCountEqual(files, api.properties['expected_files'])
|
||||
|
||||
|
||||
def GenTests(api):
|
||||
def no_properties_set(check, steps, step_name):
|
||||
check(not steps[step_name].output_properties)
|
||||
|
||||
yield api.test(
|
||||
'basic',
|
||||
api.properties(
|
||||
patch_root='',
|
||||
expected_files=['foo.cc'],
|
||||
),
|
||||
api.post_check(no_properties_set, 'git diff to analyze patch'),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
api.post_process(post_process.DropExpectation),
|
||||
)
|
||||
|
||||
yield api.test(
|
||||
'patch_root',
|
||||
api.properties(
|
||||
patch_root='test/patch/root',
|
||||
expected_files=['test/patch/root/foo.cc'],
|
||||
),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
api.post_process(post_process.DropExpectation),
|
||||
)
|
||||
|
||||
yield api.test(
|
||||
'test-data',
|
||||
api.tryserver.get_files_affected_by_patch(['foo/bar.cc', 'baz/shaz.cc']),
|
||||
api.properties(
|
||||
patch_root='test/patch/root',
|
||||
expected_files=[
|
||||
'test/patch/root/foo/bar.cc',
|
||||
'test/patch/root/baz/shaz.cc',
|
||||
],
|
||||
),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
api.post_process(post_process.DropExpectation),
|
||||
)
|
||||
|
||||
yield api.test(
|
||||
'report-files-via-property',
|
||||
api.tryserver.get_files_affected_by_patch(['foo/bar.cc', 'baz/shaz.cc']),
|
||||
api.properties(
|
||||
patch_root='test/patch/root',
|
||||
report_files_via_property='affected-files',
|
||||
expected_files=[
|
||||
'test/patch/root/foo/bar.cc',
|
||||
'test/patch/root/baz/shaz.cc',
|
||||
],
|
||||
),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
)
|
||||
|
||||
yield api.test(
|
||||
'windows',
|
||||
api.tryserver.get_files_affected_by_patch(['foo/bar.cc', 'baz/shaz.cc']),
|
||||
api.platform('win', 32),
|
||||
api.properties(
|
||||
patch_root='test\\patch\\root',
|
||||
report_files_via_property='affected-files',
|
||||
expected_files=[
|
||||
'test/patch/root/foo/bar.cc',
|
||||
'test/patch/root/baz/shaz.cc',
|
||||
],
|
||||
),
|
||||
api.post_check(post_process.StatusSuccess),
|
||||
api.post_process(post_process.DropExpectation),
|
||||
)
|
Loading…
Reference in New Issue