OLD | NEW |
1 from __future__ import print_function | 1 from __future__ import print_function |
2 | 2 |
3 import argparse | 3 import argparse |
4 import logging | 4 import logging |
5 import os | 5 import os |
6 import re | 6 import re |
7 import stat | 7 import stat |
8 import subprocess | 8 import subprocess |
9 import sys | 9 import sys |
10 import tarfile | 10 import tarfile |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 def write_inconsistent(inconsistent, iterations): | 568 def write_inconsistent(inconsistent, iterations): |
569 """Output inconsistent tests to logger.error.""" | 569 """Output inconsistent tests to logger.error.""" |
570 logger.error("## Unstable results ##\n") | 570 logger.error("## Unstable results ##\n") |
571 strings = [("`%s`" % markdown_adjust(test), ("`%s`" % markdown_adjust(subtes
t)) if subtest else "", err_string(results, iterations)) | 571 strings = [("`%s`" % markdown_adjust(test), ("`%s`" % markdown_adjust(subtes
t)) if subtest else "", err_string(results, iterations)) |
572 for test, subtest, results in inconsistent] | 572 for test, subtest, results in inconsistent] |
573 table(["Test", "Subtest", "Results"], strings, logger.error) | 573 table(["Test", "Subtest", "Results"], strings, logger.error) |
574 | 574 |
575 | 575 |
576 def write_results(results, iterations, comment_pr): | 576 def write_results(results, iterations, comment_pr): |
577 """Output all test results to logger.info.""" | 577 """Output all test results to logger.info.""" |
| 578 pr_number = None |
| 579 if comment_pr: |
| 580 try: |
| 581 pr_number = int(comment_pr) |
| 582 except ValueError: |
| 583 pass |
578 logger.info("## All results ##\n") | 584 logger.info("## All results ##\n") |
| 585 if pr_number: |
| 586 logger.info("<details>\n") |
| 587 logger.info("<summary>%i %s ran</summary>\n\n" % (len(results), |
| 588 "tests" if len(results
) > 1 |
| 589 else "test")) |
| 590 |
579 for test, test_results in results.iteritems(): | 591 for test, test_results in results.iteritems(): |
580 baseurl = "http://w3c-test.org/submissions" | 592 baseurl = "http://w3c-test.org/submissions" |
581 if "https" in os.path.splitext(test)[0].split(".")[1:]: | 593 if "https" in os.path.splitext(test)[0].split(".")[1:]: |
582 baseurl = "https://w3c-test.org/submissions" | 594 baseurl = "https://w3c-test.org/submissions" |
583 pr_number = None | |
584 if comment_pr: | |
585 try: | |
586 pr_number = int(comment_pr) | |
587 except ValueError: | |
588 pass | |
589 if pr_number: | 595 if pr_number: |
590 logger.info("<details>\n") | 596 logger.info("<details>\n") |
591 logger.info('<summary><a href="%s/%s%s">%s</a></summary>\n\n' % | 597 logger.info('<summary><a href="%s/%s%s">%s</a></summary>\n\n' % |
592 (baseurl, pr_number, test, test)) | 598 (baseurl, pr_number, test, test)) |
593 else: | 599 else: |
594 logger.info("### %s ###" % test) | 600 logger.info("### %s ###" % test) |
595 parent = test_results.pop(None) | 601 parent = test_results.pop(None) |
596 strings = [("", err_string(parent, iterations))] | 602 strings = [("", err_string(parent, iterations))] |
597 strings.extend(((("`%s`" % markdown_adjust(subtest)) if subtest | 603 strings.extend(((("`%s`" % markdown_adjust(subtest)) if subtest |
598 else "", err_string(results, iterations)) | 604 else "", err_string(results, iterations)) |
599 for subtest, results in test_results.iteritems())) | 605 for subtest, results in test_results.iteritems())) |
600 table(["Subtest", "Results"], strings, logger.info) | 606 table(["Subtest", "Results"], strings, logger.info) |
601 if pr_number: | 607 if pr_number: |
602 logger.info("</details>\n") | 608 logger.info("</details>\n") |
603 | 609 |
| 610 if pr_number: |
| 611 logger.info("</details>\n") |
| 612 |
604 | 613 |
605 def get_parser(): | 614 def get_parser(): |
606 """Create and return script-specific argument parser.""" | 615 """Create and return script-specific argument parser.""" |
607 parser = argparse.ArgumentParser() | 616 parser = argparse.ArgumentParser() |
608 parser.add_argument("--root", | 617 parser.add_argument("--root", |
609 action="store", | 618 action="store", |
610 default=os.path.join(os.path.expanduser("~"), "build"), | 619 default=os.path.join(os.path.expanduser("~"), "build"), |
611 help="Root path") | 620 help="Root path") |
612 parser.add_argument("--iterations", | 621 parser.add_argument("--iterations", |
613 action="store", | 622 action="store", |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 return retcode | 756 return retcode |
748 | 757 |
749 | 758 |
750 if __name__ == "__main__": | 759 if __name__ == "__main__": |
751 try: | 760 try: |
752 retcode = main() | 761 retcode = main() |
753 except: | 762 except: |
754 raise | 763 raise |
755 else: | 764 else: |
756 sys.exit(retcode) | 765 sys.exit(retcode) |
OLD | NEW |