OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2014 Google Inc. All rights reserved. | 2 # Copyright (c) 2014 Google Inc. 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 """Tests for analyzer | 6 """Tests for analyzer |
7 """ | 7 """ |
8 | 8 |
9 import json | 9 import json |
10 import TestGyp | 10 import TestGyp |
11 | 11 |
12 found = 'Found dependency' | 12 found = 'Found dependency' |
13 found_all = 'Found dependency (all)' | 13 found_all = 'Found dependency (all)' |
14 not_found = 'No dependencies' | 14 not_found = 'No dependencies' |
15 | 15 |
16 | 16 |
17 def _CreateConfigFile(files, targets): | 17 def _CreateConfigFile(files, compile_targets, test_targets=[]): |
Dirk Pranke
2015/11/12 00:37:20
nit: call the arg 'additional_compile_targets' ?
sky
2015/11/12 00:47:23
Done.
| |
18 """Creates the analyzer config file, which is used as the input to analyzer. | 18 """Creates the analyzer config file, which is used as the input to analyzer. |
19 See description of analyzer.py for description of the arguments.""" | 19 See description of analyzer.py for description of the arguments.""" |
20 f = open('test_file', 'w') | 20 f = open('test_file', 'w') |
21 to_write = {'files': files, 'targets': targets } | 21 to_write = {'files': files, |
22 'test_targets': test_targets, | |
23 'additional_compile_targets': compile_targets } | |
22 json.dump(to_write, f) | 24 json.dump(to_write, f) |
23 f.close() | 25 f.close() |
24 | 26 |
25 | 27 |
26 def _CreateBogusConfigFile(): | 28 def _CreateBogusConfigFile(): |
27 f = open('test_file','w') | 29 f = open('test_file','w') |
28 f.write('bogus') | 30 f.write('bogus') |
29 f.close() | 31 f.close() |
30 | 32 |
31 | 33 |
(...skipping 30 matching lines...) Expand all Loading... | |
62 args += CommonArgs() | 64 args += CommonArgs() |
63 test.run_gyp('test3.gyp', *args, **kw) | 65 test.run_gyp('test3.gyp', *args, **kw) |
64 | 66 |
65 | 67 |
66 def run_analyzer4(*args, **kw): | 68 def run_analyzer4(*args, **kw): |
67 """Same as run_analyzer(), but passes in test3.gyp instead of test.gyp.""" | 69 """Same as run_analyzer(), but passes in test3.gyp instead of test.gyp.""" |
68 args += CommonArgs() | 70 args += CommonArgs() |
69 test.run_gyp('test4.gyp', *args, **kw) | 71 test.run_gyp('test4.gyp', *args, **kw) |
70 | 72 |
71 | 73 |
72 def EnsureContains(matched=False, build_targets=set()): | 74 def EnsureContains(matched=False, compile_targets=set(), test_targets=set()): |
73 """Verifies output contains |build_targets|.""" | 75 """Verifies output contains |compile_targets|.""" |
74 result = _ReadOutputFileContents() | 76 result = _ReadOutputFileContents() |
75 if result.get('error', None): | 77 if result.get('error', None): |
76 print 'unexpected error', result.get('error') | 78 print 'unexpected error', result.get('error') |
77 test.fail_test() | 79 test.fail_test() |
78 | 80 |
79 if result.get('invalid_targets', None): | 81 if result.get('invalid_targets', None): |
80 print 'unexpected invalid_targets', result.get('invalid_targets') | 82 print 'unexpected invalid_targets', result.get('invalid_targets') |
81 test.fail_test() | 83 test.fail_test() |
82 | 84 |
83 # TODO(sky): nuke when get rid of targets. | 85 actual_compile_targets = set(result['compile_targets']) |
84 targets = build_targets | 86 if actual_compile_targets != compile_targets: |
85 actual_targets = set(result['targets']) | 87 print 'actual compile_targets:', actual_compile_targets, \ |
86 if actual_targets != targets: | 88 '\nexpected compile_targets:', compile_targets |
87 print 'actual targets:', actual_targets, '\nexpected targets:', targets | |
88 test.fail_test() | 89 test.fail_test() |
89 | 90 |
90 actual_build_targets = set(result['build_targets']) | 91 actual_test_targets = set(result['test_targets']) |
91 if actual_build_targets != build_targets: | 92 if actual_test_targets != test_targets: |
92 print 'actual build_targets:', actual_build_targets, \ | 93 print 'actual test_targets:', actual_test_targets, \ |
93 '\nexpected build_targets:', build_targets | 94 '\nexpected test_targets:', test_targets |
94 test.fail_test() | 95 test.fail_test() |
95 | 96 |
96 if matched and result['status'] != found: | 97 if matched and result['status'] != found: |
97 print 'expected', found, 'got', result['status'] | 98 print 'expected', found, 'got', result['status'] |
98 test.fail_test() | 99 test.fail_test() |
99 elif not matched and result['status'] != not_found: | 100 elif not matched and result['status'] != not_found: |
100 print 'expected', not_found, 'got', result['status'] | 101 print 'expected', not_found, 'got', result['status'] |
101 test.fail_test() | 102 test.fail_test() |
102 | 103 |
103 | 104 |
104 def EnsureMatchedAll(targets): | 105 def EnsureMatchedAll(compile_targets, test_targets=set()): |
105 result = _ReadOutputFileContents() | 106 result = _ReadOutputFileContents() |
106 if result.get('error', None): | 107 if result.get('error', None): |
107 print 'unexpected error', result.get('error') | 108 print 'unexpected error', result.get('error') |
108 test.fail_test() | 109 test.fail_test() |
109 | 110 |
110 if result.get('invalid_targets', None): | 111 if result.get('invalid_targets', None): |
111 print 'unexpected invalid_targets', result.get('invalid_targets') | 112 print 'unexpected invalid_targets', result.get('invalid_targets') |
112 test.fail_test() | 113 test.fail_test() |
113 | 114 |
114 if result['status'] != found_all: | 115 if result['status'] != found_all: |
115 print 'expected', found_all, 'got', result['status'] | 116 print 'expected', found_all, 'got', result['status'] |
116 test.fail_test() | 117 test.fail_test() |
117 | 118 |
118 actual_targets = set(result['targets']) | 119 actual_compile_targets = set(result['compile_targets']) |
119 if actual_targets != targets: | 120 if actual_compile_targets != compile_targets: |
120 print 'actual targets:', actual_targets, '\nexpected targets:', targets | 121 print ('actual compile_targets:', actual_compile_targets, |
122 '\nexpected compile_targets:', compile_targets) | |
123 test.fail_test() | |
124 | |
125 actual_test_targets = set(result['test_targets']) | |
126 if actual_test_targets != test_targets: | |
127 print ('actual test_targets:', actual_test_targets, | |
128 '\nexpected test_targets:', test_targets) | |
121 test.fail_test() | 129 test.fail_test() |
122 | 130 |
123 | 131 |
124 def EnsureError(expected_error_string): | 132 def EnsureError(expected_error_string): |
125 """Verifies output contains the error string.""" | 133 """Verifies output contains the error string.""" |
126 result = _ReadOutputFileContents() | 134 result = _ReadOutputFileContents() |
127 if result.get('error', '').find(expected_error_string) == -1: | 135 if result.get('error', '').find(expected_error_string) == -1: |
128 print 'actual error:', result.get('error', ''), '\nexpected error:', \ | 136 print 'actual error:', result.get('error', ''), '\nexpected error:', \ |
129 expected_error_string | 137 expected_error_string |
130 test.fail_test() | 138 test.fail_test() |
(...skipping 12 matching lines...) Expand all Loading... | |
143 actual_invalid_targets = set(result['invalid_targets']) | 151 actual_invalid_targets = set(result['invalid_targets']) |
144 if actual_invalid_targets != expected_invalid_targets: | 152 if actual_invalid_targets != expected_invalid_targets: |
145 print 'actual invalid_targets:', actual_invalid_targets, \ | 153 print 'actual invalid_targets:', actual_invalid_targets, \ |
146 '\nexpected :', expected_invalid_targets | 154 '\nexpected :', expected_invalid_targets |
147 test.fail_test() | 155 test.fail_test() |
148 | 156 |
149 | 157 |
150 # Two targets, A and B (both static_libraries) and A depends upon B. If a file | 158 # Two targets, A and B (both static_libraries) and A depends upon B. If a file |
151 # in B changes, then both A and B are output. It is not strictly necessary that | 159 # in B changes, then both A and B are output. It is not strictly necessary that |
152 # A is compiled in this case, only B. | 160 # A is compiled in this case, only B. |
153 _CreateConfigFile(['b.c'], ['a']) | 161 _CreateConfigFile(['b.c'], ['all']) |
154 test.run_gyp('static_library_test.gyp', *CommonArgs()) | 162 test.run_gyp('static_library_test.gyp', *CommonArgs()) |
155 EnsureContains(matched=True, build_targets={'a' ,'b'}) | 163 EnsureContains(matched=True, compile_targets={'a' ,'b'}) |
156 | 164 |
157 # Verifies config_path must be specified. | 165 # Verifies config_path must be specified. |
158 test.run_gyp('test.gyp') | 166 test.run_gyp('test.gyp') |
159 EnsureStdoutContains('Must specify files to analyze via config_path') | 167 EnsureStdoutContains('Must specify files to analyze via config_path') |
160 | 168 |
161 # Verifies config_path must point to a valid file. | 169 # Verifies config_path must point to a valid file. |
162 test.run_gyp('test.gyp', '-Gconfig_path=bogus_file', | 170 test.run_gyp('test.gyp', '-Gconfig_path=bogus_file', |
163 '-Ganalyzer_output_path=analyzer_output') | 171 '-Ganalyzer_output_path=analyzer_output') |
164 EnsureError('Unable to open file bogus_file') | 172 EnsureError('Unable to open file bogus_file') |
165 | 173 |
166 # Verify 'invalid_targets' is present when bad target is specified. | 174 # Verify 'invalid_targets' is present when bad target is specified. |
167 _CreateConfigFile(['exe2.c'], ['bad_target', 'all', 'exe2']) | 175 _CreateConfigFile(['exe2.c'], ['bad_target']) |
168 run_analyzer() | 176 run_analyzer() |
169 EnsureInvalidTargets({'bad_target'}) | 177 EnsureInvalidTargets({'bad_target'}) |
170 | 178 |
171 # Verifies config_path must point to a valid json file. | 179 # Verifies config_path must point to a valid json file. |
172 _CreateBogusConfigFile() | 180 _CreateBogusConfigFile() |
173 run_analyzer() | 181 run_analyzer() |
174 EnsureError('Unable to parse config file test_file') | 182 EnsureError('Unable to parse config file test_file') |
175 | 183 |
176 # Trivial test of a source. | 184 # Trivial test of a source. |
177 _CreateConfigFile(['foo.c'], ['all', 'exe2']) | 185 _CreateConfigFile(['foo.c'], ['all']) |
178 run_analyzer() | 186 run_analyzer() |
179 EnsureContains(matched=True, build_targets={'exe'}) | 187 EnsureContains(matched=True, compile_targets={'exe'}) |
180 | 188 |
181 # Conditional source that is excluded. | 189 # Conditional source that is excluded. |
182 _CreateConfigFile(['conditional_source.c'], ['all', 'exe2']) | 190 _CreateConfigFile(['conditional_source.c'], ['all']) |
183 run_analyzer() | 191 run_analyzer() |
184 EnsureContains(matched=False) | 192 EnsureContains(matched=False) |
185 | 193 |
186 # Conditional source that is included by way of argument. | 194 # Conditional source that is included by way of argument. |
187 _CreateConfigFile(['conditional_source.c'], ['all', 'exe2']) | 195 _CreateConfigFile(['conditional_source.c'], ['all']) |
188 run_analyzer('-Dtest_variable=1') | 196 run_analyzer('-Dtest_variable=1') |
189 EnsureContains(matched=True, build_targets={'exe'}) | 197 EnsureContains(matched=True, compile_targets={'exe'}) |
190 | 198 |
191 # Two unknown files. | 199 # Two unknown files. |
192 _CreateConfigFile(['unknown1.c', 'unoknow2.cc'], ['all', 'exe2']) | 200 _CreateConfigFile(['unknown1.c', 'unoknow2.cc'], ['all']) |
193 run_analyzer() | 201 run_analyzer() |
194 EnsureContains() | 202 EnsureContains() |
195 | 203 |
196 # Two unknown files. | 204 # Two unknown files. |
197 _CreateConfigFile(['unknown1.c', 'subdir/subdir_sourcex.c'], ['all', 'exe2']) | 205 _CreateConfigFile(['unknown1.c', 'subdir/subdir_sourcex.c'], ['all']) |
198 run_analyzer() | 206 run_analyzer() |
199 EnsureContains() | 207 EnsureContains() |
200 | 208 |
201 # Included dependency | 209 # Included dependency |
202 _CreateConfigFile(['unknown1.c', 'subdir/subdir_source.c'], ['all', 'exe2']) | 210 _CreateConfigFile(['unknown1.c', 'subdir/subdir_source.c'], ['all']) |
203 run_analyzer() | 211 run_analyzer() |
204 EnsureContains(matched=True, build_targets={'exe', 'exe3'}) | 212 EnsureContains(matched=True, compile_targets={'exe', 'exe3'}) |
205 | 213 |
206 # Included inputs to actions. | 214 # Included inputs to actions. |
207 _CreateConfigFile(['action_input.c'], ['all', 'exe2']) | 215 _CreateConfigFile(['action_input.c'], ['all']) |
208 run_analyzer() | 216 run_analyzer() |
209 EnsureContains(matched=True, build_targets={'exe'}) | 217 EnsureContains(matched=True, compile_targets={'exe'}) |
210 | 218 |
211 # Don't consider outputs. | 219 # Don't consider outputs. |
212 _CreateConfigFile(['action_output.c'], ['all', 'exe2']) | 220 _CreateConfigFile(['action_output.c'], ['all']) |
213 run_analyzer() | 221 run_analyzer() |
214 EnsureContains(matched=False) | 222 EnsureContains(matched=False) |
215 | 223 |
216 # Rule inputs. | 224 # Rule inputs. |
217 _CreateConfigFile(['rule_input.c'], ['all', 'exe2']) | 225 _CreateConfigFile(['rule_input.c'], ['all']) |
218 run_analyzer() | 226 run_analyzer() |
219 EnsureContains(matched=True, build_targets={'exe'}) | 227 EnsureContains(matched=True, compile_targets={'exe'}) |
220 | 228 |
221 # Ignore path specified with PRODUCT_DIR. | 229 # Ignore path specified with PRODUCT_DIR. |
222 _CreateConfigFile(['product_dir_input.c'], ['all', 'exe2']) | 230 _CreateConfigFile(['product_dir_input.c'], ['all']) |
223 run_analyzer() | 231 run_analyzer() |
224 EnsureContains(matched=False) | 232 EnsureContains(matched=False) |
225 | 233 |
226 # Path specified via a variable. | 234 # Path specified via a variable. |
227 _CreateConfigFile(['subdir/subdir_source2.c'], ['all', 'exe2']) | 235 _CreateConfigFile(['subdir/subdir_source2.c'], ['all']) |
228 run_analyzer() | 236 run_analyzer() |
229 EnsureContains(matched=True, build_targets={'exe'}) | 237 EnsureContains(matched=True, compile_targets={'exe'}) |
230 | 238 |
231 # Verifies paths with // are fixed up correctly. | 239 # Verifies paths with // are fixed up correctly. |
232 _CreateConfigFile(['parent_source.c'], ['all', 'exe2']) | 240 _CreateConfigFile(['parent_source.c'], ['all']) |
233 run_analyzer() | 241 run_analyzer() |
234 EnsureContains(matched=True, build_targets={'exe', 'exe3'}) | 242 EnsureContains(matched=True, compile_targets={'exe', 'exe3'}) |
235 | 243 |
236 # Verifies relative paths are resolved correctly. | 244 # Verifies relative paths are resolved correctly. |
237 _CreateConfigFile(['subdir/subdir_source.h'], ['all', 'exe2']) | 245 _CreateConfigFile(['subdir/subdir_source.h'], ['all']) |
238 run_analyzer() | 246 run_analyzer() |
239 EnsureContains(matched=True, build_targets={'exe'}) | 247 EnsureContains(matched=True, compile_targets={'exe'}) |
240 | 248 |
241 # Verifies relative paths in inputs are resolved correctly. | 249 # Verifies relative paths in inputs are resolved correctly. |
242 _CreateConfigFile(['rel_path1.h'], ['all', 'exe2']) | 250 _CreateConfigFile(['rel_path1.h'], ['all']) |
243 run_analyzer() | 251 run_analyzer() |
244 EnsureContains(matched=True, build_targets={'exe'}) | 252 EnsureContains(matched=True, compile_targets={'exe'}) |
245 | 253 |
246 # Various permutations when passing in targets. | 254 # Various permutations when passing in targets. |
247 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], | 255 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], |
248 ['exe', 'exe3', 'all', 'exe2']) | 256 ['all'], ['exe', 'exe3']) |
249 run_analyzer() | 257 run_analyzer() |
250 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) | 258 EnsureContains(matched=True, test_targets={'exe3'}, |
251 | 259 compile_targets={'exe2', 'exe3'}) |
252 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], | 260 |
253 ['exe', 'all', 'exe2']) | 261 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], ['all'], ['exe']) |
254 run_analyzer() | 262 run_analyzer() |
255 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) | 263 EnsureContains(matched=True, compile_targets={'exe2', 'exe3'}) |
256 | 264 |
257 # Verifies duplicates are ignored. | 265 # Verifies duplicates are ignored. |
258 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], | 266 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], ['all'], |
259 ['exe', 'exe', 'all', 'exe2']) | 267 ['exe', 'exe']) |
260 run_analyzer() | 268 run_analyzer() |
261 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) | 269 EnsureContains(matched=True, compile_targets={'exe2', 'exe3'}) |
262 | 270 |
263 _CreateConfigFile(['exe2.c'], ['exe', 'all', 'exe2']) | 271 _CreateConfigFile(['exe2.c'], ['all'], ['exe']) |
264 run_analyzer() | 272 run_analyzer() |
265 EnsureContains(matched=True, build_targets={'exe2'}) | 273 EnsureContains(matched=True, compile_targets={'exe2'}) |
266 | 274 |
267 _CreateConfigFile(['exe2.c'], ['all', 'exe2']) | 275 _CreateConfigFile(['exe2.c'], ['all']) |
268 run_analyzer() | 276 run_analyzer() |
269 EnsureContains(matched=True, build_targets={'exe2'}) | 277 EnsureContains(matched=True, compile_targets={'exe2'}) |
270 | 278 |
271 _CreateConfigFile(['subdir/subdir2b_source.c', 'exe2.c'], ['all', 'exe2']) | 279 _CreateConfigFile(['subdir/subdir2b_source.c', 'exe2.c'], ['all']) |
272 run_analyzer() | 280 run_analyzer() |
273 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) | 281 EnsureContains(matched=True, compile_targets={'exe2', 'exe3'}) |
274 | 282 |
275 _CreateConfigFile(['subdir/subdir2b_source.c'], ['exe3', 'all', 'exe2']) | 283 _CreateConfigFile(['subdir/subdir2b_source.c'], ['all'], ['exe3']) |
276 run_analyzer() | 284 run_analyzer() |
277 EnsureContains(matched=True, build_targets={'exe3'}) | 285 EnsureContains(matched=True, test_targets={'exe3'}, compile_targets={'exe3'}) |
278 | 286 |
279 _CreateConfigFile(['foo.c'], ['all', 'exe2']) | 287 _CreateConfigFile(['exe2.c'], ['all']) |
280 run_analyzer() | 288 run_analyzer() |
281 EnsureContains(matched=True, build_targets={'exe'}) | 289 EnsureContains(matched=True, compile_targets={'exe2'}) |
290 | |
291 _CreateConfigFile(['foo.c'], ['all']) | |
292 run_analyzer() | |
293 EnsureContains(matched=True, compile_targets={'exe'}) | |
282 | 294 |
283 # Assertions when modifying build (gyp/gypi) files, especially when said files | 295 # Assertions when modifying build (gyp/gypi) files, especially when said files |
284 # are included. | 296 # are included. |
285 _CreateConfigFile(['subdir2/d.cc'], ['exe', 'exe2', 'foo', 'exe3']) | 297 _CreateConfigFile(['subdir2/d.cc'], ['all'], ['exe', 'exe2', 'foo', 'exe3']) |
286 run_analyzer2() | 298 run_analyzer2() |
287 EnsureContains(matched=True, build_targets={'exe'}) | 299 EnsureContains(matched=True, test_targets={'exe', 'foo'}, |
288 | 300 compile_targets={'exe'}) |
289 _CreateConfigFile(['subdir2/subdir.includes.gypi'], | 301 |
302 _CreateConfigFile(['subdir2/subdir.includes.gypi'], ['all'], | |
290 ['exe', 'exe2', 'foo', 'exe3']) | 303 ['exe', 'exe2', 'foo', 'exe3']) |
291 run_analyzer2() | 304 run_analyzer2() |
292 EnsureContains(matched=True, build_targets={'exe'}) | 305 EnsureContains(matched=True, test_targets={'exe', 'foo'}, |
293 | 306 compile_targets={'exe'}) |
294 _CreateConfigFile(['subdir2/subdir.gyp'], ['exe', 'exe2', 'foo', 'exe3']) | 307 |
295 run_analyzer2() | 308 _CreateConfigFile(['subdir2/subdir.gyp'], ['all'], |
296 EnsureContains(matched=True, build_targets={'exe'}) | 309 ['exe', 'exe2', 'foo', 'exe3']) |
297 | 310 run_analyzer2() |
298 _CreateConfigFile(['test2.includes.gypi'], ['exe', 'exe2', 'foo', 'exe3']) | 311 EnsureContains(matched=True, test_targets={'exe', 'foo'}, |
299 run_analyzer2() | 312 compile_targets={'exe'}) |
300 EnsureContains(matched=True, build_targets={'exe', 'exe2', 'exe3'}) | 313 |
314 _CreateConfigFile(['test2.includes.gypi'], ['all'], | |
315 ['exe', 'exe2', 'foo', 'exe3']) | |
316 run_analyzer2() | |
317 EnsureContains(matched=True, test_targets={'exe', 'exe2', 'exe3'}, | |
318 compile_targets={'exe', 'exe2', 'exe3'}) | |
301 | 319 |
302 # Verify modifying a file included makes all targets dirty. | 320 # Verify modifying a file included makes all targets dirty. |
303 _CreateConfigFile(['common.gypi'], ['exe', 'exe2', 'foo', 'exe3']) | 321 _CreateConfigFile(['common.gypi'], ['all'], ['exe', 'exe2', 'foo', 'exe3']) |
304 run_analyzer2('-Icommon.gypi') | 322 run_analyzer2('-Icommon.gypi') |
305 EnsureMatchedAll({'exe', 'exe2', 'foo', 'exe3'}) | 323 EnsureMatchedAll({'all'}, {'exe', 'exe2', 'foo', 'exe3'}) |
306 | 324 |
307 # Assertions from test3.gyp. | 325 # Assertions from test3.gyp. |
308 _CreateConfigFile(['d.c', 'f.c'], ['a', 'all']) | 326 _CreateConfigFile(['d.c', 'f.c'], ['all'], ['a']) |
309 run_analyzer3() | 327 run_analyzer3() |
310 EnsureContains(matched=True, build_targets={'a', 'b'}) | 328 EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'}) |
311 | 329 |
312 _CreateConfigFile(['f.c'], ['a', 'all']) | 330 _CreateConfigFile(['f.c'], ['all'], ['a']) |
313 run_analyzer3() | 331 run_analyzer3() |
314 EnsureContains(matched=True, build_targets={'a', 'b'}) | 332 EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'}) |
315 | 333 |
316 _CreateConfigFile(['f.c'], ['all']) | 334 _CreateConfigFile(['f.c'], ['all']) |
317 run_analyzer3() | 335 run_analyzer3() |
318 EnsureContains(matched=True, build_targets={'a', 'b'}) | 336 EnsureContains(matched=True, compile_targets={'a', 'b'}) |
319 | 337 |
320 _CreateConfigFile(['c.c', 'e.c'], ['all']) | 338 _CreateConfigFile(['c.c', 'e.c'], ['all']) |
321 run_analyzer3() | 339 run_analyzer3() |
322 EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'e'}) | 340 EnsureContains(matched=True, compile_targets={'a', 'b', 'c', 'e'}) |
323 | 341 |
324 _CreateConfigFile(['d.c'], ['a', 'all']) | 342 _CreateConfigFile(['d.c'], ['all'], ['a']) |
325 run_analyzer3() | 343 run_analyzer3() |
326 EnsureContains(matched=True, build_targets={'a', 'b'}) | 344 EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'}) |
327 | 345 |
328 _CreateConfigFile(['a.c'], ['a', 'b', 'all']) | 346 _CreateConfigFile(['a.c'], ['all'], ['a', 'b']) |
329 run_analyzer3() | 347 run_analyzer3() |
330 EnsureContains(matched=True, build_targets={'a'}) | 348 EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a'}) |
331 | 349 |
332 _CreateConfigFile(['a.c'], ['a', 'b', 'all']) | 350 _CreateConfigFile(['a.c'], ['all'], ['a', 'b']) |
333 run_analyzer3() | 351 run_analyzer3() |
334 EnsureContains(matched=True, build_targets={'a'}) | 352 EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a'}) |
335 | 353 |
336 _CreateConfigFile(['d.c'], ['a', 'b', 'all']) | 354 _CreateConfigFile(['d.c'], ['all'], ['a', 'b']) |
337 run_analyzer3() | 355 run_analyzer3() |
338 EnsureContains(matched=True, build_targets={'a', 'b'}) | 356 EnsureContains(matched=True, test_targets={'a', 'b'}, |
339 | 357 compile_targets={'a', 'b'}) |
340 _CreateConfigFile(['f.c'], ['a', 'all']) | 358 |
341 run_analyzer3() | 359 _CreateConfigFile(['f.c'], ['all'], ['a']) |
342 EnsureContains(matched=True, build_targets={'a', 'b'}) | 360 run_analyzer3() |
343 | 361 EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'}) |
344 _CreateConfigFile(['a.c'], ['a', 'all']) | 362 |
345 run_analyzer3() | 363 _CreateConfigFile(['a.c'], ['all'], ['a']) |
346 EnsureContains(matched=True, build_targets={'a'}) | 364 run_analyzer3() |
365 EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a'}) | |
347 | 366 |
348 _CreateConfigFile(['a.c'], ['all']) | 367 _CreateConfigFile(['a.c'], ['all']) |
349 run_analyzer3() | 368 run_analyzer3() |
350 EnsureContains(matched=True, build_targets={'a'}) | 369 EnsureContains(matched=True, compile_targets={'a'}) |
351 | 370 |
352 _CreateConfigFile(['d.c'], ['all']) | 371 _CreateConfigFile(['d.c'], ['all']) |
353 run_analyzer3() | 372 run_analyzer3() |
354 EnsureContains(matched=True, build_targets={'a', 'b'}) | 373 EnsureContains(matched=True, compile_targets={'a', 'b'}) |
355 | 374 |
356 # Assertions around test4.gyp. | 375 # Assertions around test4.gyp. |
357 _CreateConfigFile(['f.c'], ['a', 'e', 'h']) | 376 _CreateConfigFile(['f.c'], ['all']) |
358 run_analyzer4() | 377 run_analyzer4() |
359 EnsureContains(matched=True, build_targets={'e', 'f'}) | 378 EnsureContains(matched=True, compile_targets={'e', 'f'}) |
360 | 379 |
361 _CreateConfigFile(['d.c'], ['a', 'e', 'h']) | 380 _CreateConfigFile(['d.c'], ['all']) |
362 run_analyzer4() | 381 run_analyzer4() |
363 EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'd'}) | 382 EnsureContains(matched=True, compile_targets={'a', 'b', 'c', 'd'}) |
364 | 383 |
365 _CreateConfigFile(['i.c'], ['a', 'e', 'h']) | 384 _CreateConfigFile(['i.c'], ['all']) |
366 run_analyzer4() | 385 run_analyzer4() |
367 EnsureContains(matched=True, build_targets={'h', 'i'}) | 386 EnsureContains(matched=True, compile_targets={'h', 'i'}) |
387 | |
388 # Assertions where 'all' is not supplied in compile_targets. | |
389 | |
390 _CreateConfigFile(['exe2.c'], [], ['exe2']) | |
391 run_analyzer() | |
392 EnsureContains(matched=True, test_targets={'exe2'}, compile_targets={'exe2'}) | |
393 | |
394 _CreateConfigFile(['exe20.c'], [], ['exe2']) | |
395 run_analyzer() | |
396 EnsureContains(matched=False) | |
397 | |
398 | |
399 _CreateConfigFile(['exe2.c', 'exe3.c'], [], ['exe2', 'exe3']) | |
400 run_analyzer() | |
401 EnsureContains(matched=True, test_targets={'exe2', 'exe3'}, | |
402 compile_targets={'exe2', 'exe3'}) | |
403 | |
404 _CreateConfigFile(['exe2.c', 'exe3.c'], ['exe3'], ['exe2']) | |
405 run_analyzer() | |
406 EnsureContains(matched=True, test_targets={'exe2'}, | |
407 compile_targets={'exe2', 'exe3'}) | |
408 | |
409 _CreateConfigFile(['exe3.c'], ['exe2'], ['exe2']) | |
410 run_analyzer() | |
411 EnsureContains(matched=False) | |
412 | |
413 # Assertions with 'all' listed as a test_target. | |
414 _CreateConfigFile(['exe3.c'], [], ['all']) | |
415 run_analyzer() | |
416 EnsureContains(matched=True, compile_targets={'exe3'}, test_targets={'all'}) | |
417 | |
418 _CreateConfigFile(['exe2.c'], [], ['all', 'exe2']) | |
419 run_analyzer() | |
420 EnsureContains(matched=True, compile_targets={'exe2'}, | |
421 test_targets={'all', 'exe2'}) | |
368 | 422 |
369 test.pass_test() | 423 test.pass_test() |
OLD | NEW |