Use new path module properties
Change-Id: I30e70fd6ba6ebcc1c58171636c127546bc0918ea
Bug: 329113288
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/200701
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
diff --git a/recipe_modules/bazel/tests/full.py b/recipe_modules/bazel/tests/full.py
index 97da5c2..fb16e6a 100644
--- a/recipe_modules/bazel/tests/full.py
+++ b/recipe_modules/bazel/tests/full.py
@@ -36,7 +36,7 @@
def RunSteps(api, props): # pylint: disable=invalid-name
# pylint: disable=missing-function-docstring
runner = api.bazel.new_runner(
- checkout=_FakeCheckoutContext(api.path['start_dir']),
+ checkout=_FakeCheckoutContext(api.path.start_dir),
options=props.bazel_options,
)
runner.run()
diff --git a/recipe_modules/build/tests/full.py b/recipe_modules/build/tests/full.py
index b1cdcfd..413eefb 100644
--- a/recipe_modules/build/tests/full.py
+++ b/recipe_modules/build/tests/full.py
@@ -29,7 +29,7 @@
def RunSteps(api, props):
build = api.build.create(
- api.path['start_dir'] / 'checkout',
+ api.path.start_dir / 'checkout',
props.build_options,
)
api.build(build)
diff --git a/recipe_modules/checkout/api.py b/recipe_modules/checkout/api.py
index a88bcc7..d555385 100644
--- a/recipe_modules/checkout/api.py
+++ b/recipe_modules/checkout/api.py
@@ -447,7 +447,7 @@
self.m.file.write_json(
'manifest json',
- self.m.path['start_dir'] / 'manifest.json',
+ self.m.path.start_dir / 'manifest.json',
manifest.dict(),
)
@@ -961,7 +961,7 @@
parsed_remote.hostname
+ parsed_remote.path.replace('-', '--').replace('/', '-')
)
- cache_path = self.m.path['cache'] / 'git' / cache_name
+ cache_path = self.m.path.cache_dir / 'git' / cache_name
self.m.file.ensure_directory('makedirs', cache_path)
with self.m.context(cwd=cache_path):
@@ -1488,7 +1488,7 @@
ctx = CheckoutContext(api=self.m)
ctx.options = options
ctx.changes = []
- ctx.root = root or self.m.path['start_dir'] / 'co'
+ ctx.root = root or self.m.path.start_dir / 'co'
for remotes in options.equivalent_remotes:
new_remotes = [self.m.sso.sso_to_https(x) for x in remotes.remotes]
@@ -1530,7 +1530,7 @@
change.gerrit_url
)
- snapshot_dir = self.m.path['start_dir'] / 'snapshot'
+ snapshot_dir = self.m.path.start_dir / 'snapshot'
ctx.snapshot_to_dir(snapshot_dir)
ctx.top = ctx.root
diff --git a/recipe_modules/checkout/tests/repo.py b/recipe_modules/checkout/tests/repo.py
index 41529e6..415d7f5 100644
--- a/recipe_modules/checkout/tests/repo.py
+++ b/recipe_modules/checkout/tests/repo.py
@@ -40,7 +40,7 @@
with api.step.nest(str(i)) as pres:
pres.step_summary_text = repr(change)
with api.step.nest('snapshot_to_dir'):
- checkout.snapshot_to_dir(api.path['start_dir'] / 'snapshot')
+ checkout.snapshot_to_dir(api.path.start_dir / 'snapshot')
def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]:
diff --git a/recipe_modules/checkout/tests/submodule.py b/recipe_modules/checkout/tests/submodule.py
index fcec70a..dd34efb 100644
--- a/recipe_modules/checkout/tests/submodule.py
+++ b/recipe_modules/checkout/tests/submodule.py
@@ -33,7 +33,7 @@
checkout = api.checkout(props.checkout_options)
with api.step.nest('snapshot_to_dir'):
- checkout.snapshot_to_dir(api.path['start_dir'] / 'snapshot')
+ checkout.snapshot_to_dir(api.path.start_dir / 'snapshot')
def GenTests(api) -> Generator[recipe_test_api.TestData, None, None]:
diff --git a/recipe_modules/cipd_upload/tests/full.py b/recipe_modules/cipd_upload/tests/full.py
index 8504921..2950e55 100644
--- a/recipe_modules/cipd_upload/tests/full.py
+++ b/recipe_modules/cipd_upload/tests/full.py
@@ -49,7 +49,7 @@
): # pylint: disable=invalid-name
"""Run test steps."""
- package_root = api.path['start_dir'] / (package_root or 'pkgroot')
+ package_root = api.path.start_dir / (package_root or 'pkgroot')
metadata = [('abc', '123')]
diff --git a/recipe_modules/environment/api.py b/recipe_modules/environment/api.py
index 273cb33..76e95c4 100644
--- a/recipe_modules/environment/api.py
+++ b/recipe_modules/environment/api.py
@@ -120,11 +120,11 @@
if env.env['BUILDBUCKET_NAME'] == '::':
env.env['BUILDBUCKET_NAME'] = 'project:bucket:builder'
- env.env['CCACHE_DIR'] = self.m.path['cache'] / 'ccache'
- env.env['CTCACHE_DIR'] = self.m.path['cache'] / 'clang_tidy'
- env.env['GOCACHE'] = self.m.path['cache'] / 'go'
- env.env['PIP_CACHE_DIR'] = self.m.path['cache'] / 'pip'
- env.env['TEST_TMPDIR'] = self.m.path['cache'] / 'bazel'
+ env.env['CCACHE_DIR'] = self.m.path.cache_dir / 'ccache'
+ env.env['CTCACHE_DIR'] = self.m.path.cache_dir / 'clang_tidy'
+ env.env['GOCACHE'] = self.m.path.cache_dir / 'go'
+ env.env['PIP_CACHE_DIR'] = self.m.path.cache_dir / 'pip'
+ env.env['TEST_TMPDIR'] = self.m.path.cache_dir / 'bazel'
env.env['TRIGGERING_CHANGES_JSON'] = env.checkout.changes_json
diff --git a/recipe_modules/environment/tests/full.py b/recipe_modules/environment/tests/full.py
index d90e4af..b65ab09 100644
--- a/recipe_modules/environment/tests/full.py
+++ b/recipe_modules/environment/tests/full.py
@@ -45,7 +45,7 @@
env_opts = None
env = api.environment.init(
- checkout=_FakeCheckoutContext(api.path['start_dir']),
+ checkout=_FakeCheckoutContext(api.path.start_dir),
use_constraint_file=False,
options=env_opts,
)
diff --git a/recipe_modules/pw_presubmit/tests/full.py b/recipe_modules/pw_presubmit/tests/full.py
index b0c753b..2334d62 100644
--- a/recipe_modules/pw_presubmit/tests/full.py
+++ b/recipe_modules/pw_presubmit/tests/full.py
@@ -40,11 +40,11 @@
def RunSteps(api, props): # pylint: disable=invalid-name
presubmit = api.pw_presubmit.init(
- api.path['start_dir'] / 'checkout',
+ api.path.start_dir / 'checkout',
props.pw_presubmit_options,
)
- log_dir = api.path['start_dir'] / 'logs'
+ log_dir = api.path.start_dir / 'logs'
for i, step in enumerate(presubmit.steps):
# Need to take path with and without log_dir argument for coverage.
diff --git a/recipe_modules/repo/examples/find_root.py b/recipe_modules/repo/examples/find_root.py
index 787c517..c42241f 100644
--- a/recipe_modules/repo/examples/find_root.py
+++ b/recipe_modules/repo/examples/find_root.py
@@ -17,7 +17,7 @@
def RunSteps(api):
- cwd = api.path['cleanup']
+ cwd = api.path.cleanup_dir
with api.context(cwd=cwd):
# diff_manifests_informational calls _find_root(). Use that to cover
@@ -29,10 +29,10 @@
# Next, call _find_root from a subdirectory. Should not affect
# context.cwd.
- cwd = api.path['cleanup'] / 'test' / 'dir' / 'sub'
+ cwd = api.path.cleanup_dir / 'test' / 'dir' / 'sub'
api.file.ensure_directory('test dir', cwd)
expected = str(cwd)
- api.path.mock_add_paths(api.path['cleanup'] / 'test' / '.repo')
+ api.path.mock_add_paths(api.path.cleanup_dir / 'test' / '.repo')
with api.context(cwd=cwd):
api.repo._find_root() # pylint: disable=protected-access
api.assertions.assertEqual(expected, str(api.context.cwd))
diff --git a/recipe_modules/repo/examples/full.py b/recipe_modules/repo/examples/full.py
index a55c7a4..f8588f1 100644
--- a/recipe_modules/repo/examples/full.py
+++ b/recipe_modules/repo/examples/full.py
@@ -20,12 +20,12 @@
def RunSteps(api): # pylint: disable=missing-function-docstring
- with api.context(cwd=api.path['cleanup']):
+ with api.context(cwd=api.path.cleanup_dir):
api.assertions.assertIsNone(
api.repo._find_root()
) # pylint: disable=protected-access
- checkout = api.path['start_dir'] / 'checkout'
+ checkout = api.path.start_dir / 'checkout'
with api.context(cwd=checkout):
api.repo.init('http://manifest_url')
@@ -70,10 +70,10 @@
snapshot_a = checkout / 'snapshot_a.xml'
snapshot_b = checkout / 'snapshot_b.xml'
- with api.context(cwd=api.path['cleanup']):
+ with api.context(cwd=api.path.cleanup_dir):
api.repo.diff_manifests_informational(snapshot_a, snapshot_b)
- repo_root = api.path['start_dir'] / 'repo'
+ repo_root = api.path.start_dir / 'repo'
api.path.mock_add_paths(repo_root / '.repo')
with api.context(cwd=repo_root / 'subdir'):
api.repo.diff_manifests_informational(snapshot_a, snapshot_b)
@@ -100,7 +100,7 @@
api.assertions.assertEqual(diff.to_rev, 'TO_REV')
api.repo.ensure_synced_checkout(
- api.path['cleanup'] / 'ensure', 'http://manifest_url'
+ api.path.cleanup_dir / 'ensure', 'http://manifest_url'
)
api.repo.start('no-projects')
diff --git a/recipe_modules/repo/examples/repo_retry_failure.py b/recipe_modules/repo/examples/repo_retry_failure.py
index 505ee2a..f147170 100644
--- a/recipe_modules/repo/examples/repo_retry_failure.py
+++ b/recipe_modules/repo/examples/repo_retry_failure.py
@@ -19,7 +19,7 @@
def RunSteps(api):
api.repo.ensure_synced_checkout(
- api.path['cleanup'] / 'ensure', 'http://manifest_url'
+ api.path.cleanup_dir / 'ensure', 'http://manifest_url'
)
diff --git a/recipe_modules/repo/examples/repo_retry_success.py b/recipe_modules/repo/examples/repo_retry_success.py
index 143bd6c..e06a432 100644
--- a/recipe_modules/repo/examples/repo_retry_success.py
+++ b/recipe_modules/repo/examples/repo_retry_success.py
@@ -19,7 +19,7 @@
def RunSteps(api):
api.repo.ensure_synced_checkout(
- api.path['cleanup'] / 'ensure', 'http://manifest_url'
+ api.path.cleanup_dir / 'ensure', 'http://manifest_url'
)
diff --git a/recipe_modules/roll_util/tests/multiple_rolls.py b/recipe_modules/roll_util/tests/multiple_rolls.py
index a2d85e6..f7efd15 100644
--- a/recipe_modules/roll_util/tests/multiple_rolls.py
+++ b/recipe_modules/roll_util/tests/multiple_rolls.py
@@ -26,7 +26,7 @@
def RunSteps(api):
# pylint: disable=unnecessary-lambda
- path = lambda name: api.path['start_dir'] / name
+ path = lambda name: api.path.start_dir / name
rolls = [
api.roll_util.create_roll(
diff --git a/recipe_modules/roll_util/tests/single_roll.py b/recipe_modules/roll_util/tests/single_roll.py
index 8218faf..e83ac41 100644
--- a/recipe_modules/roll_util/tests/single_roll.py
+++ b/recipe_modules/roll_util/tests/single_roll.py
@@ -37,10 +37,10 @@
def RunSteps( # pylint: disable=invalid-name
api, project_name, old_revision, new_revision
):
- proj_dir = api.path['start_dir'] / 'project'
+ proj_dir = api.path.start_dir / 'project'
direction = api.roll_util.get_roll_direction(
- api.path['start_dir'] / 'checkout', old_revision, new_revision
+ api.path.start_dir / 'checkout', old_revision, new_revision
)
if api.roll_util.can_roll(direction):
roll = api.roll_util.create_roll(
diff --git a/recipe_modules/save_logs/tests/full.py b/recipe_modules/save_logs/tests/full.py
index 27e830f..2a64663 100644
--- a/recipe_modules/save_logs/tests/full.py
+++ b/recipe_modules/save_logs/tests/full.py
@@ -27,8 +27,8 @@
def RunSteps(api):
with api.step.nest('save logs') as pres:
api.save_logs(
- (api.path['start_dir'] / 'checkout',),
- export_dir=api.path['start_dir'] / 'export',
+ (api.path.start_dir / 'checkout',),
+ export_dir=api.path.start_dir / 'export',
pres=pres,
step_passed=False,
step_name='step1',
diff --git a/recipe_modules/util/tests/full.py b/recipe_modules/util/tests/full.py
index 2963622..799441b 100644
--- a/recipe_modules/util/tests/full.py
+++ b/recipe_modules/util/tests/full.py
@@ -40,7 +40,7 @@
raise api.step.StepFailure('failure')
api.file.write_json(
'write metadata',
- api.path['start_dir'].join('metadata.json'),
+ api.path.start_dir.join('metadata.json'),
api.util.build_metadata(),
)
diff --git a/recipes/envtest.py b/recipes/envtest.py
index 9003a2a..d211580 100644
--- a/recipes/envtest.py
+++ b/recipes/envtest.py
@@ -44,7 +44,7 @@
props.checkout_options
)
- run: config_types.Path = api.path['start_dir'] / 'run'
+ run: config_types.Path = api.path.start_dir / 'run'
api.file.ensure_directory('mkdir run', run)
setup_path: config_types.Path = checkout.root / (
@@ -56,7 +56,7 @@
k, v = entry.split(u'=', 1)
env[str(k)] = str(v)
- env_root: config_types.Path = api.path['start_dir'] / 'environment'
+ env_root: config_types.Path = api.path.start_dir / 'environment'
env['PW_ENVIRONMENT_ROOT'] = env_root
env['PW_PRESUBMIT_DISABLE_SUBPROCESS_CAPTURE'] = '1'
env['PW_ENVIRONMENT_NO_ERROR_ON_UNRECOGNIZED'] = '1'
diff --git a/recipes/pw_presubmit.py b/recipes/pw_presubmit.py
index 279f2be..56a05cc 100644
--- a/recipes/pw_presubmit.py
+++ b/recipes/pw_presubmit.py
@@ -184,7 +184,7 @@
with env():
namespace = api.pw_presubmit.build_id(presubmit)
- checkout_dir = api.path['start_dir'] / 'checkout_upload'
+ checkout_dir = api.path.start_dir / 'checkout_upload'
checkout.snapshot_to_dir(checkout_dir)
futures = [
api.futures.spawn(
@@ -285,7 +285,7 @@
def ls_export(step_name, *files):
return api.path.exists(
- api.path['start_dir'] / 'presubmit' / step_name / 'export'
+ api.path.start_dir / 'presubmit' / step_name / 'export'
) + api.step_data(
f'upload.ls {step_name}/export',
api.file.listdir(files),
diff --git a/recipes/repo_roller.py b/recipes/repo_roller.py
index 782441d..8c5d5db 100644
--- a/recipes/repo_roller.py
+++ b/recipes/repo_roller.py
@@ -167,7 +167,7 @@
# latest revision of this repository. The use_trigger flag should have no
# effect but using it to be explicit. Checking out even if not needed so
# commit messages can be collected later.
- proj_dir = api.path['start_dir'] / 'project'
+ proj_dir = api.path.start_dir / 'project'
proj_checkout = api.checkout(
CheckoutOptions(
remote=manifest_remote, branch=proj_branch, use_trigger=False
diff --git a/recipes/target_to_cipd.py b/recipes/target_to_cipd.py
index 30a6ded..530435e 100644
--- a/recipes/target_to_cipd.py
+++ b/recipes/target_to_cipd.py
@@ -63,13 +63,13 @@
# single value instead of using steps[0].
for step in presubmit.steps:
assert step.export_dir
- log_dir = api.path['start_dir'] / 'logs'
+ log_dir = api.path.start_dir / 'logs'
api.pw_presubmit.run(presubmit, step, log_dir=log_dir)
build_dir = step.dir
export_dir = step.export_dir
break # Not required but makes flow clearer at a glance.
- pkg_dir = api.path['start_dir'] / 'cipd-package'
+ pkg_dir = api.path.start_dir / 'cipd-package'
if props.artifacts:
api.file.ensure_directory('mkdir cipd-package', pkg_dir)
diff --git a/recipes/txt_roller.py b/recipes/txt_roller.py
index b37ca47..60e3bf3 100644
--- a/recipes/txt_roller.py
+++ b/recipes/txt_roller.py
@@ -82,7 +82,7 @@
'({})'.format(bb_remote, project_remote)
)
- project_dir: config_types.Path = api.path['start_dir'] / 'project'
+ project_dir: config_types.Path = api.path.start_dir / 'project'
project_checkout: api.checkout.CheckoutContext = api.checkout(
CheckoutOptions(
diff --git a/recipes/xrefs.py b/recipes/xrefs.py
index cf7cc19..9b9a24c 100644
--- a/recipes/xrefs.py
+++ b/recipes/xrefs.py
@@ -56,7 +56,7 @@
env.PW_KYTHE_CIPD_INSTALL_DIR
)
except AttributeError:
- api.kythe.kythe_dir = api.path['start_dir'] / 'kythe'
+ api.kythe.kythe_dir = api.path.start_dir / 'kythe'
api.kythe.kythe_libs_dir = api.kythe.kythe_dir