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