diff options
author | Don Garrett <dgarrett@google.com> | 2015-06-30 17:55:10 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-07-06 20:06:45 +0000 |
commit | 0a873e0922f3e2a375c8445875e47fecb5ea4c1b (patch) | |
tree | e9963c59c7be419364152f83a97effe8e7cb73d5 /scripts | |
parent | 4e8e2c4ed39dff8f14a7b0adc02aa059b2835d33 (diff) | |
download | chromite-0a873e0922f3e2a375c8445875e47fecb5ea4c1b.tar.gz |
cbuildbot: Remove site_config from arg parsing.
If we plan to use command line arguments to fetch the site_config,
then we need to parse those options without a site_config. Rearrange
existing code to do that.
BUG=chromium:497284
TEST=Unittests.
Change-Id: I4106fd44781e48e1740a988f383c2d856fb3dfa0
Reviewed-on: https://chromium-review.googlesource.com/282786
Trybot-Ready: Don Garrett <dgarrett@chromium.org>
Tested-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Matthew Sartori <msartori@chromium.org>
Commit-Queue: Don Garrett <dgarrett@chromium.org>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/cbuildbot.py | 22 | ||||
-rw-r--r-- | scripts/cbuildbot_unittest.py | 5 |
2 files changed, 11 insertions, 16 deletions
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py index 1a0a063e3..bee84f06c 100644 --- a/scripts/cbuildbot.py +++ b/scripts/cbuildbot.py @@ -843,6 +843,10 @@ def _PostParseCheck(parser, options, args, site_config): args: The args returned by optparse. site_config: config_lib.SiteConfig containing all config info. """ + if not args: + parser.error('Invalid usage: no configuration targets provided.' + 'Use -h to see usage. Use -l to list supported configs.') + if not options.branch: options.branch = git.GetChromiteTrackingBranch() @@ -923,7 +927,7 @@ def _PostParseCheck(parser, options, args, site_config): '`cbuildbot --list --all`') -def _ParseCommandLine(parser, argv, site_config): +def _ParseCommandLine(parser, argv): """Completely parse the commandline arguments""" (options, args) = parser.parse_args(argv) @@ -936,16 +940,6 @@ def _ParseCommandLine(parser, argv, site_config): print(constants.REEXEC_API_VERSION) sys.exit(0) - if options.list: - if args: - cros_build_lib.Die('No arguments expected with the --list options.') - _PrintValidConfigs(site_config, options.print_all) - sys.exit(0) - - if not args: - parser.error('Invalid usage: no configuration targets provided.' - 'Use -h to see usage. Use -l to list supported configs.') - _FinishParsing(options, args) return options, args @@ -1041,7 +1035,11 @@ def main(argv): os.umask(0o22) parser = _CreateParser() - (options, args) = _ParseCommandLine(parser, argv, site_config) + options, args = _ParseCommandLine(parser, argv) + + if options.list: + _PrintValidConfigs(site_config, options.print_all) + sys.exit(0) _PostParseCheck(parser, options, args, site_config) diff --git a/scripts/cbuildbot_unittest.py b/scripts/cbuildbot_unittest.py index 177c9eee0..ed368813b 100644 --- a/scripts/cbuildbot_unittest.py +++ b/scripts/cbuildbot_unittest.py @@ -6,7 +6,6 @@ from __future__ import print_function -from chromite.cbuildbot import config_lib_unittest from chromite.cbuildbot import constants from chromite.lib import cros_test_lib from chromite.scripts import cbuildbot @@ -18,11 +17,9 @@ class IsDistributedBuilderTest(cros_test_lib.TestCase): # pylint: disable=W0212 def testIsDistributedBuilder(self): """Tests for _IsDistributedBuilder() under various configurations.""" - site_config = config_lib_unittest.MockSiteConfig() - parser = cbuildbot._CreateParser() argv = ['x86-generic-paladin'] - (options, _) = cbuildbot._ParseCommandLine(parser, argv, site_config) + (options, _) = cbuildbot._ParseCommandLine(parser, argv) options.buildbot = False options.pre_cq = False |