blob: 975ce74d2f87488e2f6ccc68f27cf0004b4ca63a [file] [log] [blame]
# Copyright 2020 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.
DEPS = [
"fuchsia/cache",
"recipe_engine/context",
"recipe_engine/path",
"recipe_engine/step",
]
def RunSteps(api):
with api.cache.guard(cache="example"):
pass
# Reentrancy should be allowed.
with api.cache.guard(cache="example"):
with api.cache.guard(cache="example"):
pass
try:
with api.cache.guard(cache="failing"):
api.step.empty("failing step", status=api.step.FAILURE)
except api.step.StepFailure:
pass
# It shouldn't be allowed to enter a cache context while cwd is set to the
# cache's directory.
with api.context(cwd=api.path.cache_dir / "cwd_cache"):
try:
with api.cache.guard(cache="cwd_cache"):
assert False # pragma: no cover
except ValueError:
pass
def GenTests(api):
yield api.test("default") + api.path.exists(
api.path.cache_dir.joinpath("example", ".GUARD_FILE")
)