1# Copyright 2024 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5from __future__ import annotations 6 7import contextlib 8 9from crossbench import path as pth 10from crossbench import plt 11 12 13@contextlib.contextmanager 14def tmp_platform_cache_dir(cache_dir: pth.LocalPath): 15 old_cache_dir = plt.PLATFORM.cache_dir("test") 16 plt.PLATFORM.set_cache_dir(cache_dir) 17 try: 18 yield 19 finally: 20 plt.PLATFORM.set_cache_dir(old_cache_dir) 21