def testBuildPackages(self): parser = cbuildbot.CreateParser() argv = ['--buildroot', '/foo', '--buildbot', '--cbb_snapshot_revision', 'hash1234', '--cbb_build_packages', 'pkgA pkgB', 'caroline-postsubmit'] options = cbuildbot.ParseCommandLine(parser, argv) expected = ['pkgA', 'pkgB'] self.assertEqual(expected, options.cbb_build_packages) self.assertEqual('hash1234', options.cbb_snapshot_revision)
def PreParseArguments(argv): """Extract the branch name from cbuildbot command line arguments. Args: argv: The command line arguments to parse. Returns: Branch as a string ('master' if nothing is specified). """ parser = cbuildbot.CreateParser() options = cbuildbot.ParseCommandLine(parser, argv) options.Freeze() # This option isn't required for cbuildbot, but is for us. if not options.buildroot: cros_build_lib.Die('--buildroot is a required option.') return options
def Cbuildbot(buildroot, depot_tools_path, argv): """Start cbuildbot in specified directory with all arguments. Args: buildroot: Directory to be passed to cbuildbot with --buildroot. depot_tools_path: Directory for depot_tools to be used by cbuildbot. argv: Command line options passed to cbuildbot_launch. Returns: Return code of cbuildbot as an integer. """ logging.info('Bootstrap cbuildbot in: %s', buildroot) # Fixup buildroot parameter. argv = argv[:] for i, arg in enumerate(argv): if arg in ('-r', '--buildroot'): argv[i + 1] = buildroot # This filters out command line arguments not supported by older versions # of cbuildbot. parser = cbuildbot.CreateParser() options = cbuildbot.ParseCommandLine(parser, argv) cbuildbot_path = os.path.join(buildroot, 'chromite', 'bin', 'cbuildbot') cmd = sync_stages.BootstrapStage.FilterArgsForTargetCbuildbot( buildroot, cbuildbot_path, options) # We want cbuildbot to use branched depot_tools scripts from our manifest, # so that depot_tools is branched to match cbuildbot. logging.info('Adding depot_tools into PATH: %s', depot_tools_path) extra_env = {'PATH': PrependPath(depot_tools_path)} # TODO(crbug.com/845304): Remove once underlying boto issues are resolved. fix_boto = ShouldFixBotoCerts(options) with boto_compat.FixBotoCerts(activate=fix_boto): result = cros_build_lib.run(cmd, extra_env=extra_env, error_code_ok=True, cwd=buildroot) return result.returncode