OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """Tests for analyzer |
| 7 """ |
| 8 |
| 9 import TestGyp |
| 10 |
| 11 found = 'Found dependency\n' |
| 12 not_found = 'No dependencies\n' |
| 13 |
| 14 def __CreateTestFile(files): |
| 15 f = open('test_file', 'w') |
| 16 for file in files: |
| 17 f.write(file + '\n') |
| 18 f.close() |
| 19 |
| 20 test = TestGyp.TestGypCustom(format='analyzer') |
| 21 |
| 22 # Verifies file_path must be specified. |
| 23 test.run_gyp('test.gyp', |
| 24 stdout='Must specify files to analyze via file_path generator ' |
| 25 'flag\n') |
| 26 |
| 27 # Trivial test of a source. |
| 28 __CreateTestFile(['foo.c']) |
| 29 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=found) |
| 30 |
| 31 # Conditional source that is excluded. |
| 32 __CreateTestFile(['conditional_source.c']) |
| 33 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=not_found) |
| 34 |
| 35 # Conditional source that is included by way of argument. |
| 36 __CreateTestFile(['conditional_source.c']) |
| 37 test.run_gyp('test.gyp', '-Gfile_path=test_file', '-Dtest_variable=1', |
| 38 stdout=found) |
| 39 |
| 40 # Two unknown files. |
| 41 __CreateTestFile(['unknown1.c', 'unoknow2.cc']) |
| 42 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=not_found) |
| 43 |
| 44 # Two unknown files. |
| 45 __CreateTestFile(['unknown1.c', 'subdir/subdir_sourcex.c']) |
| 46 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=not_found) |
| 47 |
| 48 # Included dependency |
| 49 __CreateTestFile(['unknown1.c', 'subdir/subdir_source.c']) |
| 50 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=found) |
| 51 |
| 52 # Included inputs to actions. |
| 53 __CreateTestFile(['action_input.c']) |
| 54 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=found) |
| 55 |
| 56 # Don't consider outputs. |
| 57 __CreateTestFile(['action_output.c']) |
| 58 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=not_found) |
| 59 |
| 60 # Rule inputs. |
| 61 __CreateTestFile(['rule_input.c']) |
| 62 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=found) |
| 63 |
| 64 # Ignore patch specified with PRODUCT_DIR. |
| 65 __CreateTestFile(['product_dir_input.c']) |
| 66 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=not_found) |
| 67 |
| 68 # Path specified via a variable. |
| 69 __CreateTestFile(['subdir/subdir_source2.c']) |
| 70 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=found) |
| 71 |
| 72 # Verifies paths with // are fixed up correctly. |
| 73 __CreateTestFile(['parent_source.c']) |
| 74 test.run_gyp('test.gyp', '-Gfile_path=test_file', stdout=found) |
| 75 |
| 76 test.pass_test() |
OLD | NEW |