| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs all types of tests from one unified interface. | 7 """Runs all types of tests from one unified interface. |
| 8 | 8 |
| 9 TODO(gkanwar): | 9 TODO(gkanwar): |
| 10 * Add options to run Monkey tests. | 10 * Add options to run Monkey tests. |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 return '\nExample:\n %s\n' % self.example | 727 return '\nExample:\n %s\n' % self.example |
| 728 return '' | 728 return '' |
| 729 | 729 |
| 730 | 730 |
| 731 def main(argv): | 731 def main(argv): |
| 732 option_parser = CommandOptionParser( | 732 option_parser = CommandOptionParser( |
| 733 usage='Usage: %prog <command> [options]', | 733 usage='Usage: %prog <command> [options]', |
| 734 command_list=VALID_COMMANDS.keys()) | 734 command_list=VALID_COMMANDS.keys()) |
| 735 | 735 |
| 736 if len(argv) < 2 or argv[1] not in VALID_COMMANDS: | 736 if len(argv) < 2 or argv[1] not in VALID_COMMANDS: |
| 737 # Parse args first, if this is '--help', optparse will display help and exit |
| 738 option_parser.parse_args(argv) |
| 737 option_parser.error('Invalid command.') | 739 option_parser.error('Invalid command.') |
| 738 command = argv[1] | 740 command = argv[1] |
| 739 VALID_COMMANDS[command].add_options_func(option_parser) | 741 VALID_COMMANDS[command].add_options_func(option_parser) |
| 740 options, args = option_parser.parse_args(argv) | 742 options, args = option_parser.parse_args(argv) |
| 741 return VALID_COMMANDS[command].run_command_func( | 743 return VALID_COMMANDS[command].run_command_func( |
| 742 command, options, args, option_parser) | 744 command, options, args, option_parser) |
| 743 | 745 |
| 744 | 746 |
| 745 if __name__ == '__main__': | 747 if __name__ == '__main__': |
| 746 sys.exit(main(sys.argv)) | 748 sys.exit(main(sys.argv)) |
| OLD | NEW |