| Index: test/analyzer/gyptest-analyzer.py
|
| ===================================================================
|
| --- test/analyzer/gyptest-analyzer.py (revision 1964)
|
| +++ test/analyzer/gyptest-analyzer.py (working copy)
|
| @@ -9,45 +9,49 @@
|
| import json
|
| import TestGyp
|
|
|
| -# TODO(sky): when done migrating recipes rename to gyptest-analyzer and nuke
|
| -# existing gyptest-analyzer.
|
| -
|
| found = 'Found dependency'
|
| not_found = 'No dependencies'
|
|
|
| +
|
| def _CreateTestFile(files, targets):
|
| f = open('test_file', 'w')
|
| to_write = {'files': files, 'targets': targets }
|
| json.dump(to_write, f)
|
| f.close()
|
|
|
| +
|
| def _CreateBogusTestFile():
|
| f = open('test_file','w')
|
| f.write('bogus')
|
| f.close()
|
|
|
| +
|
| def _ReadOutputFileContents():
|
| f = open('analyzer_output', 'r')
|
| result = json.load(f)
|
| f.close()
|
| return result
|
|
|
| +
|
| # NOTE: this would be clearer if it subclassed TestGypCustom, but that trips
|
| # over a bug in pylint (E1002).
|
| test = TestGyp.TestGypCustom(format='analyzer')
|
|
|
| +
|
| def run_analyzer(*args, **kw):
|
| """Runs the test specifying a particular config and output path."""
|
| args += ('-Gconfig_path=test_file',
|
| '-Ganalyzer_output_path=analyzer_output')
|
| test.run_gyp('test.gyp', *args, **kw)
|
|
|
| +
|
| def run_analyzer2(*args, **kw):
|
| """Runs the test specifying a particular config and output path."""
|
| args += ('-Gconfig_path=test_file',
|
| '-Ganalyzer_output_path=analyzer_output')
|
| test.run_gyp('test2.gyp', *args, **kw)
|
|
|
| +
|
| def EnsureContains(targets=set(), matched=False):
|
| """Verifies output contains |targets|."""
|
| result = _ReadOutputFileContents()
|
| @@ -71,6 +75,7 @@
|
| print 'expected', not_found, 'got', result['status']
|
| test.fail_test()
|
|
|
| +
|
| def EnsureError(expected_error_string):
|
| """Verifies output contains the error string."""
|
| result = _ReadOutputFileContents()
|
| @@ -79,6 +84,14 @@
|
| expected_error_string
|
| test.fail_test()
|
|
|
| +
|
| +def EnsureStdoutContains(expected_error_string):
|
| + if test.stdout().find(expected_error_string) == -1:
|
| + print 'actual stdout:', test.stdout(), '\nexpected stdout:', \
|
| + expected_error_string
|
| + test.fail_test()
|
| +
|
| +
|
| def EnsureWarning(expected_warning_string):
|
| """Verifies output contains the warning string."""
|
| result = _ReadOutputFileContents()
|
| @@ -87,11 +100,11 @@
|
| '\nexpected warning:', expected_warning_string
|
| test.fail_test()
|
|
|
| -# Verifies file_path must be specified.
|
| -test.run_gyp('test.gyp',
|
| - stdout='Must specify files to analyze via file_path generator '
|
| - 'flag\n')
|
|
|
| +# Verifies config_path must be specified.
|
| +test.run_gyp('test.gyp')
|
| +EnsureStdoutContains('Must specify files to analyze via config_path')
|
| +
|
| # Verifies config_path must point to a valid file.
|
| test.run_gyp('test.gyp', '-Gconfig_path=bogus_file',
|
| '-Ganalyzer_output_path=analyzer_output')
|
|
|