| OLD | NEW |
| 1 import argparse | 1 import argparse |
| 2 import json | 2 import json |
| 3 import logging | 3 import logging |
| 4 import os | 4 import os |
| 5 import re | 5 import re |
| 6 import stat | 6 import stat |
| 7 import subprocess | 7 import subprocess |
| 8 import sys | 8 import sys |
| 9 import tarfile | 9 import tarfile |
| 10 import traceback | 10 import traceback |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 handler = LogHandler() | 395 handler = LogHandler() |
| 396 reader.handle_log(reader.read(log), handler) | 396 reader.handle_log(reader.read(log), handler) |
| 397 results = handler.results | 397 results = handler.results |
| 398 for test, test_results in results.iteritems(): | 398 for test, test_results in results.iteritems(): |
| 399 for subtest, result in test_results.iteritems(): | 399 for subtest, result in test_results.iteritems(): |
| 400 if is_inconsistent(result, iterations): | 400 if is_inconsistent(result, iterations): |
| 401 inconsistent.append((test, subtest, result)) | 401 inconsistent.append((test, subtest, result)) |
| 402 return results, inconsistent | 402 return results, inconsistent |
| 403 | 403 |
| 404 | 404 |
| 405 def markdown_adjust(s): |
| 406 s = s.replace('\t', u'\\t') |
| 407 s = s.replace('\n', u'\\n') |
| 408 s = s.replace('\r', u'\\r') |
| 409 s = s.replace('`', u'\\`') |
| 410 return s |
| 411 |
| 412 |
| 405 def table(headings, data, log): | 413 def table(headings, data, log): |
| 406 cols = range(len(headings)) | 414 cols = range(len(headings)) |
| 407 assert all(len(item) == len(cols) for item in data) | 415 assert all(len(item) == len(cols) for item in data) |
| 408 max_widths = reduce(lambda prev, cur: [(len(cur[i]) + 2) | 416 max_widths = reduce(lambda prev, cur: [(len(cur[i]) + 2) |
| 409 if (len(cur[i]) + 2) > prev[i] | 417 if (len(cur[i]) + 2) > prev[i] |
| 410 else prev[i] | 418 else prev[i] |
| 411 for i in cols], | 419 for i in cols], |
| 412 data, | 420 data, |
| 413 [len(item) + 2 for item in headings]) | 421 [len(item) + 2 for item in headings]) |
| 414 log("|%s|" % "|".join(item.center(max_widths[i]) for i, item in enumerate(he
adings))) | 422 log("|%s|" % "|".join(item.center(max_widths[i]) for i, item in enumerate(he
adings))) |
| 415 log("|%s|" % "|".join("-" * max_widths[i] for i in cols)) | 423 log("|%s|" % "|".join("-" * max_widths[i] for i in cols)) |
| 416 for row in data: | 424 for row in data: |
| 417 log("|%s|" % "|".join(" %s" % row[i].ljust(max_widths[i] - 1) for i in c
ols)) | 425 log("|%s|" % "|".join(" %s" % row[i].ljust(max_widths[i] - 1) for i in c
ols)) |
| 418 log("") | 426 log("") |
| 419 | 427 |
| 420 | 428 |
| 421 def write_inconsistent(inconsistent, iterations): | 429 def write_inconsistent(inconsistent, iterations): |
| 422 logger.error("## Unstable results ##\n") | 430 logger.error("## Unstable results ##\n") |
| 423 strings = [(test, subtest if subtest else "", err_string(results, iterations
)) | 431 strings = [("`%s`" % markdown_adjust(test), ("`%s`" % markdown_adjust(subtes
t)) if subtest else "", err_string(results, iterations)) |
| 424 for test, subtest, results in inconsistent] | 432 for test, subtest, results in inconsistent] |
| 425 table(["Test", "Subtest", "Results"], strings, logger.error) | 433 table(["Test", "Subtest", "Results"], strings, logger.error) |
| 426 | 434 |
| 427 | 435 |
| 428 def write_results(results, iterations, comment_pr): | 436 def write_results(results, iterations, comment_pr): |
| 429 logger.info("## All results ##\n") | 437 logger.info("## All results ##\n") |
| 430 for test, test_results in results.iteritems(): | 438 for test, test_results in results.iteritems(): |
| 431 baseurl = "http://w3c-test.org/submissions" | 439 baseurl = "http://w3c-test.org/submissions" |
| 432 if "https" in os.path.splitext(test)[0].split(".")[1:]: | 440 if "https" in os.path.splitext(test)[0].split(".")[1:]: |
| 433 baseurl = "https://w3c-test.org/submissions" | 441 baseurl = "https://w3c-test.org/submissions" |
| 434 pr_number = None | 442 pr_number = None |
| 435 if comment_pr: | 443 if comment_pr: |
| 436 try: | 444 try: |
| 437 pr_number = int(comment_pr) | 445 pr_number = int(comment_pr) |
| 438 except ValueError: | 446 except ValueError: |
| 439 pass | 447 pass |
| 440 if pr_number: | 448 if pr_number: |
| 441 logger.info("### [%s](%s/%s%s) ###" % (test, baseurl, pr_number, tes
t)) | 449 logger.info("### [%s](%s/%s%s) ###" % (test, baseurl, pr_number, tes
t)) |
| 442 else: | 450 else: |
| 443 logger.info("### %s ###" % test) | 451 logger.info("### %s ###" % test) |
| 444 parent = test_results.pop(None) | 452 parent = test_results.pop(None) |
| 445 strings = [("", err_string(parent, iterations))] | 453 strings = [("", err_string(parent, iterations))] |
| 446 strings.extend(((subtest if subtest else "", err_string(results, iterati
ons)) | 454 strings.extend(((("`%s`" % markdown_adjust(subtest)) if subtest else "",
err_string(results, iterations)) |
| 447 for subtest, results in test_results.iteritems())) | 455 for subtest, results in test_results.iteritems())) |
| 448 table(["Subtest", "Results"], strings, logger.info) | 456 table(["Subtest", "Results"], strings, logger.info) |
| 449 | 457 |
| 450 | 458 |
| 451 def get_parser(): | 459 def get_parser(): |
| 452 parser = argparse.ArgumentParser() | 460 parser = argparse.ArgumentParser() |
| 453 parser.add_argument("--root", | 461 parser.add_argument("--root", |
| 454 action="store", | 462 action="store", |
| 455 default=os.path.join(os.path.expanduser("~"), "build"), | 463 default=os.path.join(os.path.expanduser("~"), "build"), |
| 456 help="Root path") | 464 help="Root path") |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 return retcode | 581 return retcode |
| 574 | 582 |
| 575 | 583 |
| 576 if __name__ == "__main__": | 584 if __name__ == "__main__": |
| 577 try: | 585 try: |
| 578 retcode = main() | 586 retcode = main() |
| 579 except: | 587 except: |
| 580 raise | 588 raise |
| 581 else: | 589 else: |
| 582 sys.exit(retcode) | 590 sys.exit(retcode) |
| OLD | NEW |