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 'json', |
9 'path', | 9 'path', |
10 'properties', | 10 'properties', |
11 'raw_io', | 11 'raw_io', |
12 'step', | 12 'step', |
13 ] | 13 ] |
14 | 14 |
15 def GenSteps(api): | 15 def GenSteps(api): |
16 api.path['checkout'] = api.path['slave_build'] | 16 api.path['checkout'] = api.path['slave_build'] |
17 api.chromium.set_config('chromium') | 17 api.chromium.set_config('chromium') |
18 api.filter.does_patch_require_compile() | 18 api.filter.does_patch_require_compile() |
19 assert (api.filter.result and api.properties['example_result']) or \ | 19 assert (api.filter.result and api.properties['example_result']) or \ |
20 (not api.filter.result and not api.properties['example_result']) | 20 (not api.filter.result and not api.properties['example_result']) |
21 assert (not api.properties['example_matching_exes'] or | 21 assert (list(api.properties.get('example_matching_exes', [])) == |
22 list(api.properties['example_matching_exes']) == | 22 list(api.filter.matching_exes)) |
23 api.filter.matching_exes) | 23 assert (list(api.properties.get('example_matching_compile_targets', [])) == |
| 24 api.filter.compile_targets) |
24 api.step('hello', ['echo', 'Why hello, there.']) | 25 api.step('hello', ['echo', 'Why hello, there.']) |
25 | 26 |
26 def GenTests(api): | 27 def GenTests(api): |
27 # Trivial test with no exclusions and nothing matching. | 28 # Trivial test with no exclusions and nothing matching. |
28 yield (api.test('basic') + | 29 yield (api.test('basic') + |
29 api.properties(filter_exclusions=[]) + | 30 api.properties( |
30 api.properties(example_result=None) + | 31 filter_exclusions=[], |
31 api.properties(example_matching_exes=None) + | 32 example_result=None) + |
32 api.override_step_data( | 33 api.override_step_data( |
33 'git diff to analyze patch', | 34 'git diff to analyze patch', |
34 api.raw_io.stream_output('yy'))) | 35 api.raw_io.stream_output('yy'))) |
35 | 36 |
36 # Matches exclusions | 37 # Matches exclusions |
37 yield (api.test('match_exclusion') + | 38 yield (api.test('match_exclusion') + |
38 api.properties(filter_exclusions=['fo.*']) + | 39 api.properties( |
39 api.properties(example_result=1) + | 40 filter_exclusions=['fo.*'], |
40 api.properties(example_matching_exes=None) + | 41 example_result=1) + |
41 api.override_step_data( | 42 api.override_step_data( |
42 'git diff to analyze patch', | 43 'git diff to analyze patch', |
43 api.raw_io.stream_output('foo.cc'))) | 44 api.raw_io.stream_output('foo.cc'))) |
44 | 45 |
45 # Doesnt match exclusion. | 46 # Doesnt match exclusion. |
46 yield (api.test('doesnt_match_exclusion') + | 47 yield (api.test('doesnt_match_exclusion') + |
47 api.properties(filter_exclusions=['fo.*']) + | 48 api.properties( |
48 api.properties(example_result=None) + | 49 filter_exclusions=['fo.*'], |
49 api.properties(example_matching_exes=None) + | 50 example_result=None) + |
50 api.override_step_data( | 51 api.override_step_data( |
51 'git diff to analyze patch', | 52 'git diff to analyze patch', |
52 api.raw_io.stream_output('bar.cc'))) | 53 api.raw_io.stream_output('bar.cc'))) |
53 | 54 |
54 # Analyze returns matching result. | 55 # Analyze returns matching result. |
55 yield (api.test('analyzes_returns_true') + | 56 yield (api.test('analyzes_returns_true') + |
56 api.properties(example_result=1) + | 57 api.properties(example_result=1) + |
57 api.properties(example_matching_exes=None) + | |
58 api.override_step_data( | |
59 'analyze', | |
60 api.json.output({'status': 'Found dependency', | |
61 'targets': []}))) | |
62 | |
63 # Analyze returns matching tests while matching all. | |
64 yield (api.test('analyzes_matches_all_exes') + | |
65 api.properties(matching_exes=['foo', 'bar']) + | |
66 api.properties(example_matching_exes=['foo']) + | |
67 api.properties(example_result=1) + | |
68 api.override_step_data( | |
69 'analyze', | |
70 api.json.output({'status': 'Found dependency (all)', | |
71 'targets': ['foo']}))) | |
72 | |
73 # Analyze matches all and returns matching tests. | |
74 yield (api.test('analyzes_matches_exes') + | |
75 api.properties(matching_exes=['foo', 'bar']) + | |
76 api.properties(example_matching_exes=['foo']) + | |
77 api.properties(example_result=1) + | |
78 api.override_step_data( | 58 api.override_step_data( |
79 'analyze', | 59 'analyze', |
80 api.json.output({'status': 'Found dependency', | 60 api.json.output({'status': 'Found dependency', |
81 'targets': ['foo']}))) | 61 'targets': [], |
| 62 'build_targets': []}))) |
| 63 |
| 64 # Analyze returns matching tests while matching all. |
| 65 yield (api.test('analyzes_matches_all_exes') + |
| 66 api.properties(example_result=1) + |
| 67 api.override_step_data( |
| 68 'analyze', |
| 69 api.json.output({'status': 'Found dependency (all)'}))) |
| 70 |
| 71 # Analyze matches all and returns matching tests. |
| 72 yield (api.test('analyzes_matches_exes') + |
| 73 api.properties( |
| 74 matching_exes=['foo', 'bar'], |
| 75 example_matching_exes=['foo'], |
| 76 example_result=1) + |
| 77 api.override_step_data( |
| 78 'analyze', |
| 79 api.json.output({'status': 'Found dependency', |
| 80 'targets': ['foo'], |
| 81 'build_targets': []}))) |
| 82 |
| 83 # Analyze matches all and returns matching tests. |
| 84 yield (api.test('analyzes_matches_compile_targets') + |
| 85 api.properties( |
| 86 example_matching_exes=['foo'], |
| 87 example_matching_compile_targets=['bar'], |
| 88 example_result=1) + |
| 89 api.override_step_data( |
| 90 'analyze', |
| 91 api.json.output({'status': 'Found dependency', |
| 92 'targets': ['foo'], |
| 93 'build_targets': ['bar']}))) |
82 | 94 |
83 # Analyze with error condition. | 95 # Analyze with error condition. |
84 yield (api.test('analyzes_error') + | 96 yield (api.test('analyzes_error') + |
85 api.properties(matching_exes=None) + | 97 api.properties( |
86 api.properties(example_matching_exes=None) + | 98 matching_exes=[], |
87 api.properties(example_result=1) + | 99 example_result=1) + |
88 api.override_step_data( | 100 api.override_step_data( |
89 'analyze', | 101 'analyze', |
90 api.json.output({'error': 'ERROR'}))) | 102 api.json.output({'error': 'ERROR'}))) |
91 | 103 |
92 # Analyze with python returning bad status. | 104 # Analyze with python returning bad status. |
93 yield (api.test('bad_retcode_doesnt_fail') + | 105 yield (api.test('bad_retcode_doesnt_fail') + |
94 api.properties(matching_exes=None) + | 106 api.properties( |
95 api.properties(example_matching_exes=None) + | 107 matching_exes=[], |
96 api.properties(example_result=1) + | 108 example_result=1) + |
97 api.step_data( | 109 api.step_data( |
98 'analyze', | 110 'analyze', |
99 retcode=-1)) | 111 retcode=-1)) |
OLD | NEW |