OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Set of utilities to add commands to a buildbot factory. | 5 """Set of utilities to add commands to a buildbot factory. |
6 | 6 |
7 This is based on commands.py and adds skia-specific commands. | 7 This is based on commands.py and adds skia-specific commands. |
8 | 8 |
9 TODO(borenet): Do we need this file at all? Can't we just do everything | 9 TODO(borenet): Do we need this file at all? Can't we just do everything |
10 in factory.py? (See https://codereview.chromium.org/248053003/ ) | 10 in factory.py? (See https://codereview.chromium.org/248053003/ ) |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 '--svn_username_file', svn_username_file, | 63 '--svn_username_file', svn_username_file, |
64 ] | 64 ] |
65 self.AddSlaveScript(script=self.PathJoin('utils', 'merge_into_svn.py'), | 65 self.AddSlaveScript(script=self.PathJoin('utils', 'merge_into_svn.py'), |
66 args=args, description=description, timeout=timeout, | 66 args=args, description=description, timeout=timeout, |
67 is_upload_step=True, | 67 is_upload_step=True, |
68 is_rebaseline_step=is_rebaseline_step) | 68 is_rebaseline_step=is_rebaseline_step) |
69 | 69 |
70 # TODO(borenet): Can kwargs be used to simplify this function declaration? | 70 # TODO(borenet): Can kwargs be used to simplify this function declaration? |
71 def AddSlaveScript(self, script, args, description, timeout=None, | 71 def AddSlaveScript(self, script, args, description, timeout=None, |
72 halt_on_failure=False, is_upload_step=False, | 72 halt_on_failure=False, is_upload_step=False, |
73 is_rebaseline_step=False, get_props_from_stdout=None, | 73 is_rebaseline_step=False, |
| 74 get_links_from_stdout=None, get_props_from_stdout=None, |
74 workdir=None, do_step_if=None, | 75 workdir=None, do_step_if=None, |
75 always_run=False, flunk_on_failure=True, | 76 always_run=False, flunk_on_failure=True, |
76 exception_on_failure=False): | 77 exception_on_failure=False): |
77 """Run a slave-side Python script as its own build step.""" | 78 """Run a slave-side Python script as its own build step.""" |
78 if workdir: | 79 if workdir: |
79 path_to_script = script | 80 path_to_script = script |
80 use_workdir = workdir | 81 use_workdir = workdir |
81 else: | 82 else: |
82 path_to_script = self.PathJoin(self._local_slave_script_dir, script) | 83 path_to_script = self.PathJoin(self._local_slave_script_dir, script) |
83 use_workdir = self.workdir | 84 use_workdir = self.workdir |
84 self.AddRunCommand(command=['python', path_to_script] + args, | 85 self.AddRunCommand(command=['python', path_to_script] + args, |
85 description=description, timeout=timeout, | 86 description=description, timeout=timeout, |
86 halt_on_failure=halt_on_failure, | 87 halt_on_failure=halt_on_failure, |
87 is_upload_step=is_upload_step, | 88 is_upload_step=is_upload_step, |
88 is_rebaseline_step=is_rebaseline_step, | 89 is_rebaseline_step=is_rebaseline_step, |
| 90 get_links_from_stdout=get_links_from_stdout, |
89 get_props_from_stdout=get_props_from_stdout, | 91 get_props_from_stdout=get_props_from_stdout, |
90 workdir=use_workdir, | 92 workdir=use_workdir, |
91 do_step_if=do_step_if, | 93 do_step_if=do_step_if, |
92 always_run=always_run, | 94 always_run=always_run, |
93 flunk_on_failure=flunk_on_failure, | 95 flunk_on_failure=flunk_on_failure, |
94 exception_on_failure=exception_on_failure) | 96 exception_on_failure=exception_on_failure) |
95 | 97 |
96 # TODO(borenet): Can kwargs be used to simplify this function declaration? | 98 # TODO(borenet): Can kwargs be used to simplify this function declaration? |
97 def AddRunCommand(self, command, description='Run', timeout=None, | 99 def AddRunCommand(self, command, description='Run', timeout=None, |
98 halt_on_failure=False, is_upload_step=False, | 100 halt_on_failure=False, is_upload_step=False, |
99 is_rebaseline_step=False, get_props_from_stdout=None, | 101 is_rebaseline_step=False, |
| 102 get_links_from_stdout=None, get_props_from_stdout=None, |
100 workdir=None, do_step_if=None, always_run=False, | 103 workdir=None, do_step_if=None, always_run=False, |
101 flunk_on_failure=True, exception_on_failure=False): | 104 flunk_on_failure=True, exception_on_failure=False): |
102 """Runs an arbitrary command, perhaps a binary we built.""" | 105 """Runs an arbitrary command, perhaps a binary we built.""" |
103 if description not in self.factory.dontskipsteps: | 106 if description not in self.factory.dontskipsteps: |
104 if description in self.factory.skipsteps: | 107 if description in self.factory.skipsteps: |
105 return | 108 return |
106 | 109 |
107 # If a developer has marked the step as dontskip, make sure it will run. | 110 # If a developer has marked the step as dontskip, make sure it will run. |
108 if description in self.factory.dontskipsteps: | 111 if description in self.factory.dontskipsteps: |
109 do_step_if = True | 112 do_step_if = True |
110 | 113 |
111 if not timeout: | 114 if not timeout: |
112 timeout = self.default_timeout | 115 timeout = self.default_timeout |
113 self.factory.addStep(skia_build_step.SkiaBuildStep, | 116 self.factory.addStep(skia_build_step.SkiaBuildStep, |
114 is_upload_step=is_upload_step, | 117 is_upload_step=is_upload_step, |
115 is_rebaseline_step=is_rebaseline_step, | 118 is_rebaseline_step=is_rebaseline_step, |
| 119 get_links_from_stdout=get_links_from_stdout, |
116 get_props_from_stdout=get_props_from_stdout, | 120 get_props_from_stdout=get_props_from_stdout, |
117 description=description, timeout=timeout, | 121 description=description, timeout=timeout, |
118 command=command, workdir=workdir or self.workdir, | 122 command=command, workdir=workdir or self.workdir, |
119 env=self.environment_variables, | 123 env=self.environment_variables, |
120 haltOnFailure=halt_on_failure, | 124 haltOnFailure=halt_on_failure, |
121 doStepIf=do_step_if or skia_build_step.ShouldDoStep, | 125 doStepIf=do_step_if or skia_build_step.ShouldDoStep, |
122 alwaysRun=always_run, | 126 alwaysRun=always_run, |
123 flunkOnFailure=flunk_on_failure, | 127 flunkOnFailure=flunk_on_failure, |
124 exception_on_failure=exception_on_failure, | 128 exception_on_failure=exception_on_failure, |
125 hideStepIf=lambda s: s.isSkipped()) | 129 hideStepIf=lambda s: s.isSkipped()) |
126 | 130 |
127 # TODO(borenet): Can kwargs be used to simplify this function declaration? | 131 # TODO(borenet): Can kwargs be used to simplify this function declaration? |
128 def AddRunCommandList(self, command_list, description='Run', timeout=None, | 132 def AddRunCommandList(self, command_list, description='Run', timeout=None, |
129 halt_on_failure=False, is_upload_step=False, | 133 halt_on_failure=False, is_upload_step=False, |
130 is_rebaseline_step=False): | 134 is_rebaseline_step=False): |
131 """Runs a list of arbitrary commands.""" | 135 """Runs a list of arbitrary commands.""" |
132 # TODO(epoger): Change this so that build-step output shows each command | 136 # TODO(epoger): Change this so that build-step output shows each command |
133 # in the list separately--that will be a lot easier to follow. | 137 # in the list separately--that will be a lot easier to follow. |
134 # | 138 # |
135 # TODO(epoger): For now, this wraps the total command with WithProperties() | 139 # TODO(epoger): For now, this wraps the total command with WithProperties() |
136 # because *some* callers need it, and we can't use the string.join() command | 140 # because *some* callers need it, and we can't use the string.join() command |
137 # to concatenate strings that have already been wrapped with | 141 # to concatenate strings that have already been wrapped with |
138 # WithProperties(). Once I figure out how to make the build-step output | 142 # WithProperties(). Once I figure out how to make the build-step output |
139 # show each command separately, maybe I can remove this wrapper. | 143 # show each command separately, maybe I can remove this wrapper. |
140 self.AddRunCommand(command=WithProperties(' && '.join(command_list)), | 144 self.AddRunCommand(command=WithProperties(' && '.join(command_list)), |
141 description=description, timeout=timeout, | 145 description=description, timeout=timeout, |
142 halt_on_failure=halt_on_failure, | 146 halt_on_failure=halt_on_failure, |
143 is_upload_step=is_upload_step, | 147 is_upload_step=is_upload_step, |
144 is_rebaseline_step=is_rebaseline_step) | 148 is_rebaseline_step=is_rebaseline_step) |
OLD | NEW |