Chromium Code Reviews| Index: scripts/slave/recipe_modules/filter/api.py |
| diff --git a/scripts/slave/recipe_modules/filter/api.py b/scripts/slave/recipe_modules/filter/api.py |
| index f62ffd4c967555731c55c7821fe0c74a7a09b552..cad4b38ddd56d0258d2965ed90974d80a34ff0a5 100644 |
| --- a/scripts/slave/recipe_modules/filter/api.py |
| +++ b/scripts/slave/recipe_modules/filter/api.py |
| @@ -131,6 +131,12 @@ class FilterApi(recipe_api.RecipeApi): |
| self._compile_targets = [] |
| self._paths = affected_files |
| + analyze_input = { |
| + 'files': self.paths, |
| + 'test_targets': test_targets, |
| + 'additional_compile_targets': additional_compile_targets, |
| + } |
| + |
| # Check the path of each file against the exclusion list. If found, no need |
| # to check dependencies. |
| exclusion_regexs = [re.compile(exclusion) for exclusion in exclusions] |
| @@ -139,29 +145,25 @@ class FilterApi(recipe_api.RecipeApi): |
| for path in self.paths: |
| first_match = self.__is_path_in_regex_list(path, exclusion_regexs) |
| if first_match: |
| + analyze_result = 'Analyze disabled: matched exclusion' |
| # TODO(phajdan.jr): consider using plain api.step here, not python. |
| - step_result = self.m.python.succeeding_step( |
| - 'analyze', 'Analyze disabled: matched exclusion') |
| + step_result = self.m.python.succeeding_step('analyze', analyze_result) |
| step_result.presentation.logs.setdefault('excluded_files', []).append( |
| '%s (regex = \'%s\')' % (path, first_match)) |
| self._compile_targets = sorted(all_targets) |
| self._test_targets = sorted(test_targets) |
| + self._report_analyze_result(analyze_input, {'status': analyze_result}) |
| return |
| if not self.__is_path_in_regex_list(path, ignore_regexs): |
| ignored = False |
| if ignored: |
| - self.m.python.succeeding_step( |
| - 'analyze', 'No compile necessary (all files ignored)') |
| + analyze_result = 'No compile necessary (all files ignored)' |
| + self.m.python.succeeding_step('analyze', analyze_result) |
| + self._report_analyze_result(analyze_input, {'status': analyze_result}) |
| return |
| - analyze_input = { |
| - 'files': self.paths, |
| - 'test_targets': test_targets, |
| - 'additional_compile_targets': additional_compile_targets, |
| - } |
| - |
| test_output = { |
| 'status': 'No dependency', |
| 'compile_targets': [], |
| @@ -215,31 +217,34 @@ class FilterApi(recipe_api.RecipeApi): |
| test_output), |
| **kwargs) |
| - if 'error' in step_result.json.output: |
| - step_result.presentation.step_text = 'Error: ' + \ |
| - step_result.json.output['error'] |
| - raise self.m.step.StepFailure( |
| - 'Error: ' + step_result.json.output['error']) |
| - |
| - if 'invalid_targets' in step_result.json.output: |
| - raise self.m.step.StepFailure('Error, following targets were not ' + \ |
| - 'found: ' + ', '.join(step_result.json.output['invalid_targets'])) |
| - |
| - if (step_result.json.output['status'] == 'Found dependency' or |
| - step_result.json.output['status'] == 'Found dependency (all)'): |
| - self._compile_targets = step_result.json.output['compile_targets'] |
| - self._test_targets = step_result.json.output['test_targets'] |
| - |
| - # TODO(dpranke) crbug.com/557505 - we need to not prune meta |
| - # targets that are part of 'test_targets', because otherwise |
| - # we might not actually build all of the binaries needed for |
| - # a given test, even if they aren't affected by the patch. |
| - # Until the GYP code is updated, we will merge the returned |
| - # test_targets into compile_targets to be safe. |
| - self._compile_targets = sorted(set(self._compile_targets + |
| - self._test_targets)) |
| - else: |
| - step_result.presentation.step_text = 'No compile necessary' |
| + try: |
| + if 'error' in step_result.json.output: |
| + step_result.presentation.step_text = 'Error: ' + \ |
|
chrishall
2016/10/07 06:36:26
not sure if this trailing \ is needed, below we ha
Paweł Hajdan Jr.
2016/10/07 10:50:54
Done.
|
| + step_result.json.output['error'] |
| + raise self.m.step.StepFailure( |
| + 'Error: ' + step_result.json.output['error']) |
| + |
| + if 'invalid_targets' in step_result.json.output: |
| + raise self.m.step.StepFailure('Error, following targets were not ' + \ |
|
chrishall
2016/10/07 06:36:26
same here, not sure if this trailing \ is needed,
Paweł Hajdan Jr.
2016/10/07 10:50:54
Done.
|
| + 'found: ' + ', '.join(step_result.json.output['invalid_targets'])) |
| + |
| + if (step_result.json.output['status'] == 'Found dependency' or |
| + step_result.json.output['status'] == 'Found dependency (all)'): |
|
chrishall
2016/10/07 06:36:26
could change this to
if step_result.json.output['
Paweł Hajdan Jr.
2016/10/07 10:50:54
Done.
|
| + self._compile_targets = step_result.json.output['compile_targets'] |
| + self._test_targets = step_result.json.output['test_targets'] |
| + |
| + # TODO(dpranke) crbug.com/557505 - we need to not prune meta |
| + # targets that are part of 'test_targets', because otherwise |
| + # we might not actually build all of the binaries needed for |
| + # a given test, even if they aren't affected by the patch. |
| + # Until the GYP code is updated, we will merge the returned |
| + # test_targets into compile_targets to be safe. |
| + self._compile_targets = sorted(set(self._compile_targets + |
|
chrishall
2016/10/07 06:36:26
this is the line that ends in + and lacks trailing
|
| + self._test_targets)) |
| + else: |
| + step_result.presentation.step_text = 'No compile necessary' |
| + finally: |
| + self._report_analyze_result(analyze_input, step_result.json.output) |
| # TODO(phajdan.jr): Merge with does_patch_require_compile. |
| def analyze(self, affected_files, test_targets, additional_compile_targets, |
| @@ -284,3 +289,26 @@ class FilterApi(recipe_api.RecipeApi): |
| step_result.presentation.logs['analyze_details'] = listio.lines |
| return self.test_targets, compile_targets |
| + |
| + def _report_analyze_result(self, analyze_input, analyze_output): |
| + try: |
| + self.m.python( |
| + 'analyze report', |
| + self.package_repo_resource('scripts', 'tools', 'runit.py'), |
| + [ |
| + '--show-path', |
| + 'python', |
| + self.package_repo_resource( |
| + 'scripts', 'slave', 'send_analyze_event.py'), |
| + # TODO(phajdan.jr): switch to prod. |
| + '--event-mon-run-type', 'test', |
| + '--master-name', self.m.properties.get('mastername', ''), |
| + '--builder-name', self.m.properties.get('buildername', ''), |
| + '--build-id', self.m.properties.get('buildnumber', ''), |
| + '--analyze-input', self.m.json.input(analyze_input), |
| + '--analyze-output', self.m.json.input(analyze_output), |
| + ], |
| + ) |
| + except self.m.step.StepFailure: # pragma: no cover |
| + # TODO(phajdan.jr): make report failures fatal. |
| + pass |