blob: 86516eeabc0c5679dc83733ac38dc83ca2452dd7 [file] [log] [blame]
# Copyright 2021 The Pigweed Authors
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""Recipe for running a specified script from."""
import re
from import InputProperties
DEPS = [
PROPERTIES = InputProperties
def RunSteps(api, props):
checkout = api.checkout(props.checkout_options)
env = api.environment.init(checkout.root, props.environment_options)
cmd = [checkout.root.join(props.script)]
with env():
for arg in props.arguments:
repl = lambda match: getattr(env,
arg = re.sub(r'\$([\w]+)', repl, arg)
arg = re.sub(r'\$\{([\w]+)\}', repl, arg)
with api.context(cwd=checkout.root):
api.step('run {}'.format(props.script), cmd)
def GenTests(api):
def properties(**kwargs):
new_kwargs = api.checkout.git_properties()
yield (
+ properties(script='foo/bar/', arguments='foo bar'.split())
yield (
+ properties(
arguments='without=$PW_TEST_VAR with=${PW_TEST_VAR}'.split(),