def testSimpleTryJob(self, version=None): """Test that a tryjob spec file is created and pushed properly.""" self.mox.StubOutWithMock(repository, 'IsARepoRoot') repository.IsARepoRoot(mox.IgnoreArg()).AndReturn(True) self.mox.StubOutWithMock(repository, 'IsInternalRepoCheckout') repository.IsInternalRepoCheckout(mox.IgnoreArg()).AndReturn(False) self.mox.ReplayAll() try: os.environ["GIT_AUTHOR_EMAIL"] = "Elmer Fudd <*****@*****.**>" os.environ["GIT_COMMITTER_EMAIL"] = "Elmer Fudd <*****@*****.**>" job = self._CreateJob() finally: os.environ.pop("GIT_AUTHOR_EMAIL", None) os.environ.pop("GIT_COMMITTER_EMAIL", None) created_file = self._SubmitJob(self.checkout_dir, job, version=version) with open(created_file, 'rb') as job_desc_file: values = json.load(job_desc_file) self.assertTrue('*****@*****.**' in values['email'][0]) for patch in self.PATCHES: self.assertTrue(patch in values['extra_args'], msg="expected patch %s in args %s" % (patch, values['extra_args'])) self.assertTrue(set(self.BOTS).issubset(values['bot'])) remote_url = cros_build_lib.RunCommand( ['git', 'config', 'remote.origin.url'], redirect_stdout=True, cwd=self.checkout_dir).output.strip() self.assertEqual(remote_url, self.ext_mirror)
def testInternalRepoCheckout(self): """Test we detect internal checkouts properly.""" self.mox.StubOutWithMock(cros_build_lib, 'RunCommand') tests = [ 'ssh://gerrit-int.chromium.org:29419/chromeos/manifest-internal.git', 'ssh://gerrit-int.chromium.org:29419/chromeos/manifest-internal', 'ssh://gerrit.chromium.org:29418/chromeos/manifest-internal', '[email protected]:39291/bla/manifest-internal.git', ] for test in tests: cros_build_lib.RunCommand = functools.partial( self.RunCommand_Mock, test) self.assertTrue(repository.IsInternalRepoCheckout('.'))
def testInternalTryJob(self): """Verify internal tryjobs are pushed properly.""" self.mox.StubOutWithMock(repository, 'IsARepoRoot') repository.IsARepoRoot(mox.IgnoreArg()).AndReturn(True) self.mox.StubOutWithMock(repository, 'IsInternalRepoCheckout') repository.IsInternalRepoCheckout(mox.IgnoreArg()).AndReturn(True) self.mox.ReplayAll() job = self._CreateJob() self._SubmitJob(self.checkout_dir, job) remote_url = cros_build_lib.RunCommand( ['git', 'config', 'remote.origin.url'], redirect_stdout=True, cwd=self.checkout_dir).output.strip() self.assertEqual(remote_url, self.int_mirror)
def __init__(self, options, bots, local_patches): """Construct the object. Args: options: The parsed options passed into cbuildbot. bots: A list of configs to run tryjobs for. local_patches: A list of LocalPatch objects. """ self.options = options self.user = getpass.getuser() cwd = os.path.dirname(os.path.realpath(__file__)) self.user_email = git.GetProjectUserEmail(cwd) cros_build_lib.Info('Using email:%s', self.user_email) # Name of the job that appears on the waterfall. patch_list = options.gerrit_patches + options.local_patches self.name = options.remote_description if self.name is None: self.name = '' if options.branch != 'master': self.name = '[%s] ' % options.branch self.name += ','.join(patch_list) self.bots = bots[:] self.slaves_request = options.slaves self.description = ('name: %s\n patches: %s\nbots: %s' % (self.name, patch_list, self.bots)) self.extra_args = options.pass_through_args if '--buildbot' not in self.extra_args: self.extra_args.append('--remote-trybot') self.extra_args.append('--remote-version=%s' % (self.TRYJOB_FORMAT_VERSION,)) self.tryjob_repo = None self.local_patches = local_patches self.ssh_url = self.EXT_SSH_URL self.manifest = None if repository.IsARepoRoot(options.sourceroot): self.manifest = git.ManifestCheckout.Cached(options.sourceroot) if repository.IsInternalRepoCheckout(options.sourceroot): self.ssh_url = self.INT_SSH_URL