Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: test/analyzer/gyptest-analyzer-deprecated.py

Issue 1431343002: Changes semantics of analyzer (Closed) Base URL: https://chromium.googlesource.com/external/gyp@master
Patch Set: compile_targets -> additional_compile_targets Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 # Verifies config_path must be specified. 157 # Verifies config_path must be specified.
158 test.run_gyp('test.gyp') 158 test.run_gyp('test.gyp')
159 EnsureStdoutContains('Must specify files to analyze via config_path') 159 EnsureStdoutContains('Must specify files to analyze via config_path')
160 160
161 # Verifies config_path must point to a valid file. 161 # Verifies config_path must point to a valid file.
162 test.run_gyp('test.gyp', '-Gconfig_path=bogus_file', 162 test.run_gyp('test.gyp', '-Gconfig_path=bogus_file',
163 '-Ganalyzer_output_path=analyzer_output') 163 '-Ganalyzer_output_path=analyzer_output')
164 EnsureError('Unable to open file bogus_file') 164 EnsureError('Unable to open file bogus_file')
165 165
166 # Verify 'invalid_targets' is present when bad target is specified. 166 # Verify 'invalid_targets' is present when bad target is specified.
167 _CreateConfigFile(['exe2.c'], ['bad_target', 'all', 'exe2']) 167 _CreateConfigFile(['exe2.c'], ['bad_target', 'allx', 'exe2'])
Dirk Pranke 2015/11/12 00:37:20 why does this change to 'allx' ?
sky 2015/11/12 00:47:23 You found out in test/analyzer/test.gyp . I rename
168 run_analyzer() 168 run_analyzer()
169 EnsureInvalidTargets({'bad_target'}) 169 EnsureInvalidTargets({'bad_target'})
170 170
171 # Verifies config_path must point to a valid json file. 171 # Verifies config_path must point to a valid json file.
172 _CreateBogusConfigFile() 172 _CreateBogusConfigFile()
173 run_analyzer() 173 run_analyzer()
174 EnsureError('Unable to parse config file test_file') 174 EnsureError('Unable to parse config file test_file')
175 175
176 # Trivial test of a source. 176 # Trivial test of a source.
177 _CreateConfigFile(['foo.c'], ['all', 'exe2']) 177 _CreateConfigFile(['foo.c'], ['allx', 'exe2'])
178 run_analyzer() 178 run_analyzer()
179 EnsureContains(matched=True, build_targets={'exe'}) 179 EnsureContains(matched=True, build_targets={'exe'})
180 180
181 # Conditional source that is excluded. 181 # Conditional source that is excluded.
182 _CreateConfigFile(['conditional_source.c'], ['all', 'exe2']) 182 _CreateConfigFile(['conditional_source.c'], ['allx', 'exe2'])
183 run_analyzer() 183 run_analyzer()
184 EnsureContains(matched=False) 184 EnsureContains(matched=False)
185 185
186 # Conditional source that is included by way of argument. 186 # Conditional source that is included by way of argument.
187 _CreateConfigFile(['conditional_source.c'], ['all', 'exe2']) 187 _CreateConfigFile(['conditional_source.c'], ['allx', 'exe2'])
188 run_analyzer('-Dtest_variable=1') 188 run_analyzer('-Dtest_variable=1')
189 EnsureContains(matched=True, build_targets={'exe'}) 189 EnsureContains(matched=True, build_targets={'exe'})
190 190
191 # Two unknown files. 191 # Two unknown files.
192 _CreateConfigFile(['unknown1.c', 'unoknow2.cc'], ['all', 'exe2']) 192 _CreateConfigFile(['unknown1.c', 'unoknow2.cc'], ['allx', 'exe2'])
193 run_analyzer() 193 run_analyzer()
194 EnsureContains() 194 EnsureContains()
195 195
196 # Two unknown files. 196 # Two unknown files.
197 _CreateConfigFile(['unknown1.c', 'subdir/subdir_sourcex.c'], ['all', 'exe2']) 197 _CreateConfigFile(['unknown1.c', 'subdir/subdir_sourcex.c'], ['allx', 'exe2'])
198 run_analyzer() 198 run_analyzer()
199 EnsureContains() 199 EnsureContains()
200 200
201 # Included dependency 201 # Included dependency
202 _CreateConfigFile(['unknown1.c', 'subdir/subdir_source.c'], ['all', 'exe2']) 202 _CreateConfigFile(['unknown1.c', 'subdir/subdir_source.c'], ['allx', 'exe2'])
203 run_analyzer() 203 run_analyzer()
204 EnsureContains(matched=True, build_targets={'exe', 'exe3'}) 204 EnsureContains(matched=True, build_targets={'exe', 'exe3'})
205 205
206 # Included inputs to actions. 206 # Included inputs to actions.
207 _CreateConfigFile(['action_input.c'], ['all', 'exe2']) 207 _CreateConfigFile(['action_input.c'], ['allx', 'exe2'])
208 run_analyzer() 208 run_analyzer()
209 EnsureContains(matched=True, build_targets={'exe'}) 209 EnsureContains(matched=True, build_targets={'exe'})
210 210
211 # Don't consider outputs. 211 # Don't consider outputs.
212 _CreateConfigFile(['action_output.c'], ['all', 'exe2']) 212 _CreateConfigFile(['action_output.c'], ['allx', 'exe2'])
213 run_analyzer() 213 run_analyzer()
214 EnsureContains(matched=False) 214 EnsureContains(matched=False)
215 215
216 # Rule inputs. 216 # Rule inputs.
217 _CreateConfigFile(['rule_input.c'], ['all', 'exe2']) 217 _CreateConfigFile(['rule_input.c'], ['allx', 'exe2'])
218 run_analyzer() 218 run_analyzer()
219 EnsureContains(matched=True, build_targets={'exe'}) 219 EnsureContains(matched=True, build_targets={'exe'})
220 220
221 # Ignore path specified with PRODUCT_DIR. 221 # Ignore path specified with PRODUCT_DIR.
222 _CreateConfigFile(['product_dir_input.c'], ['all', 'exe2']) 222 _CreateConfigFile(['product_dir_input.c'], ['allx', 'exe2'])
223 run_analyzer() 223 run_analyzer()
224 EnsureContains(matched=False) 224 EnsureContains(matched=False)
225 225
226 # Path specified via a variable. 226 # Path specified via a variable.
227 _CreateConfigFile(['subdir/subdir_source2.c'], ['all', 'exe2']) 227 _CreateConfigFile(['subdir/subdir_source2.c'], ['allx', 'exe2'])
228 run_analyzer() 228 run_analyzer()
229 EnsureContains(matched=True, build_targets={'exe'}) 229 EnsureContains(matched=True, build_targets={'exe'})
230 230
231 # Verifies paths with // are fixed up correctly. 231 # Verifies paths with // are fixed up correctly.
232 _CreateConfigFile(['parent_source.c'], ['all', 'exe2']) 232 _CreateConfigFile(['parent_source.c'], ['allx', 'exe2'])
233 run_analyzer() 233 run_analyzer()
234 EnsureContains(matched=True, build_targets={'exe', 'exe3'}) 234 EnsureContains(matched=True, build_targets={'exe', 'exe3'})
235 235
236 # Verifies relative paths are resolved correctly. 236 # Verifies relative paths are resolved correctly.
237 _CreateConfigFile(['subdir/subdir_source.h'], ['all', 'exe2']) 237 _CreateConfigFile(['subdir/subdir_source.h'], ['allx', 'exe2'])
238 run_analyzer() 238 run_analyzer()
239 EnsureContains(matched=True, build_targets={'exe'}) 239 EnsureContains(matched=True, build_targets={'exe'})
240 240
241 # Verifies relative paths in inputs are resolved correctly. 241 # Verifies relative paths in inputs are resolved correctly.
242 _CreateConfigFile(['rel_path1.h'], ['all', 'exe2']) 242 _CreateConfigFile(['rel_path1.h'], ['allx', 'exe2'])
243 run_analyzer() 243 run_analyzer()
244 EnsureContains(matched=True, build_targets={'exe'}) 244 EnsureContains(matched=True, build_targets={'exe'})
245 245
246 # Various permutations when passing in targets. 246 # Various permutations when passing in targets.
247 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], 247 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'],
248 ['exe', 'exe3', 'all', 'exe2']) 248 ['exe', 'exe3', 'allx', 'exe2'])
249 run_analyzer() 249 run_analyzer()
250 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) 250 EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
251 251
252 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], 252 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'],
253 ['exe', 'all', 'exe2']) 253 ['exe', 'allx', 'exe2'])
254 run_analyzer() 254 run_analyzer()
255 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) 255 EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
256 256
257 # Verifies duplicates are ignored. 257 # Verifies duplicates are ignored.
258 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], 258 _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'],
259 ['exe', 'exe', 'all', 'exe2']) 259 ['exe', 'exe', 'allx', 'exe2'])
260 run_analyzer() 260 run_analyzer()
261 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) 261 EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
262 262
263 _CreateConfigFile(['exe2.c'], ['exe', 'all', 'exe2']) 263 _CreateConfigFile(['exe2.c'], ['exe', 'allx', 'exe2'])
264 run_analyzer() 264 run_analyzer()
265 EnsureContains(matched=True, build_targets={'exe2'}) 265 EnsureContains(matched=True, build_targets={'exe2'})
266 266
267 _CreateConfigFile(['exe2.c'], ['all', 'exe2']) 267 _CreateConfigFile(['exe2.c'], ['allx', 'exe2'])
268 run_analyzer() 268 run_analyzer()
269 EnsureContains(matched=True, build_targets={'exe2'}) 269 EnsureContains(matched=True, build_targets={'exe2'})
270 270
271 _CreateConfigFile(['subdir/subdir2b_source.c', 'exe2.c'], ['all', 'exe2']) 271 _CreateConfigFile(['subdir/subdir2b_source.c', 'exe2.c'], ['allx', 'exe2'])
272 run_analyzer() 272 run_analyzer()
273 EnsureContains(matched=True, build_targets={'exe2', 'exe3'}) 273 EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
274 274
275 _CreateConfigFile(['subdir/subdir2b_source.c'], ['exe3', 'all', 'exe2']) 275 _CreateConfigFile(['subdir/subdir2b_source.c'], ['exe3', 'allx', 'exe2'])
276 run_analyzer() 276 run_analyzer()
277 EnsureContains(matched=True, build_targets={'exe3'}) 277 EnsureContains(matched=True, build_targets={'exe3'})
278 278
279 _CreateConfigFile(['foo.c'], ['all', 'exe2']) 279 _CreateConfigFile(['foo.c'], ['allx', 'exe2'])
280 run_analyzer() 280 run_analyzer()
281 EnsureContains(matched=True, build_targets={'exe'}) 281 EnsureContains(matched=True, build_targets={'exe'})
282 282
283 # Assertions when modifying build (gyp/gypi) files, especially when said files 283 # Assertions when modifying build (gyp/gypi) files, especially when said files
284 # are included. 284 # are included.
285 _CreateConfigFile(['subdir2/d.cc'], ['exe', 'exe2', 'foo', 'exe3']) 285 _CreateConfigFile(['subdir2/d.cc'], ['exe', 'exe2', 'foo', 'exe3'])
286 run_analyzer2() 286 run_analyzer2()
287 EnsureContains(matched=True, build_targets={'exe'}) 287 EnsureContains(matched=True, build_targets={'exe'})
288 288
289 _CreateConfigFile(['subdir2/subdir.includes.gypi'], 289 _CreateConfigFile(['subdir2/subdir.includes.gypi'],
290 ['exe', 'exe2', 'foo', 'exe3']) 290 ['exe', 'exe2', 'foo', 'exe3'])
291 run_analyzer2() 291 run_analyzer2()
292 EnsureContains(matched=True, build_targets={'exe'}) 292 EnsureContains(matched=True, build_targets={'exe'})
293 293
294 _CreateConfigFile(['subdir2/subdir.gyp'], ['exe', 'exe2', 'foo', 'exe3']) 294 _CreateConfigFile(['subdir2/subdir.gyp'], ['exe', 'exe2', 'foo', 'exe3'])
295 run_analyzer2() 295 run_analyzer2()
296 EnsureContains(matched=True, build_targets={'exe'}) 296 EnsureContains(matched=True, build_targets={'exe'})
297 297
298 _CreateConfigFile(['test2.includes.gypi'], ['exe', 'exe2', 'foo', 'exe3']) 298 _CreateConfigFile(['test2.includes.gypi'], ['exe', 'exe2', 'foo', 'exe3'])
299 run_analyzer2() 299 run_analyzer2()
300 EnsureContains(matched=True, build_targets={'exe', 'exe2', 'exe3'}) 300 EnsureContains(matched=True, build_targets={'exe', 'exe2', 'exe3'})
301 301
302 # Verify modifying a file included makes all targets dirty. 302 # Verify modifying a file included makes all targets dirty.
303 _CreateConfigFile(['common.gypi'], ['exe', 'exe2', 'foo', 'exe3']) 303 _CreateConfigFile(['common.gypi'], ['exe', 'exe2', 'foo', 'exe3'])
304 run_analyzer2('-Icommon.gypi') 304 run_analyzer2('-Icommon.gypi')
305 EnsureMatchedAll({'exe', 'exe2', 'foo', 'exe3'}) 305 EnsureMatchedAll({'exe', 'exe2', 'foo', 'exe3'})
306 306
307 # Assertions from test3.gyp. 307 # Assertions from test3.gyp.
308 _CreateConfigFile(['d.c', 'f.c'], ['a', 'all']) 308 _CreateConfigFile(['d.c', 'f.c'], ['a', 'allx'])
309 run_analyzer3() 309 run_analyzer3()
310 EnsureContains(matched=True, build_targets={'a', 'b'}) 310 EnsureContains(matched=True, build_targets={'a', 'b'})
311 311
312 _CreateConfigFile(['f.c'], ['a', 'all']) 312 _CreateConfigFile(['f.c'], ['a', 'allx'])
313 run_analyzer3() 313 run_analyzer3()
314 EnsureContains(matched=True, build_targets={'a', 'b'}) 314 EnsureContains(matched=True, build_targets={'a', 'b'})
315 315
316 _CreateConfigFile(['f.c'], ['all']) 316 _CreateConfigFile(['f.c'], ['allx'])
317 run_analyzer3() 317 run_analyzer3()
318 EnsureContains(matched=True, build_targets={'a', 'b'}) 318 EnsureContains(matched=True, build_targets={'a', 'b'})
319 319
320 _CreateConfigFile(['c.c', 'e.c'], ['all']) 320 _CreateConfigFile(['c.c', 'e.c'], ['allx'])
321 run_analyzer3() 321 run_analyzer3()
322 EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'e'}) 322 EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'e'})
323 323
324 _CreateConfigFile(['d.c'], ['a', 'all']) 324 _CreateConfigFile(['d.c'], ['a', 'allx'])
325 run_analyzer3() 325 run_analyzer3()
326 EnsureContains(matched=True, build_targets={'a', 'b'}) 326 EnsureContains(matched=True, build_targets={'a', 'b'})
327 327
328 _CreateConfigFile(['a.c'], ['a', 'b', 'all']) 328 _CreateConfigFile(['a.c'], ['a', 'b', 'allx'])
329 run_analyzer3() 329 run_analyzer3()
330 EnsureContains(matched=True, build_targets={'a'}) 330 EnsureContains(matched=True, build_targets={'a'})
331 331
332 _CreateConfigFile(['a.c'], ['a', 'b', 'all']) 332 _CreateConfigFile(['a.c'], ['a', 'b', 'allx'])
333 run_analyzer3() 333 run_analyzer3()
334 EnsureContains(matched=True, build_targets={'a'}) 334 EnsureContains(matched=True, build_targets={'a'})
335 335
336 _CreateConfigFile(['d.c'], ['a', 'b', 'all']) 336 _CreateConfigFile(['d.c'], ['a', 'b', 'allx'])
337 run_analyzer3() 337 run_analyzer3()
338 EnsureContains(matched=True, build_targets={'a', 'b'}) 338 EnsureContains(matched=True, build_targets={'a', 'b'})
339 339
340 _CreateConfigFile(['f.c'], ['a', 'all']) 340 _CreateConfigFile(['f.c'], ['a', 'allx'])
341 run_analyzer3() 341 run_analyzer3()
342 EnsureContains(matched=True, build_targets={'a', 'b'}) 342 EnsureContains(matched=True, build_targets={'a', 'b'})
343 343
344 _CreateConfigFile(['a.c'], ['a', 'all']) 344 _CreateConfigFile(['a.c'], ['a', 'allx'])
345 run_analyzer3() 345 run_analyzer3()
346 EnsureContains(matched=True, build_targets={'a'}) 346 EnsureContains(matched=True, build_targets={'a'})
347 347
348 _CreateConfigFile(['a.c'], ['all']) 348 _CreateConfigFile(['a.c'], ['allx'])
349 run_analyzer3() 349 run_analyzer3()
350 EnsureContains(matched=True, build_targets={'a'}) 350 EnsureContains(matched=True, build_targets={'a'})
351 351
352 _CreateConfigFile(['d.c'], ['all']) 352 _CreateConfigFile(['d.c'], ['allx'])
353 run_analyzer3() 353 run_analyzer3()
354 EnsureContains(matched=True, build_targets={'a', 'b'}) 354 EnsureContains(matched=True, build_targets={'a', 'b'})
355 355
356 # Assertions around test4.gyp. 356 # Assertions around test4.gyp.
357 _CreateConfigFile(['f.c'], ['a', 'e', 'h']) 357 _CreateConfigFile(['f.c'], ['a', 'e', 'h'])
358 run_analyzer4() 358 run_analyzer4()
359 EnsureContains(matched=True, build_targets={'e', 'f'}) 359 EnsureContains(matched=True, build_targets={'e', 'f'})
360 360
361 _CreateConfigFile(['d.c'], ['a', 'e', 'h']) 361 _CreateConfigFile(['d.c'], ['a', 'e', 'h'])
362 run_analyzer4() 362 run_analyzer4()
363 EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'd'}) 363 EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'd'})
364 364
365 _CreateConfigFile(['i.c'], ['a', 'e', 'h']) 365 _CreateConfigFile(['i.c'], ['a', 'e', 'h'])
366 run_analyzer4() 366 run_analyzer4()
367 EnsureContains(matched=True, build_targets={'h', 'i'}) 367 EnsureContains(matched=True, build_targets={'h', 'i'})
368 368
369 test.pass_test() 369 test.pass_test()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698