def FindPriorSvnRev(path, goal): revs = proc.check_output( ['git', 'rev-list', 'origin/master'], cwd=path).splitlines() for rev in revs: num = proc.check_output( ['git', 'svn', 'find-rev', rev], cwd=path).strip() if int(num) <= goal: return rev raise Exception('Cannot find svn rev at or before %d' % goal)
def FindPriorSvnRev(path, goal): revs = proc.check_output( ['git', 'rev-list', RemoteBranch('master')], cwd=path).splitlines() for rev in revs: num = proc.check_output( ['git', 'svn', 'find-rev', rev], cwd=path).strip() if int(num) <= goal: return rev raise Exception('Cannot find svn rev at or before %d' % goal)
def Which(name): """Find an executable on the system by name. If not found return ''.""" # If we want to run this on Windows, we'll have to be smarter. try: o = proc.check_output(['which', name]) return o.strip() except proc.CalledProcessError: return ''
def FindPriorSvnRev(path, goal): revs = Git( ['rev-list', RemoteBranch('master')], cwd=path).splitlines() for rev in revs: num = proc.check_output( [sys.executable, FIND_SVN_REV, rev], cwd=path).strip() if int(num) <= goal: return rev raise Exception('Cannot find svn rev at or before %d' % goal)
def __call__(self, test_file): """Execute a single test.""" basename = os.path.basename(test_file) outfile = self.outname_ctor(self.outdir, test_file) if self.outdir else '' try: output = proc.check_output( self.command_ctor(test_file, outfile, self.extras), stderr=proc.STDOUT, cwd=self.outdir or os.getcwd(), preexec_fn=Tester.setlimits) # Flush the logged command so buildbots don't think the script is dead. sys.stdout.flush() return Result(test=basename, success=True, output=output) except proc.CalledProcessError as e: return Result(test=basename, success=False, output=e.output)
def CurrentGitInfo(self): def pretty(fmt): return proc.check_output( ['git', 'log', '-n1', '--pretty=format:%s' % fmt], cwd=self.src_dir).strip() remote = proc.check_output(['git', 'config', '--get', 'remote.origin.url'], cwd=self.src_dir).strip() return { 'hash': pretty('%H'), 'name': pretty('%aN'), 'email': pretty('%ae'), 'subject': pretty('%s'), 'remote': remote, }
def __call__(self, test_file): """Execute a single test.""" basename = os.path.basename(test_file) outfile = self.outname_ctor(self.outdir, test_file) if self.outdir else '' try: output = proc.check_output( self.command_ctor(test_file, outfile, self.extras), stderr=proc.STDOUT, cwd=self.outdir or os.getcwd(), # preexec_fn is not supported on Windows preexec_fn=Tester.setlimits if sys.platform != 'win32' else None) # Flush the logged command so buildbots don't think the script is dead. sys.stdout.flush() return Result(test=basename, success=True, output=output) except proc.CalledProcessError as e: return Result(test=basename, success=False, output=e.output)
def __call__(self, test_file): """Execute a single test.""" basename = os.path.basename(test_file) if self.outdir: outfile = self.outname_ctor(self.outdir, test_file, self.extras) else: outfile = '' try: output = proc.check_output( self.command_ctor(test_file, outfile, self.extras), stderr=proc.STDOUT, cwd=self.outdir or os.getcwd(), # preexec_fn is not supported on Windows preexec_fn=Tester.setlimits if sys.platform != 'win32' else None, should_log=False) return Result(test=basename, success=True, output=output) except proc.CalledProcessError as e: return Result(test=basename, success=False, output=e.output)
def CurrentGitInfo(self): if not self.src_dir: return None def pretty(fmt): return proc.check_output( ['git', 'log', '-n1', '--pretty=format:%s' % fmt], cwd=self.src_dir).strip() remote = proc.check_output( ['git', 'config', '--get', 'remote.origin.url'], cwd=self.src_dir).strip() return { 'hash': pretty('%H'), 'name': pretty('%aN'), 'email': pretty('%ae'), 'subject': pretty('%s'), 'remote': remote, }
def Gclient(cmd, **kwargs): """Invoke gclient.""" return proc.check_output( ['gclient'] + cmd, shell=sys.platform == 'win32', **kwargs)
def GitRemoteUrl(cwd, remote): """Get the URL of a remote.""" return proc.check_output(['git', 'config', '--get', 'remote.%s.url' % remote], cwd=cwd).strip()
def CurrentSvnRev(path): return int(proc.check_output( ['git', 'svn', 'find-rev', 'HEAD'], cwd=path).strip())
def pretty(fmt): return proc.check_output( ['git', 'log', '-n1', '--pretty=format:%s' % fmt], cwd=self.src_dir).strip()
def HasRemote(cwd, remote): """"Checked whether the named remote exists.""" remotes = proc.check_output(['git', 'remote'], cwd=cwd).strip().splitlines() return remote in remotes
def CurrentSvnRev(path): return int(proc.check_output( [sys.executable, FIND_SVN_REV, 'HEAD'], cwd=path).strip())