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