| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. 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 """Implements a simple "negative compile" test for C++ on linux. | 6 """Implements a simple "negative compile" test for C++ on linux. |
| 7 | 7 |
| 8 Sometimes a C++ API needs to ensure that various usages cannot compile. To | 8 Sometimes a C++ API needs to ensure that various usages cannot compile. To |
| 9 enable unittesting of these assertions, we use this python script to | 9 enable unittesting of these assertions, we use this python script to |
| 10 invoke gcc on a source file and assert that compilation fails. | 10 invoke gcc on a source file and assert that compilation fails. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 assert type(raw_expectation) is list | 114 assert type(raw_expectation) is list |
| 115 | 115 |
| 116 expectation = [] | 116 expectation = [] |
| 117 for regex_str in raw_expectation: | 117 for regex_str in raw_expectation: |
| 118 assert type(regex_str) is str | 118 assert type(regex_str) is str |
| 119 expectation.append(re.compile(regex_str)) | 119 expectation.append(re.compile(regex_str)) |
| 120 return expectation | 120 return expectation |
| 121 | 121 |
| 122 | 122 |
| 123 def ExtractTestConfigs(sourcefile_path, suite_name): | 123 def ExtractTestConfigs(sourcefile_path, suite_name): |
| 124 """Parses the soruce file for test configurations. | 124 """Parses the source file for test configurations. |
| 125 | 125 |
| 126 Each no-compile test in the file is separated by an ifdef macro. We scan | 126 Each no-compile test in the file is separated by an ifdef macro. We scan |
| 127 the source file with the NCTEST_CONFIG_RE to find all ifdefs that look like | 127 the source file with the NCTEST_CONFIG_RE to find all ifdefs that look like |
| 128 they demark one no-compile test and try to extract the test configuration | 128 they demark one no-compile test and try to extract the test configuration |
| 129 from that. | 129 from that. |
| 130 | 130 |
| 131 Args: | 131 Args: |
| 132 sourcefile_path: The path to the source file. | 132 sourcefile_path: The path to the source file. |
| 133 suite_name: The name of the test suite. | 133 suite_name: The name of the test suite. |
| 134 | 134 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 if return_code == 0: | 477 if return_code == 0: |
| 478 with open(resultfile_path, 'w') as fd: | 478 with open(resultfile_path, 'w') as fd: |
| 479 fd.write(resultfile.getvalue()) | 479 fd.write(resultfile.getvalue()) |
| 480 | 480 |
| 481 resultfile.close() | 481 resultfile.close() |
| 482 sys.exit(return_code) | 482 sys.exit(return_code) |
| 483 | 483 |
| 484 | 484 |
| 485 if __name__ == '__main__': | 485 if __name__ == '__main__': |
| 486 main() | 486 main() |
| OLD | NEW |