| Index: test/analyzer/gyptest-analyzer.py
|
| diff --git a/test/analyzer/gyptest-analyzer.py b/test/analyzer/gyptest-analyzer.py
|
| index 7d1c5285f354c485c9dd56acb26073851b8872e7..03e6791f1b2384738ecacbcac2c10d64af4063a0 100644
|
| --- a/test/analyzer/gyptest-analyzer.py
|
| +++ b/test/analyzer/gyptest-analyzer.py
|
| @@ -14,11 +14,13 @@ found_all = 'Found dependency (all)'
|
| not_found = 'No dependencies'
|
|
|
|
|
| -def _CreateConfigFile(files, targets):
|
| +def _CreateConfigFile(files, additional_compile_targets, test_targets=[]):
|
| """Creates the analyzer config file, which is used as the input to analyzer.
|
| See description of analyzer.py for description of the arguments."""
|
| f = open('test_file', 'w')
|
| - to_write = {'files': files, 'targets': targets }
|
| + to_write = {'files': files,
|
| + 'test_targets': test_targets,
|
| + 'additional_compile_targets': additional_compile_targets }
|
| json.dump(to_write, f)
|
| f.close()
|
|
|
| @@ -69,8 +71,8 @@ def run_analyzer4(*args, **kw):
|
| test.run_gyp('test4.gyp', *args, **kw)
|
|
|
|
|
| -def EnsureContains(matched=False, build_targets=set()):
|
| - """Verifies output contains |build_targets|."""
|
| +def EnsureContains(matched=False, compile_targets=set(), test_targets=set()):
|
| + """Verifies output contains |compile_targets|."""
|
| result = _ReadOutputFileContents()
|
| if result.get('error', None):
|
| print 'unexpected error', result.get('error')
|
| @@ -80,17 +82,16 @@ def EnsureContains(matched=False, build_targets=set()):
|
| print 'unexpected invalid_targets', result.get('invalid_targets')
|
| test.fail_test()
|
|
|
| - # TODO(sky): nuke when get rid of targets.
|
| - targets = build_targets
|
| - actual_targets = set(result['targets'])
|
| - if actual_targets != targets:
|
| - print 'actual targets:', actual_targets, '\nexpected targets:', targets
|
| + actual_compile_targets = set(result['compile_targets'])
|
| + if actual_compile_targets != compile_targets:
|
| + print 'actual compile_targets:', actual_compile_targets, \
|
| + '\nexpected compile_targets:', compile_targets
|
| test.fail_test()
|
|
|
| - actual_build_targets = set(result['build_targets'])
|
| - if actual_build_targets != build_targets:
|
| - print 'actual build_targets:', actual_build_targets, \
|
| - '\nexpected build_targets:', build_targets
|
| + actual_test_targets = set(result['test_targets'])
|
| + if actual_test_targets != test_targets:
|
| + print 'actual test_targets:', actual_test_targets, \
|
| + '\nexpected test_targets:', test_targets
|
| test.fail_test()
|
|
|
| if matched and result['status'] != found:
|
| @@ -101,7 +102,7 @@ def EnsureContains(matched=False, build_targets=set()):
|
| test.fail_test()
|
|
|
|
|
| -def EnsureMatchedAll(targets):
|
| +def EnsureMatchedAll(compile_targets, test_targets=set()):
|
| result = _ReadOutputFileContents()
|
| if result.get('error', None):
|
| print 'unexpected error', result.get('error')
|
| @@ -115,9 +116,16 @@ def EnsureMatchedAll(targets):
|
| print 'expected', found_all, 'got', result['status']
|
| test.fail_test()
|
|
|
| - actual_targets = set(result['targets'])
|
| - if actual_targets != targets:
|
| - print 'actual targets:', actual_targets, '\nexpected targets:', targets
|
| + actual_compile_targets = set(result['compile_targets'])
|
| + if actual_compile_targets != compile_targets:
|
| + print ('actual compile_targets:', actual_compile_targets,
|
| + '\nexpected compile_targets:', compile_targets)
|
| + test.fail_test()
|
| +
|
| + actual_test_targets = set(result['test_targets'])
|
| + if actual_test_targets != test_targets:
|
| + print ('actual test_targets:', actual_test_targets,
|
| + '\nexpected test_targets:', test_targets)
|
| test.fail_test()
|
|
|
|
|
| @@ -150,9 +158,9 @@ def EnsureInvalidTargets(expected_invalid_targets):
|
| # Two targets, A and B (both static_libraries) and A depends upon B. If a file
|
| # in B changes, then both A and B are output. It is not strictly necessary that
|
| # A is compiled in this case, only B.
|
| -_CreateConfigFile(['b.c'], ['a'])
|
| +_CreateConfigFile(['b.c'], ['all'])
|
| test.run_gyp('static_library_test.gyp', *CommonArgs())
|
| -EnsureContains(matched=True, build_targets={'a' ,'b'})
|
| +EnsureContains(matched=True, compile_targets={'a' ,'b'})
|
|
|
| # Verifies config_path must be specified.
|
| test.run_gyp('test.gyp')
|
| @@ -164,7 +172,7 @@ test.run_gyp('test.gyp', '-Gconfig_path=bogus_file',
|
| EnsureError('Unable to open file bogus_file')
|
|
|
| # Verify 'invalid_targets' is present when bad target is specified.
|
| -_CreateConfigFile(['exe2.c'], ['bad_target', 'all', 'exe2'])
|
| +_CreateConfigFile(['exe2.c'], ['bad_target'])
|
| run_analyzer()
|
| EnsureInvalidTargets({'bad_target'})
|
|
|
| @@ -174,196 +182,243 @@ run_analyzer()
|
| EnsureError('Unable to parse config file test_file')
|
|
|
| # Trivial test of a source.
|
| -_CreateConfigFile(['foo.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['foo.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Conditional source that is excluded.
|
| -_CreateConfigFile(['conditional_source.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['conditional_source.c'], ['all'])
|
| run_analyzer()
|
| EnsureContains(matched=False)
|
|
|
| # Conditional source that is included by way of argument.
|
| -_CreateConfigFile(['conditional_source.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['conditional_source.c'], ['all'])
|
| run_analyzer('-Dtest_variable=1')
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Two unknown files.
|
| -_CreateConfigFile(['unknown1.c', 'unoknow2.cc'], ['all', 'exe2'])
|
| +_CreateConfigFile(['unknown1.c', 'unoknow2.cc'], ['all'])
|
| run_analyzer()
|
| EnsureContains()
|
|
|
| # Two unknown files.
|
| -_CreateConfigFile(['unknown1.c', 'subdir/subdir_sourcex.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['unknown1.c', 'subdir/subdir_sourcex.c'], ['all'])
|
| run_analyzer()
|
| EnsureContains()
|
|
|
| # Included dependency
|
| -_CreateConfigFile(['unknown1.c', 'subdir/subdir_source.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['unknown1.c', 'subdir/subdir_source.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe', 'exe3'})
|
| +EnsureContains(matched=True, compile_targets={'exe', 'exe3'})
|
|
|
| # Included inputs to actions.
|
| -_CreateConfigFile(['action_input.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['action_input.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Don't consider outputs.
|
| -_CreateConfigFile(['action_output.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['action_output.c'], ['all'])
|
| run_analyzer()
|
| EnsureContains(matched=False)
|
|
|
| # Rule inputs.
|
| -_CreateConfigFile(['rule_input.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['rule_input.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Ignore path specified with PRODUCT_DIR.
|
| -_CreateConfigFile(['product_dir_input.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['product_dir_input.c'], ['all'])
|
| run_analyzer()
|
| EnsureContains(matched=False)
|
|
|
| # Path specified via a variable.
|
| -_CreateConfigFile(['subdir/subdir_source2.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['subdir/subdir_source2.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Verifies paths with // are fixed up correctly.
|
| -_CreateConfigFile(['parent_source.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['parent_source.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe', 'exe3'})
|
| +EnsureContains(matched=True, compile_targets={'exe', 'exe3'})
|
|
|
| # Verifies relative paths are resolved correctly.
|
| -_CreateConfigFile(['subdir/subdir_source.h'], ['all', 'exe2'])
|
| +_CreateConfigFile(['subdir/subdir_source.h'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Verifies relative paths in inputs are resolved correctly.
|
| -_CreateConfigFile(['rel_path1.h'], ['all', 'exe2'])
|
| +_CreateConfigFile(['rel_path1.h'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Various permutations when passing in targets.
|
| _CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'],
|
| - ['exe', 'exe3', 'all', 'exe2'])
|
| + ['all'], ['exe', 'exe3'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
|
| +EnsureContains(matched=True, test_targets={'exe3'},
|
| + compile_targets={'exe2', 'exe3'})
|
|
|
| -_CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'],
|
| - ['exe', 'all', 'exe2'])
|
| +_CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], ['all'], ['exe'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
|
| +EnsureContains(matched=True, compile_targets={'exe2', 'exe3'})
|
|
|
| # Verifies duplicates are ignored.
|
| -_CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'],
|
| - ['exe', 'exe', 'all', 'exe2'])
|
| +_CreateConfigFile(['exe2.c', 'subdir/subdir2b_source.c'], ['all'],
|
| + ['exe', 'exe'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
|
| +EnsureContains(matched=True, compile_targets={'exe2', 'exe3'})
|
|
|
| -_CreateConfigFile(['exe2.c'], ['exe', 'all', 'exe2'])
|
| +_CreateConfigFile(['exe2.c'], ['all'], ['exe'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe2'})
|
| +EnsureContains(matched=True, compile_targets={'exe2'})
|
|
|
| -_CreateConfigFile(['exe2.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['exe2.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe2'})
|
| +EnsureContains(matched=True, compile_targets={'exe2'})
|
|
|
| -_CreateConfigFile(['subdir/subdir2b_source.c', 'exe2.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['subdir/subdir2b_source.c', 'exe2.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe2', 'exe3'})
|
| +EnsureContains(matched=True, compile_targets={'exe2', 'exe3'})
|
|
|
| -_CreateConfigFile(['subdir/subdir2b_source.c'], ['exe3', 'all', 'exe2'])
|
| +_CreateConfigFile(['subdir/subdir2b_source.c'], ['all'], ['exe3'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe3'})
|
| +EnsureContains(matched=True, test_targets={'exe3'}, compile_targets={'exe3'})
|
|
|
| -_CreateConfigFile(['foo.c'], ['all', 'exe2'])
|
| +_CreateConfigFile(['exe2.c'], ['all'])
|
| run_analyzer()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, compile_targets={'exe2'})
|
| +
|
| +_CreateConfigFile(['foo.c'], ['all'])
|
| +run_analyzer()
|
| +EnsureContains(matched=True, compile_targets={'exe'})
|
|
|
| # Assertions when modifying build (gyp/gypi) files, especially when said files
|
| # are included.
|
| -_CreateConfigFile(['subdir2/d.cc'], ['exe', 'exe2', 'foo', 'exe3'])
|
| +_CreateConfigFile(['subdir2/d.cc'], ['all'], ['exe', 'exe2', 'foo', 'exe3'])
|
| run_analyzer2()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, test_targets={'exe', 'foo'},
|
| + compile_targets={'exe'})
|
|
|
| -_CreateConfigFile(['subdir2/subdir.includes.gypi'],
|
| +_CreateConfigFile(['subdir2/subdir.includes.gypi'], ['all'],
|
| ['exe', 'exe2', 'foo', 'exe3'])
|
| run_analyzer2()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, test_targets={'exe', 'foo'},
|
| + compile_targets={'exe'})
|
|
|
| -_CreateConfigFile(['subdir2/subdir.gyp'], ['exe', 'exe2', 'foo', 'exe3'])
|
| +_CreateConfigFile(['subdir2/subdir.gyp'], ['all'],
|
| + ['exe', 'exe2', 'foo', 'exe3'])
|
| run_analyzer2()
|
| -EnsureContains(matched=True, build_targets={'exe'})
|
| +EnsureContains(matched=True, test_targets={'exe', 'foo'},
|
| + compile_targets={'exe'})
|
|
|
| -_CreateConfigFile(['test2.includes.gypi'], ['exe', 'exe2', 'foo', 'exe3'])
|
| +_CreateConfigFile(['test2.includes.gypi'], ['all'],
|
| + ['exe', 'exe2', 'foo', 'exe3'])
|
| run_analyzer2()
|
| -EnsureContains(matched=True, build_targets={'exe', 'exe2', 'exe3'})
|
| +EnsureContains(matched=True, test_targets={'exe', 'exe2', 'exe3'},
|
| + compile_targets={'exe', 'exe2', 'exe3'})
|
|
|
| # Verify modifying a file included makes all targets dirty.
|
| -_CreateConfigFile(['common.gypi'], ['exe', 'exe2', 'foo', 'exe3'])
|
| +_CreateConfigFile(['common.gypi'], ['all'], ['exe', 'exe2', 'foo', 'exe3'])
|
| run_analyzer2('-Icommon.gypi')
|
| -EnsureMatchedAll({'exe', 'exe2', 'foo', 'exe3'})
|
| +EnsureMatchedAll({'all', 'exe', 'exe2', 'foo', 'exe3'},
|
| + {'exe', 'exe2', 'foo', 'exe3'})
|
|
|
| # Assertions from test3.gyp.
|
| -_CreateConfigFile(['d.c', 'f.c'], ['a', 'all'])
|
| +_CreateConfigFile(['d.c', 'f.c'], ['all'], ['a'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b'})
|
| +EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'})
|
|
|
| -_CreateConfigFile(['f.c'], ['a', 'all'])
|
| +_CreateConfigFile(['f.c'], ['all'], ['a'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b'})
|
| +EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'})
|
|
|
| _CreateConfigFile(['f.c'], ['all'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b'})
|
| +EnsureContains(matched=True, compile_targets={'a', 'b'})
|
|
|
| _CreateConfigFile(['c.c', 'e.c'], ['all'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'e'})
|
| +EnsureContains(matched=True, compile_targets={'a', 'b', 'c', 'e'})
|
|
|
| -_CreateConfigFile(['d.c'], ['a', 'all'])
|
| +_CreateConfigFile(['d.c'], ['all'], ['a'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b'})
|
| +EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'})
|
|
|
| -_CreateConfigFile(['a.c'], ['a', 'b', 'all'])
|
| +_CreateConfigFile(['a.c'], ['all'], ['a', 'b'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a'})
|
| +EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a'})
|
|
|
| -_CreateConfigFile(['a.c'], ['a', 'b', 'all'])
|
| +_CreateConfigFile(['a.c'], ['all'], ['a', 'b'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a'})
|
| +EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a'})
|
|
|
| -_CreateConfigFile(['d.c'], ['a', 'b', 'all'])
|
| +_CreateConfigFile(['d.c'], ['all'], ['a', 'b'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b'})
|
| +EnsureContains(matched=True, test_targets={'a', 'b'},
|
| + compile_targets={'a', 'b'})
|
|
|
| -_CreateConfigFile(['f.c'], ['a', 'all'])
|
| +_CreateConfigFile(['f.c'], ['all'], ['a'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b'})
|
| +EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a', 'b'})
|
|
|
| -_CreateConfigFile(['a.c'], ['a', 'all'])
|
| +_CreateConfigFile(['a.c'], ['all'], ['a'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a'})
|
| +EnsureContains(matched=True, test_targets={'a'}, compile_targets={'a'})
|
|
|
| _CreateConfigFile(['a.c'], ['all'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a'})
|
| +EnsureContains(matched=True, compile_targets={'a'})
|
|
|
| _CreateConfigFile(['d.c'], ['all'])
|
| run_analyzer3()
|
| -EnsureContains(matched=True, build_targets={'a', 'b'})
|
| +EnsureContains(matched=True, compile_targets={'a', 'b'})
|
|
|
| # Assertions around test4.gyp.
|
| -_CreateConfigFile(['f.c'], ['a', 'e', 'h'])
|
| +_CreateConfigFile(['f.c'], ['all'])
|
| run_analyzer4()
|
| -EnsureContains(matched=True, build_targets={'e', 'f'})
|
| +EnsureContains(matched=True, compile_targets={'e', 'f'})
|
|
|
| -_CreateConfigFile(['d.c'], ['a', 'e', 'h'])
|
| +_CreateConfigFile(['d.c'], ['all'])
|
| run_analyzer4()
|
| -EnsureContains(matched=True, build_targets={'a', 'b', 'c', 'd'})
|
| +EnsureContains(matched=True, compile_targets={'a', 'b', 'c', 'd'})
|
|
|
| -_CreateConfigFile(['i.c'], ['a', 'e', 'h'])
|
| +_CreateConfigFile(['i.c'], ['all'])
|
| run_analyzer4()
|
| -EnsureContains(matched=True, build_targets={'h', 'i'})
|
| +EnsureContains(matched=True, compile_targets={'h', 'i'})
|
| +
|
| +# Assertions where 'all' is not supplied in compile_targets.
|
| +
|
| +_CreateConfigFile(['exe2.c'], [], ['exe2'])
|
| +run_analyzer()
|
| +EnsureContains(matched=True, test_targets={'exe2'}, compile_targets={'exe2'})
|
| +
|
| +_CreateConfigFile(['exe20.c'], [], ['exe2'])
|
| +run_analyzer()
|
| +EnsureContains(matched=False)
|
| +
|
| +
|
| +_CreateConfigFile(['exe2.c', 'exe3.c'], [], ['exe2', 'exe3'])
|
| +run_analyzer()
|
| +EnsureContains(matched=True, test_targets={'exe2', 'exe3'},
|
| + compile_targets={'exe2', 'exe3'})
|
| +
|
| +_CreateConfigFile(['exe2.c', 'exe3.c'], ['exe3'], ['exe2'])
|
| +run_analyzer()
|
| +EnsureContains(matched=True, test_targets={'exe2'},
|
| + compile_targets={'exe2', 'exe3'})
|
| +
|
| +_CreateConfigFile(['exe3.c'], ['exe2'], ['exe2'])
|
| +run_analyzer()
|
| +EnsureContains(matched=False)
|
| +
|
| +# Assertions with 'all' listed as a test_target.
|
| +_CreateConfigFile(['exe3.c'], [], ['all'])
|
| +run_analyzer()
|
| +EnsureContains(matched=True, compile_targets={'exe3'}, test_targets={'all'})
|
| +
|
| +_CreateConfigFile(['exe2.c'], [], ['all', 'exe2'])
|
| +run_analyzer()
|
| +EnsureContains(matched=True, compile_targets={'exe2'},
|
| + test_targets={'all', 'exe2'})
|
|
|
| test.pass_test()
|
|
|