| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Set of utilities to add commands to a buildbot factory (BuildFactory). | 6 """Set of utilities to add commands to a buildbot factory (BuildFactory). |
| 7 | 7 |
| 8 All the utility functions to add steps to a build factory here are not | 8 All the utility functions to add steps to a build factory here are not |
| 9 project-specific. See the other *_commands.py for project-specific commands. | 9 project-specific. See the other *_commands.py for project-specific commands. |
| 10 """ | 10 """ |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 def GetTestCommand(self, executable, arg_list=None): | 144 def GetTestCommand(self, executable, arg_list=None): |
| 145 cmd = [self._python, self._test_tool, | 145 cmd = [self._python, self._test_tool, |
| 146 '--target', self._target, | 146 '--target', self._target, |
| 147 '--build-dir', self._build_dir, | 147 '--build-dir', self._build_dir, |
| 148 self.GetExecutableName(executable)] | 148 self.GetExecutableName(executable)] |
| 149 | 149 |
| 150 if arg_list is not None: | 150 if arg_list is not None: |
| 151 cmd.extend(arg_list) | 151 cmd.extend(arg_list) |
| 152 return cmd | 152 return cmd |
| 153 | 153 |
| 154 @staticmethod |
| 155 def DoStepFilterTest(bStep): |
| 156 """Examines the 'testfilters' property of the build and determines if |
| 157 the step should run; True for yes.""" |
| 158 try: |
| 159 filters = bStep.getProperty('testfilters') |
| 160 except: |
| 161 return True |
| 162 |
| 163 for filter in filters: |
| 164 if filter == bStep.name: |
| 165 return True |
| 166 if filter.startswith(("%s:" % bStep.name)): |
| 167 bStep.command.append("--gtest_filter=%s" % filter.split(':',1)[1]) |
| 168 return True |
| 169 return False |
| 170 |
| 154 def AddTestStep(self, command_class, test_name, test_command, | 171 def AddTestStep(self, command_class, test_name, test_command, |
| 155 test_description='', timeout=600, workdir=None, env=None, | 172 test_description='', timeout=600, workdir=None, env=None, |
| 156 locks=None, halt_on_failure=False): | 173 locks=None, halt_on_failure=False): |
| 157 """Adds a step to the factory to run a test. | 174 """Adds a step to the factory to run a test. |
| 158 | 175 |
| 159 Args: | 176 Args: |
| 160 command_class: the command type to run, such as shell.ShellCommand or | 177 command_class: the command type to run, such as shell.ShellCommand or |
| 161 gtest_command.GTestCommand | 178 gtest_command.GTestCommand |
| 162 test_name: a string describing the test, used to build its logfile name | 179 test_name: a string describing the test, used to build its logfile name |
| 163 and its descriptions in the waterfall display | 180 and its descriptions in the waterfall display |
| 164 timeout: the buildbot timeout for the test, in seconds. If it doesn't | 181 timeout: the buildbot timeout for the test, in seconds. If it doesn't |
| 165 produce any output to stdout or stderr for this many seconds, | 182 produce any output to stdout or stderr for this many seconds, |
| 166 buildbot will cancel it and call it a failure. | 183 buildbot will cancel it and call it a failure. |
| 167 test_command: the command list to run | 184 test_command: the command list to run |
| 168 test_description: an auxiliary description to be appended to the | 185 test_description: an auxiliary description to be appended to the |
| 169 test_name in the buildbot display; for example, ' (single process)' | 186 test_name in the buildbot display; for example, ' (single process)' |
| 170 workdir: directory where the test executable will be launched. If None, | 187 workdir: directory where the test executable will be launched. If None, |
| 171 step will use default directory. | 188 step will use default directory. |
| 172 env: dictionary with environmental variable key value pairs that will be | 189 env: dictionary with environmental variable key value pairs that will be |
| 173 set or overridden before launching the test executable. Does not do | 190 set or overridden before launching the test executable. Does not do |
| 174 anything if 'env' is None. | 191 anything if 'env' is None. |
| 175 locks: any locks to acquire for this test | 192 locks: any locks to acquire for this test |
| 176 halt_on_failure: whether the current build should halt if this step fails | 193 halt_on_failure: whether the current build should halt if this step fails |
| 177 """ | 194 """ |
| 195 doStepCondition = True |
| 196 if command_class == gtest_command.GTestCommand: |
| 197 doStepCondition = self.DoStepFilterTest |
| 198 |
| 178 self._factory.addStep( | 199 self._factory.addStep( |
| 179 command_class, | 200 command_class, |
| 180 name=test_name, | 201 name=test_name, |
| 181 timeout=timeout, | 202 timeout=timeout, |
| 203 doStepIf=doStepCondition, |
| 182 workdir=workdir, | 204 workdir=workdir, |
| 183 env=env, | 205 env=env, |
| 184 # TODO(bradnelson): FIXME | 206 # TODO(bradnelson): FIXME |
| 185 #locks=locks, | 207 #locks=locks, |
| 186 description='running %s%s' % (test_name, test_description), | 208 description='running %s%s' % (test_name, test_description), |
| 187 descriptionDone='%s%s' % (test_name, test_description), | 209 descriptionDone='%s%s' % (test_name, test_description), |
| 188 haltOnFailure=halt_on_failure, | 210 haltOnFailure=halt_on_failure, |
| 189 command=test_command) | 211 command=test_command) |
| 190 | 212 |
| 191 def AddBasicGTestTestStep(self, test_name, factory_properties=None, | 213 def AddBasicGTestTestStep(self, test_name, factory_properties=None, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 raise Exception, ('There is no mapping for identifier %s in %s' % | 483 raise Exception, ('There is no mapping for identifier %s in %s' % |
| 462 (perf_id, self._target)) | 484 (perf_id, self._target)) |
| 463 report_link = '%s/%s/%s/%s' % (self.PERF_BASE_URL, perf_name, test_name, | 485 report_link = '%s/%s/%s/%s' % (self.PERF_BASE_URL, perf_name, test_name, |
| 464 self.PERF_REPORT_URL_SUFFIX) | 486 self.PERF_REPORT_URL_SUFFIX) |
| 465 output_dir = '%s/%s/%s' % (self.PERF_OUTPUT_DIR, perf_name, test_name) | 487 output_dir = '%s/%s/%s' % (self.PERF_OUTPUT_DIR, perf_name, test_name) |
| 466 | 488 |
| 467 return self._CreatePerformanceStepClass(log_processor_class, | 489 return self._CreatePerformanceStepClass(log_processor_class, |
| 468 report_link=report_link, output_dir=output_dir, | 490 report_link=report_link, output_dir=output_dir, |
| 469 factory_properties=factory_properties, perf_name=perf_name, | 491 factory_properties=factory_properties, perf_name=perf_name, |
| 470 test_name=test_name) | 492 test_name=test_name) |
| OLD | NEW |