| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 was aborted. If the test completed successfully, | 213 was aborted. If the test completed successfully, |
| 214 this value is 0. | 214 this value is 0. |
| 215 'finished_at': A timestamp in seconds since the epoch for when this | 215 'finished_at': A timestamp in seconds since the epoch for when this |
| 216 test was successfully complete. If the test is aborted, | 216 test was successfully complete. If the test is aborted, |
| 217 or running, this value is 0. | 217 or running, this value is 0. |
| 218 'expectations': A dictionary with the test expectations. See | 218 'expectations': A dictionary with the test expectations. See |
| 219 ParseExpectation() for the structure. | 219 ParseExpectation() for the structure. |
| 220 } | 220 } |
| 221 """ | 221 """ |
| 222 # TODO(ajwong): Get the compiler from gyp. | 222 # TODO(ajwong): Get the compiler from gyp. |
| 223 cmdline = ['g++'] | 223 cmdline = [os.path.join(os.path.dirname(os.path.realpath(__file__)), |
| 224 '../third_party/llvm-build/Release+Asserts/bin', |
| 225 'clang++')] |
| 224 cmdline.extend(shlex.split(cflags)) | 226 cmdline.extend(shlex.split(cflags)) |
| 225 name = config['name'] | 227 name = config['name'] |
| 226 expectations = config['expectations'] | 228 expectations = config['expectations'] |
| 227 if expectations is not None: | 229 if expectations is not None: |
| 228 cmdline.append('-D%s' % name) | 230 cmdline.append('-D%s' % name) |
| 229 cmdline.extend(['-o', '/dev/null', '-c', '-x', 'c++', sourcefile_path]) | 231 cmdline.extend(['-std=c++11', '-o', '/dev/null', '-c', '-x', 'c++', |
| 232 sourcefile_path]) |
| 230 | 233 |
| 231 process = subprocess.Popen(cmdline, stdout=subprocess.PIPE, | 234 process = subprocess.Popen(cmdline, stdout=subprocess.PIPE, |
| 232 stderr=subprocess.PIPE) | 235 stderr=subprocess.PIPE) |
| 233 now = time.time() | 236 now = time.time() |
| 234 return {'proc': process, | 237 return {'proc': process, |
| 235 'cmdline': ' '.join(cmdline), | 238 'cmdline': ' '.join(cmdline), |
| 236 'name': name, | 239 'name': name, |
| 237 'suite_name': config['suite_name'], | 240 'suite_name': config['suite_name'], |
| 238 'terminate_timeout': now + NCTEST_TERMINATE_TIMEOUT_SEC, | 241 'terminate_timeout': now + NCTEST_TERMINATE_TIMEOUT_SEC, |
| 239 'kill_timeout': now + NCTEST_KILL_TIMEOUT_SEC, | 242 'kill_timeout': now + NCTEST_KILL_TIMEOUT_SEC, |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 timings['results_processed'] = time.time() | 466 timings['results_processed'] = time.time() |
| 464 | 467 |
| 465 # We always know at least a sanity test was run. | 468 # We always know at least a sanity test was run. |
| 466 WriteStats(resultfile, finished_tests[0]['suite_name'], timings) | 469 WriteStats(resultfile, finished_tests[0]['suite_name'], timings) |
| 467 | 470 |
| 468 resultfile.close() | 471 resultfile.close() |
| 469 | 472 |
| 470 | 473 |
| 471 if __name__ == '__main__': | 474 if __name__ == '__main__': |
| 472 main() | 475 main() |
| OLD | NEW |