| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Compare the artifacts from two builds.""" | 6 """Compare the artifacts from two builds.""" |
| 7 | 7 |
| 8 import difflib | 8 import difflib |
| 9 import json | 9 import json |
| 10 import optparse | 10 import optparse |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 print >> sys.stderr, ('not support abs path %s used for target %s' | 537 print >> sys.stderr, ('not support abs path %s used for target %s' |
| 538 % (path, target)) | 538 % (path, target)) |
| 539 continue | 539 continue |
| 540 files.append(path) | 540 files.append(path) |
| 541 return files | 541 return files |
| 542 | 542 |
| 543 | 543 |
| 544 def compare_deps(first_dir, second_dir, targets): | 544 def compare_deps(first_dir, second_dir, targets): |
| 545 """Print difference of dependent files.""" | 545 """Print difference of dependent files.""" |
| 546 for target in targets: | 546 for target in targets: |
| 547 print 'Checking %s difference:' % target | |
| 548 first_deps = get_deps(first_dir, target) | 547 first_deps = get_deps(first_dir, target) |
| 549 second_deps =get_deps(second_dir, target) | 548 second_deps = get_deps(second_dir, target) |
| 549 print 'Checking %s difference: (%s deps)' % (target, len(first_deps)) |
| 550 if set(first_deps) != set(second_deps): | 550 if set(first_deps) != set(second_deps): |
| 551 # Since we do not thiks this case occur, we do not do anything special | 551 # Since we do not thiks this case occur, we do not do anything special |
| 552 # for this case. | 552 # for this case. |
| 553 print 'deps on %s are different: %s' % ( | 553 print 'deps on %s are different: %s' % ( |
| 554 target, set(first_deps).symmetric_difference(set(second_deps))) | 554 target, set(first_deps).symmetric_difference(set(second_deps))) |
| 555 continue | 555 continue |
| 556 max_filepath_len = max(len(n) for n in first_deps) |
| 556 for d in first_deps: | 557 for d in first_deps: |
| 557 first_file = os.path.join(first_dir, d) | 558 first_file = os.path.join(first_dir, d) |
| 558 second_file = os.path.join(second_dir, d) | 559 second_file = os.path.join(second_dir, d) |
| 559 compare_files(first_file, second_file) | 560 result = compare_files(first_file, second_file) |
| 561 if result: |
| 562 print('%-*s: %s' % (max_filepath_len, d, result)) |
| 560 | 563 |
| 561 | 564 |
| 562 def compare_build_artifacts(first_dir, second_dir, target_platform, | 565 def compare_build_artifacts(first_dir, second_dir, target_platform, |
| 563 recursive=False): | 566 recursive=False): |
| 564 """Compares the artifacts from two distinct builds.""" | 567 """Compares the artifacts from two distinct builds.""" |
| 565 if not os.path.isdir(first_dir): | 568 if not os.path.isdir(first_dir): |
| 566 print >> sys.stderr, '%s isn\'t a valid directory.' % first_dir | 569 print >> sys.stderr, '%s isn\'t a valid directory.' % first_dir |
| 567 return 1 | 570 return 1 |
| 568 if not os.path.isdir(second_dir): | 571 if not os.path.isdir(second_dir): |
| 569 print >> sys.stderr, '%s isn\'t a valid directory.' % second_dir | 572 print >> sys.stderr, '%s isn\'t a valid directory.' % second_dir |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 parser.error('--target-platform is required') | 658 parser.error('--target-platform is required') |
| 656 | 659 |
| 657 return compare_build_artifacts(os.path.abspath(options.first_build_dir), | 660 return compare_build_artifacts(os.path.abspath(options.first_build_dir), |
| 658 os.path.abspath(options.second_build_dir), | 661 os.path.abspath(options.second_build_dir), |
| 659 options.target_platform, | 662 options.target_platform, |
| 660 options.recursive) | 663 options.recursive) |
| 661 | 664 |
| 662 | 665 |
| 663 if __name__ == '__main__': | 666 if __name__ == '__main__': |
| 664 sys.exit(main()) | 667 sys.exit(main()) |
| OLD | NEW |