depot_tools: add test_api to infra_paths recipe module

BUG=chromium:605919

Review URL: https://codereview.chromium.org/1915113006

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@300191 0039d316-1c4b-4281-b951-d872f2087c98
parent 6d1266ee
......@@ -3,6 +3,7 @@
# found in the LICENSE file.
from recipe_engine import recipe_api
from recipe_engine.config_types import Path, NamedBasePath
class InfraPathsApi(recipe_api.RecipeApi):
......@@ -28,6 +29,10 @@ class InfraPathsApi(recipe_api.RecipeApi):
else:
self.set_config('buildbot')
for path in self._test_data.get('exists', []):
assert isinstance(path.base, NamedBasePath)
self.m.path.mock_add_paths(self[path.base.name].join(*path.pieces))
def __getitem__(self, name):
self._lazy_set_config()
return self.c.paths[name]
......@@ -4,6 +4,10 @@
"cwd": "[CWD]",
"name": "step"
},
{
"cmd": [],
"name": "path exists"
},
{
"name": "$result",
"recipe_result": null,
......
......@@ -4,6 +4,10 @@
"cwd": "[CWD]",
"name": "step"
},
{
"cmd": [],
"name": "path exists"
},
{
"name": "$result",
"recipe_result": null,
......
......@@ -4,6 +4,10 @@
"cwd": "[CWD]",
"name": "step"
},
{
"cmd": [],
"name": "path exists"
},
{
"name": "$result",
"recipe_result": null,
......
......@@ -4,6 +4,7 @@
DEPS = [
'infra_paths',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/step',
......@@ -14,10 +15,16 @@ from recipe_engine.config_types import Path
def RunSteps(api):
api.step('step', [], cwd=api.infra_paths['slave_build'])
if api.path.exists(api.infra_paths['slave_build'].join('foo.txt')):
api.step('path exists', [])
def GenTests(api):
for platform in ('linux', 'win', 'mac'):
yield (api.test(platform) + api.platform.name(platform))
yield (api.test(platform) +
api.platform.name(platform) +
api.infra_paths.exists(
api.infra_paths['slave_build'].join('foo.txt')))
yield (api.test('%s_kitchen' % platform) +
api.platform.name(platform) +
......
# Copyright 2016 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 recipe_test_api
from recipe_engine.config_types import Path, NamedBasePath
class InfraPathsTestApi(recipe_test_api.RecipeTestApi):
@recipe_test_api.mod_test_data
@staticmethod
def exists(*paths):
assert all(isinstance(p, Path) for p in paths)
return paths
def __getitem__(self, name):
return Path(NamedBasePath(name))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment