Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2522 return 0 | 2522 return 0 |
| 2523 | 2523 |
| 2524 | 2524 |
| 2525 def CMDtry(parser, args): | 2525 def CMDtry(parser, args): |
| 2526 """Triggers a try job through Rietveld.""" | 2526 """Triggers a try job through Rietveld.""" |
| 2527 group = optparse.OptionGroup(parser, "Try job options") | 2527 group = optparse.OptionGroup(parser, "Try job options") |
| 2528 group.add_option( | 2528 group.add_option( |
| 2529 "-b", "--bot", action="append", | 2529 "-b", "--bot", action="append", |
| 2530 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " | 2530 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " |
| 2531 "times to specify multiple builders. ex: " | 2531 "times to specify multiple builders. ex: " |
| 2532 "'-b win_rel:ui_tests,webkit_unit_tests -b win_layout'. See " | 2532 "'-b win_rel -b win_layout'. See " |
| 2533 "the try server waterfall for the builders name and the tests " | 2533 "the try server waterfall for the builders name and the tests " |
| 2534 "available. Can also be used to specify gtest_filter, e.g. " | 2534 "available.")) |
| 2535 "-b win_rel:base_unittests:ValuesTest.*Value")) | |
| 2536 group.add_option( | 2535 group.add_option( |
| 2537 "-m", "--master", default='', | 2536 "-m", "--master", default='', |
| 2538 help=("Specify a try master where to run the tries.")) | 2537 help=("Specify a try master where to run the tries.")) |
| 2539 group.add_option( | 2538 group.add_option( |
| 2540 "-r", "--revision", | 2539 "-r", "--revision", |
| 2541 help="Revision to use for the try job; default: the " | 2540 help="Revision to use for the try job; default: the " |
| 2542 "revision will be determined by the try server; see " | 2541 "revision will be determined by the try server; see " |
| 2543 "its waterfall for more info") | 2542 "its waterfall for more info") |
| 2544 group.add_option( | 2543 group.add_option( |
| 2545 "-c", "--clobber", action="store_true", default=False, | 2544 "-c", "--clobber", action="store_true", default=False, |
| 2546 help="Force a clobber before building; e.g. don't do an " | 2545 help="Force a clobber before building; e.g. don't do an " |
| 2547 "incremental build") | 2546 "incremental build") |
| 2548 group.add_option( | 2547 group.add_option( |
| 2549 "--project", | 2548 "--project", |
| 2550 help="Override which project to use. Projects are defined " | 2549 help="Override which project to use. Projects are defined " |
| 2551 "server-side to define what default bot set to use") | 2550 "server-side to define what default bot set to use") |
| 2552 group.add_option( | 2551 group.add_option( |
| 2553 "-t", "--testfilter", action="append", default=[], | |
| 2554 help=("Apply a testfilter to all the selected builders. Unless the " | |
| 2555 "builders configurations are similar, use multiple " | |
| 2556 "--bot <builder>:<test> arguments.")) | |
| 2557 group.add_option( | |
| 2558 "-n", "--name", help="Try job name; default to current branch name") | 2552 "-n", "--name", help="Try job name; default to current branch name") |
| 2559 parser.add_option_group(group) | 2553 parser.add_option_group(group) |
| 2560 options, args = parser.parse_args(args) | 2554 options, args = parser.parse_args(args) |
| 2561 | 2555 |
| 2562 if args: | 2556 if args: |
| 2563 parser.error('Unknown arguments: %s' % args) | 2557 parser.error('Unknown arguments: %s' % args) |
| 2564 | 2558 |
| 2565 cl = Changelist() | 2559 cl = Changelist() |
| 2566 if not cl.GetIssue(): | 2560 if not cl.GetIssue(): |
| 2567 parser.error('Need to upload first') | 2561 parser.error('Need to upload first') |
| 2568 | 2562 |
| 2569 props = cl.GetIssueProperties() | 2563 props = cl.GetIssueProperties() |
| 2570 if props.get('closed'): | 2564 if props.get('closed'): |
| 2571 parser.error('Cannot send tryjobs for a closed CL') | 2565 parser.error('Cannot send tryjobs for a closed CL') |
| 2572 | 2566 |
| 2573 if props.get('private'): | 2567 if props.get('private'): |
| 2574 parser.error('Cannot use trybots with private issue') | 2568 parser.error('Cannot use trybots with private issue') |
| 2575 | 2569 |
| 2576 if not options.name: | 2570 if not options.name: |
| 2577 options.name = cl.GetBranch() | 2571 options.name = cl.GetBranch() |
| 2578 | 2572 |
| 2579 if options.bot and not options.master: | 2573 if options.bot and not options.master: |
| 2580 options.master, err_msg = GetBuilderMaster(options.bot) | 2574 options.master, err_msg = GetBuilderMaster(options.bot) |
| 2581 if err_msg: | 2575 if err_msg: |
| 2582 parser.error('Tryserver master cannot be found because: %s\n' | 2576 parser.error('Tryserver master cannot be found because: %s\n' |
| 2583 'Please manually specify the tryserver master' | 2577 'Please manually specify the tryserver master' |
| 2584 ', e.g. "-m tryserver.chromium.linux".' % err_msg) | 2578 ', e.g. "-m tryserver.chromium.linux".' % err_msg) |
| 2585 | 2579 |
| 2586 def GetMasterMap(): | 2580 def GetMasterMap(): |
| 2587 # Process --bot and --testfilter. | 2581 # Process --bot. |
| 2588 if not options.bot: | 2582 if not options.bot: |
| 2589 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) | 2583 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) |
| 2590 | 2584 |
| 2591 # Get try masters from PRESUBMIT.py files. | 2585 # Get try masters from PRESUBMIT.py files. |
| 2592 masters = presubmit_support.DoGetTryMasters( | 2586 masters = presubmit_support.DoGetTryMasters( |
| 2593 change, | 2587 change, |
| 2594 change.LocalPaths(), | 2588 change.LocalPaths(), |
| 2595 settings.GetRoot(), | 2589 settings.GetRoot(), |
| 2596 None, | 2590 None, |
| 2597 None, | 2591 None, |
| 2598 options.verbose, | 2592 options.verbose, |
| 2599 sys.stdout) | 2593 sys.stdout) |
| 2600 if masters: | 2594 if masters: |
| 2601 return masters | 2595 return masters |
| 2602 | 2596 |
| 2603 # Fall back to deprecated method: get try slaves from PRESUBMIT.py files. | 2597 # Fall back to deprecated method: get try slaves from PRESUBMIT.py files. |
|
M-A Ruel
2015/01/21 14:23:53
Why not remove this too?
Paweł Hajdan Jr.
2015/01/21 14:36:18
I'm concerned we may have repos which still use it
M-A Ruel
2015/01/21 14:48:38
That's true.
| |
| 2604 options.bot = presubmit_support.DoGetTrySlaves( | 2598 options.bot = presubmit_support.DoGetTrySlaves( |
| 2605 change, | 2599 change, |
| 2606 change.LocalPaths(), | 2600 change.LocalPaths(), |
| 2607 settings.GetRoot(), | 2601 settings.GetRoot(), |
| 2608 None, | 2602 None, |
| 2609 None, | 2603 None, |
| 2610 options.verbose, | 2604 options.verbose, |
| 2611 sys.stdout) | 2605 sys.stdout) |
| 2612 if not options.bot: | 2606 if not options.bot: |
| 2613 parser.error('No default try builder to try, use --bot') | 2607 parser.error('No default try builder to try, use --bot') |
| 2614 | 2608 |
| 2615 builders_and_tests = {} | 2609 builders_and_tests = {} |
| 2616 # TODO(machenbach): The old style command-line options don't support | 2610 # TODO(machenbach): The old style command-line options don't support |
| 2617 # multiple try masters yet. | 2611 # multiple try masters yet. |
| 2618 old_style = filter(lambda x: isinstance(x, basestring), options.bot) | 2612 old_style = filter(lambda x: isinstance(x, basestring), options.bot) |
| 2619 new_style = filter(lambda x: isinstance(x, tuple), options.bot) | 2613 new_style = filter(lambda x: isinstance(x, tuple), options.bot) |
| 2620 | 2614 |
| 2621 for bot in old_style: | 2615 for bot in old_style: |
| 2622 if ':' in bot: | 2616 if ':' in bot: |
| 2623 builder, tests = bot.split(':', 1) | 2617 parser.error('Specifying testfilter is no longer supported') |
| 2624 builders_and_tests.setdefault(builder, []).extend(tests.split(',')) | |
| 2625 elif ',' in bot: | 2618 elif ',' in bot: |
| 2626 parser.error('Specify one bot per --bot flag') | 2619 parser.error('Specify one bot per --bot flag') |
| 2627 else: | 2620 else: |
| 2628 builders_and_tests.setdefault(bot, []).append('defaulttests') | 2621 builders_and_tests.setdefault(bot, []).append('defaulttests') |
| 2629 | 2622 |
| 2630 for bot, tests in new_style: | 2623 for bot, tests in new_style: |
| 2631 builders_and_tests.setdefault(bot, []).extend(tests) | 2624 builders_and_tests.setdefault(bot, []).extend(tests) |
| 2632 | 2625 |
| 2633 # Return a master map with one master to be backwards compatible. The | 2626 # Return a master map with one master to be backwards compatible. The |
| 2634 # master name defaults to an empty string, which will cause the master | 2627 # master name defaults to an empty string, which will cause the master |
| 2635 # not to be set on rietveld (deprecated). | 2628 # not to be set on rietveld (deprecated). |
| 2636 return {options.master: builders_and_tests} | 2629 return {options.master: builders_and_tests} |
| 2637 | 2630 |
| 2638 masters = GetMasterMap() | 2631 masters = GetMasterMap() |
| 2639 | 2632 |
| 2640 if options.testfilter: | |
| 2641 forced_tests = sum((t.split(',') for t in options.testfilter), []) | |
| 2642 masters = dict((master, dict( | |
| 2643 (b, forced_tests) for b, t in slaves.iteritems() | |
| 2644 if t != ['compile'])) for master, slaves in masters.iteritems()) | |
| 2645 | |
| 2646 for builders in masters.itervalues(): | 2633 for builders in masters.itervalues(): |
| 2647 if any('triggered' in b for b in builders): | 2634 if any('triggered' in b for b in builders): |
| 2648 print >> sys.stderr, ( | 2635 print >> sys.stderr, ( |
| 2649 'ERROR You are trying to send a job to a triggered bot. This type of' | 2636 'ERROR You are trying to send a job to a triggered bot. This type of' |
| 2650 ' bot requires an\ninitial job from a parent (usually a builder). ' | 2637 ' bot requires an\ninitial job from a parent (usually a builder). ' |
| 2651 'Instead send your job to the parent.\n' | 2638 'Instead send your job to the parent.\n' |
| 2652 'Bot list: %s' % builders) | 2639 'Bot list: %s' % builders) |
| 2653 return 1 | 2640 return 1 |
| 2654 | 2641 |
| 2655 patchset = cl.GetMostRecentPatchset() | 2642 patchset = cl.GetMostRecentPatchset() |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2947 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2934 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2948 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2935 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2949 | 2936 |
| 2950 | 2937 |
| 2951 if __name__ == '__main__': | 2938 if __name__ == '__main__': |
| 2952 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2939 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2953 # unit testing. | 2940 # unit testing. |
| 2954 fix_encoding.fix_encoding() | 2941 fix_encoding.fix_encoding() |
| 2955 colorama.init() | 2942 colorama.init() |
| 2956 sys.exit(main(sys.argv[1:])) | 2943 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |