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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 test = StartTest(sourcefile_path, cflags, config) | 455 test = StartTest(sourcefile_path, cflags, config) |
456 assert test['name'] not in executing_tests | 456 assert test['name'] not in executing_tests |
457 executing_tests[test['name']] = test | 457 executing_tests[test['name']] = test |
458 | 458 |
459 # If there are no more test to start, we still need to drain the running | 459 # If there are no more test to start, we still need to drain the running |
460 # ones. | 460 # ones. |
461 while len(executing_tests) > 0: | 461 while len(executing_tests) > 0: |
462 finished_tests.extend(CompleteAtLeastOneTest(executing_tests)) | 462 finished_tests.extend(CompleteAtLeastOneTest(executing_tests)) |
463 timings['compile_done'] = time.time() | 463 timings['compile_done'] = time.time() |
464 | 464 |
| 465 finished_tests = sorted(finished_tests, key=lambda test: test['name']) |
465 for test in finished_tests: | 466 for test in finished_tests: |
466 if test['name'] == 'NCTEST_SANITY': | 467 if test['name'] == 'NCTEST_SANITY': |
467 _, stderr = test['proc'].communicate() | 468 _, stderr = test['proc'].communicate() |
468 return_code = test['proc'].poll() | 469 return_code = test['proc'].poll() |
469 if return_code != 0: | 470 if return_code != 0: |
470 sys.stderr.write(stderr) | 471 sys.stderr.write(stderr) |
471 continue | 472 continue |
472 ProcessTestResult(resultfile, resultlog, test) | 473 ProcessTestResult(resultfile, resultlog, test) |
473 timings['results_processed'] = time.time() | 474 timings['results_processed'] = time.time() |
474 | 475 |
475 WriteStats(resultlog, suite_name, timings) | 476 WriteStats(resultlog, suite_name, timings) |
476 | 477 |
477 with open(resultfile_path + '.log', 'w') as fd: | 478 with open(resultfile_path + '.log', 'w') as fd: |
478 fd.write(resultlog.getvalue()) | 479 fd.write(resultlog.getvalue()) |
479 if return_code == 0: | 480 if return_code == 0: |
480 with open(resultfile_path, 'w') as fd: | 481 with open(resultfile_path, 'w') as fd: |
481 fd.write(resultfile.getvalue()) | 482 fd.write(resultfile.getvalue()) |
482 | 483 |
483 resultfile.close() | 484 resultfile.close() |
484 sys.exit(return_code) | 485 sys.exit(return_code) |
485 | 486 |
486 | 487 |
487 if __name__ == '__main__': | 488 if __name__ == '__main__': |
488 main() | 489 main() |
OLD | NEW |