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

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

Issue 442083004: Adds support for detecting modified gyp* files to analyzer (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 4 months 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 | Annotate | Revision Log
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 24 matching lines...) Expand all
35 # NOTE: this would be clearer if it subclassed TestGypCustom, but that trips 35 # NOTE: this would be clearer if it subclassed TestGypCustom, but that trips
36 # over a bug in pylint (E1002). 36 # over a bug in pylint (E1002).
37 test = TestGyp.TestGypCustom(format='analyzer') 37 test = TestGyp.TestGypCustom(format='analyzer')
38 38
39 def run_analyzer(*args, **kw): 39 def run_analyzer(*args, **kw):
40 """Runs the test specifying a particular config and output path.""" 40 """Runs the test specifying a particular config and output path."""
41 args += ('-Gconfig_path=test_file', 41 args += ('-Gconfig_path=test_file',
42 '-Ganalyzer_output_path=analyzer_output') 42 '-Ganalyzer_output_path=analyzer_output')
43 test.run_gyp('test.gyp', *args, **kw) 43 test.run_gyp('test.gyp', *args, **kw)
44 44
45 def run_analyzer2(*args, **kw):
46 """Runs the test specifying a particular config and output path."""
47 args += ('-Gconfig_path=test_file',
48 '-Ganalyzer_output_path=analyzer_output')
49 test.run_gyp('test2.gyp', *args, **kw)
50
45 def EnsureContains(targets=set(), matched=False): 51 def EnsureContains(targets=set(), matched=False):
46 """Verifies output contains |targets| and |direct_targets|.""" 52 """Verifies output contains |targets| and |direct_targets|."""
scottmg 2014/08/05 23:02:43 Looks like there's no |direct_targets| any longer.
sky 2014/08/06 00:26:07 Done.
47 result = _ReadOutputFileContents() 53 result = _ReadOutputFileContents()
48 if result.get('error', None): 54 if result.get('error', None):
49 print 'unexpected error', result.get('error') 55 print 'unexpected error', result.get('error')
50 test.fail_test() 56 test.fail_test()
51 57
52 if result.get('warning', None): 58 if result.get('warning', None):
53 print 'unexpected warning', result.get('warning') 59 print 'unexpected warning', result.get('warning')
54 test.fail_test() 60 test.fail_test()
55 61
56 actual_targets = set(result['targets']) 62 actual_targets = set(result['targets'])
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 EnsureContains(matched=True) 195 EnsureContains(matched=True)
190 196
191 _CreateTestFile(['subdir/subdir2b_source.c', 'exe2.c'], []) 197 _CreateTestFile(['subdir/subdir2b_source.c', 'exe2.c'], [])
192 run_analyzer() 198 run_analyzer()
193 EnsureContains(matched=True) 199 EnsureContains(matched=True)
194 200
195 _CreateTestFile(['exe2.c'], []) 201 _CreateTestFile(['exe2.c'], [])
196 run_analyzer() 202 run_analyzer()
197 EnsureContains(matched=True) 203 EnsureContains(matched=True)
198 204
205 # Assertions when modifying build (gyp/gypi) files, especially when said files
206 # are included.
207 _CreateTestFile(['subdir2/d.cc'], ['exe', 'exe2', 'foo', 'exe3'])
208 run_analyzer2()
209 EnsureContains(matched=True, targets={'exe', 'foo'})
210
211 _CreateTestFile(['subdir2/subdir.includes.gypi'],
212 ['exe', 'exe2', 'foo', 'exe3'])
213 run_analyzer2()
214 EnsureContains(matched=True, targets={'exe', 'foo'})
215
216 _CreateTestFile(['subdir2/subdir.gyp'], ['exe', 'exe2', 'foo', 'exe3'])
217 run_analyzer2()
218 EnsureContains(matched=True, targets={'exe', 'foo'})
219
220 _CreateTestFile(['test2.includes.gypi'], ['exe', 'exe2', 'foo', 'exe3'])
221 run_analyzer2()
222 EnsureContains(matched=True, targets={'exe', 'exe2', 'exe3'})
223
224 # Verify modifying a file included makes all targets dirty.
225 _CreateTestFile(['common.gypi'], ['exe', 'exe2', 'foo', 'exe3'])
226 run_analyzer2('-Icommon.gypi')
227 EnsureContains(matched=True, targets={'exe', 'foo', 'exe2', 'exe3'})
228
199 test.pass_test() 229 test.pass_test()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698