9from recipe_engine
import recipe_api
12TEST_DEFAULT_ASSET_VERSION =
'42'
17 """Initialize the recipe module."""
18 super(SkiaStepApi, self).
__init__(*args, **kwargs)
26 """Raise an exception if any step failed."""
28 raise self.m.step.StepFailure(
'Failed build steps: %s' %
41 """Convenience function for reading files."""
42 name = kwargs.pop(
'name',
'read %s' % self.m.path.basename(filename))
43 return self.m.file.read_text(name, filename, *args, **kwargs)
46 """Convenience function for writing files."""
47 return self.m.file.write_text(
'write %s' % self.m.path.basename(filename),
51 """Wrapper around api.file.rmtree."""
52 self.m.file.rmtree(
'rmtree %s' % self.m.path.basename(path), path)
55 """Return the contents of VERSION for the given asset as a string.
57 If test_data is not specified, reads the property
58 'test_<asset_name>_version' or if not present, uses
59 TEST_DEFAULT_ASSET_VERSION.
"""
60 version_file = skia_dir.join(
61 'infra',
'bots',
'assets', asset_name,
'VERSION')
63 test_data = self.m.properties.get(
64 'test_%s_version' % asset_name, TEST_DEFAULT_ASSET_VERSION)
65 return self.m.file.read_text(
'Get %s VERSION' % asset_name,
67 test_data=test_data).rstrip()
69 def __call__(self, steptype, name, abort_on_failure=True,
70 fail_build_on_failure=True, **kwargs):
71 """Run a step. If it fails, keep going but mark the build status failed."""
73 with self.m.
env(self.m.vars.default_env):
74 return steptype(name=name, **kwargs)
75 except self.m.step.StepFailure
as e:
76 if fail_build_on_failure:
81 def with_retry(self, steptype, name, attempts, between_attempts_fn=None,
82 abort_on_failure=True, fail_build_on_failure=True, **kwargs):
83 for attempt
in range(attempts):
86 step_name +=
' (attempt %d)' % (attempt + 1)
88 res =
self(steptype, name=step_name, abort_on_failure=
True,
89 fail_build_on_failure=fail_build_on_failure, **kwargs)
90 if attempt > 0
and fail_build_on_failure:
93 except self.m.step.StepFailure:
94 if between_attempts_fn:
95 between_attempts_fn(attempt+1)
96 if (attempt == attempts - 1)
and abort_on_failure:
def asset_version(self, asset_name, skia_dir, test_data=None)
def __call__(self, steptype, name, abort_on_failure=True, fail_build_on_failure=True, **kwargs)
def readfile(self, filename, *args, **kwargs)
def with_retry(self, steptype, name, attempts, between_attempts_fn=None, abort_on_failure=True, fail_build_on_failure=True, **kwargs)
def run_once(self, fn, *args, **kwargs)
def writefile(self, filename, contents)
def __init__(self, *args, **kwargs)
static void append(char **dst, size_t *count, const char *src, size_t n)
static SkString join(const CommandLineFlags::StringArray &)