OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 DEPS = [ | 5 DEPS = [ |
6 'chromium', | 6 'chromium', |
7 'filter', | 7 'filter', |
| 8 'json', |
8 'path', | 9 'path', |
9 'properties', | 10 'properties', |
10 'raw_io', | 11 'raw_io', |
11 ] | 12 ] |
12 | 13 |
13 def GenSteps(api): | 14 def GenSteps(api): |
14 api.path['checkout'] = api.path['slave_build'] | 15 api.path['checkout'] = api.path['slave_build'] |
15 api.chromium.set_config('chromium') | 16 api.chromium.set_config('chromium') |
16 api.filter.does_patch_require_compile() | 17 api.filter.does_patch_require_compile() |
17 assert (api.filter.result and api.properties['example_result']) or \ | 18 assert (api.filter.result and api.properties['example_result']) or \ |
18 (not api.filter.result and not api.properties['example_result']) | 19 (not api.filter.result and not api.properties['example_result']) |
| 20 assert (not api.properties['example_matching_exes'] or |
| 21 list(api.properties['example_matching_exes']) == |
| 22 api.filter.matching_exes) |
19 | 23 |
20 def GenTests(api): | 24 def GenTests(api): |
21 # Trivial test with no exclusions and nothing matching. | 25 # Trivial test with no exclusions and nothing matching. |
22 yield (api.test('basic') + | 26 yield (api.test('basic') + |
23 api.properties(filter_exclusions=[]) + | 27 api.properties(filter_exclusions=[]) + |
24 api.properties(example_result=None) + | 28 api.properties(example_result=None) + |
25 api.override_step_data( | 29 api.properties(example_matching_exes=None) + |
26 'analyze', | |
27 api.raw_io.stream_output('xx')) + | |
28 api.override_step_data( | 30 api.override_step_data( |
29 'git diff to analyze patch', | 31 'git diff to analyze patch', |
30 api.raw_io.stream_output('yy'))) | 32 api.raw_io.stream_output('yy'))) |
31 | 33 |
32 # Matches exclusions | 34 # Matches exclusions |
33 yield (api.test('match_exclusion') + | 35 yield (api.test('match_exclusion') + |
34 api.properties(filter_exclusions=['fo.*']) + | 36 api.properties(filter_exclusions=['fo.*']) + |
35 api.properties(example_result=1) + | 37 api.properties(example_result=1) + |
| 38 api.properties(example_matching_exes=None) + |
36 api.override_step_data( | 39 api.override_step_data( |
37 'git diff to analyze patch', | 40 'git diff to analyze patch', |
38 api.raw_io.stream_output('foo.cc'))) | 41 api.raw_io.stream_output('foo.cc'))) |
39 | 42 |
40 # Doesnt match exclusion. | 43 # Doesnt match exclusion. |
41 yield (api.test('doesnt_match_exclusion') + | 44 yield (api.test('doesnt_match_exclusion') + |
42 api.properties(filter_exclusions=['fo.*']) + | 45 api.properties(filter_exclusions=['fo.*']) + |
43 api.properties(example_result=None) + | 46 api.properties(example_result=None) + |
44 api.override_step_data( | 47 api.properties(example_matching_exes=None) + |
45 'analyze', | |
46 api.raw_io.stream_output('xx')) + | |
47 api.override_step_data( | 48 api.override_step_data( |
48 'git diff to analyze patch', | 49 'git diff to analyze patch', |
49 api.raw_io.stream_output('bar.cc'))) | 50 api.raw_io.stream_output('bar.cc'))) |
50 | 51 |
51 # Analyze returns matching result. | 52 # Analyze returns matching result. |
52 yield (api.test('analyzes_returns_true') + | 53 yield (api.test('analyzes_returns_true') + |
53 api.properties(example_result=1) + | 54 api.properties(example_result=1) + |
| 55 api.properties(example_matching_exes=None) + |
54 api.override_step_data( | 56 api.override_step_data( |
55 'analyze', | 57 'analyze', |
56 api.raw_io.stream_output('Found dependency'))) | 58 api.json.output({'status': 'Found dependency', |
| 59 'targets': []}))) |
| 60 |
| 61 # Analyze returns matching tests. |
| 62 yield (api.test('analyzes_matches_exes') + |
| 63 api.properties(matching_exes=['foo', 'bar']) + |
| 64 api.properties(example_matching_exes=['foo']) + |
| 65 api.properties(example_result=1) + |
| 66 api.override_step_data( |
| 67 'analyze', |
| 68 api.json.output({'status': 'Found dependency', |
| 69 'targets': ['foo']}))) |
| 70 |
| 71 # Analyze with error condition. |
| 72 yield (api.test('analyzes_error') + |
| 73 api.properties(matching_exes=None) + |
| 74 api.properties(example_matching_exes=None) + |
| 75 api.properties(example_result=1) + |
| 76 api.override_step_data( |
| 77 'analyze', |
| 78 api.json.output({'error': 'ERROR'}))) |
OLD | NEW |