rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if exclude is not None and exclude(name):
head, tail = os.path.split(name) if tail in ('.svn', '.git'):
def add(self, name, arcname=None, recursive=True, exclude=None): if exclude is not None and exclude(name): return tarfile.TarFile.add(self, name, arcname=arcname, recursive=recursive)
def ShouldExcludePath(path): head, tail = os.path.split(path) if tail in ('.svn', '.git'): return True if not options.remove_nonessential_files: return False for nonessential_dir in NONESSENTIAL_DIRS: if path.startswith(os.path.join(GetSourceDirectory(), nonessential_dir)): return True return False
def ShouldExcludePath(path): head, tail = os.path.split(path) if tail in ('.svn', '.git'): return True
archive.add(GetSourceDirectory(), arcname=output_basename, exclude=ShouldExcludePath)
archive.add(GetSourceDirectory(), arcname=output_basename)
def ShouldExcludePath(path): head, tail = os.path.split(path) if tail in ('.svn', '.git'): return True
def port_fallbacks(): """Get the port fallback information. Returns: A dictionary mapping platform name to a list of other platforms to fall back on. All platforms fall back on 'base'. """ fallbacks = {_BASE_PLATFORM: []} for port_name in os.listdir(os.path.join('LayoutTests', 'platform')): try: platforms = port_facto...
class MockExecutive(object): last_run_command = [] response = '' class Executive(object): def run_command(self, args, cwd=None, input=None, error_handler=None, return_exit_code=False, return_stderr=True, decode_output=True): MockExecutive.last_run_command += [args] return MockExecutive.response
def port_fallbacks(): """Get the port fallback information. Returns: A dictionary mapping platform name to a list of other platforms to fall back on. All platforms fall back on 'base'. """ fallbacks = {_BASE_PLATFORM: []} for port_name in os.listdir(os.path.join('LayoutTests', 'platform')): try: platforms = port_facto...
def parse_git_output(git_output, glob_pattern): """Parses the output of git ls-tree and filters based on glob_pattern. Args: git_output: result of git ls-tree -r HEAD LayoutTests. glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """ hashes = collections....
class ListDuplicatesTest(unittest.TestCase): def setUp(self): MockExecutive.last_run_command = [] MockExecutive.response = '' deduplicate_tests.executive = MockExecutive
def parse_git_output(git_output, glob_pattern): """Parses the output of git ls-tree and filters based on glob_pattern. Args: git_output: result of git ls-tree -r HEAD LayoutTests. glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """ hashes = collections....
def cluster_file_hashes(glob_pattern): """Get the hashes of all the test expectations in the tree. We cheat and use git's hashes. Args: glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """
hashes = deduplicate_tests.parse_git_output(git_output, '*.png') expected = {('animage.png', 'abcdebc762e3aec5df03b5c04485b2cb3b65ffb1'): set(['platform/chromium-linux/animage.png', 'platform/chromium-win/animage.png'])} self.assertEquals(expected, hashes)
def cluster_file_hashes(glob_pattern): """Get the hashes of all the test expectations in the tree. We cheat and use git's hashes. Args: glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """ # A map of file hash => set of all files with that hash. hashes ...
hashes = collections.defaultdict(set)
def test_extract_platforms(self): self.assertEquals({'foo': 'platform/foo/bar', 'zoo': 'platform/zoo/com'}, deduplicate_tests.extract_platforms(['platform/foo/bar', 'platform/zoo/com'])) self.assertEquals({'foo': 'platform/foo/bar', deduplicate_tests._BASE_PLATFORM: 'what/'}, deduplicate_tests.extract_platforms(['platf...
def cluster_file_hashes(glob_pattern): """Get the hashes of all the test expectations in the tree. We cheat and use git's hashes. Args: glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """ # A map of file hash => set of all files with that hash. hashes ...
cmd = ('git', 'ls-tree', '-r', 'HEAD', 'LayoutTests') try: git_output = executive.Executive().run_command(cmd) except OSError, e: if e.errno == 2: _log.error("Error: 'No such file' when running git.") _log.error("This script requires git.") sys.exit(1) raise e return parse_git_output(git_output, glob_pattern)
def test_unique(self): MockExecutive.response = ( '100644 blob 5053240b3353f6eb39f7cb00259785f16d121df2\tLayoutTests/mac/foo-expected.txt\n' '100644 blob a004548d107ecc4e1ea08019daf0a14e8634a1ff\tLayoutTests/platform/chromium/foo-expected.txt\n' '100644 blob abcd0bc762e3aec5df03b5c04485b2cb3b65ffb1\tLayoutTests/platfor...
def cluster_file_hashes(glob_pattern): """Get the hashes of all the test expectations in the tree. We cheat and use git's hashes. Args: glob_pattern: a pattern to filter the files. Returns: A dictionary mapping (test name, hash of content) => [paths] """ # A map of file hash => set of all files with that hash. hashes ...
def extract_platforms(paths): """Extracts the platforms from a list of paths matching ^platform/(.*?)/. Args: paths: a list of paths. Returns: A dictionary containing all platforms from paths. """ platforms = {} for path in paths: match = re.match(r'^platform/(.*?)/', path) if match: platform = match.group(1) else: pla...
result = deduplicate_tests.deduplicate('*') self.assertEquals(1, len(MockExecutive.last_run_command)) self.assertEquals(('git', 'ls-tree', '-r', 'HEAD', 'LayoutTests'), MockExecutive.last_run_command[-1]) self.assertEquals(2, len(result)) self.assertEquals({'test': 'animage.png', 'path': 'platform/chromium-linux/animag...
def extract_platforms(paths): """Extracts the platforms from a list of paths matching ^platform/(.*?)/. Args: paths: a list of paths. Returns: A dictionary containing all platforms from paths. """ platforms = {} for path in paths: match = re.match(r'^platform/(.*?)/', path) if match: platform = match.group(1) else: pla...
def find_dups(hashes, port_fallbacks): """Yields info about redundant test expectations. Args: hashes: a list of hashes as returned by cluster_file_hashes. port_fallbacks: a list of fallback information as returned by get_port_fallbacks. Returns: a tuple containing (test, platform, fallback, platforms) """ for (test, h...
result = deduplicate_tests.deduplicate('*.png') self.assertEquals(3, len(MockExecutive.last_run_command)) self.assertEquals(('git', 'ls-tree', '-r', 'HEAD', 'LayoutTests'), MockExecutive.last_run_command[-1]) self.assertEquals(1, len(result)) self.assertEquals({'test': 'animage.png', 'path': 'platform/chromium-linux/an...
def find_dups(hashes, port_fallbacks): """Yields info about redundant test expectations. Args: hashes: a list of hashes as returned by cluster_file_hashes. port_fallbacks: a list of fallback information as returned by get_port_fallbacks. Returns: a tuple containing (test, platform, fallback, platforms) """ for (test, h...
print run_command(self.status_command(), error_handler=Executive.ignore_error)
print self.run(self.status_command(), error_handler=Executive.ignore_error)
def ensure_clean_working_directory(self, force_clean): if not force_clean and not self.working_directory_is_clean(): # FIXME: Shouldn't this use cwd=self.checkout_root? print run_command(self.status_command(), error_handler=Executive.ignore_error) raise ScriptError(message="Working directory has modifications, pass --f...
for line in run_command(status_command, cwd=self.checkout_root).splitlines():
for line in self.run(status_command, cwd=self.checkout_root).splitlines():
def run_status_and_extract_filenames(self, status_command, status_regexp): filenames = [] # We run with cwd=self.checkout_root so that returned-paths are root-relative. for line in run_command(status_command, cwd=self.checkout_root).splitlines(): match = re.search(status_regexp, line) if not match: continue # status = ...
find_output = run_command(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip()
find_output = self.run(find_args, cwd=home_directory, error_handler=Executive.ignore_error).rstrip()
def has_authorization_for_realm(self, realm=svn_server_realm, home_directory=os.getenv("HOME")): # Assumes find and grep are installed. if not os.path.isdir(os.path.join(home_directory, ".subversion")): return False find_args = ["find", ".subversion", "-type", "f", "-exec", "grep", "-q", realm, "{}", ";", "-print"]; fi...
self.cached_version = run_command(['svn', '--version', '--quiet'])
self.cached_version = self.run(['svn', '--version', '--quiet'])
def svn_version(self): if not self.cached_version: self.cached_version = run_command(['svn', '--version', '--quiet']) return self.cached_version
return run_command(["svn", "diff"], cwd=self.checkout_root, decode_output=False) == ""
return self.run(["svn", "diff"], cwd=self.checkout_root, decode_output=False) == ""
def working_directory_is_clean(self): return run_command(["svn", "diff"], cwd=self.checkout_root, decode_output=False) == ""
run_command(["svn", "revert", "-R", "."], cwd=self.checkout_root)
self.run(["svn", "revert", "-R", "."], cwd=self.checkout_root)
def clean_working_directory(self): # svn revert -R is not as awesome as git reset --hard. # It will leave added files around, causing later svn update # calls to fail on the bots. We make this mirror git reset --hard # by deleting any added files as well. added_files = reversed(sorted(self.added_files())) # added_file...
run_command(["svn", "add", path])
self.run(["svn", "add", path])
def add(self, path): # path is assumed to be cwd relative? run_command(["svn", "add", path])
return run_command([self.script_path("svn-create-patch")],
return self.run([self.script_path("svn-create-patch")],
def create_patch(self, git_commit=None, squash=None): """Returns a byte array (str()) representing the patch file. Patch files are effectively binary since they may contain files of multiple different encodings.""" return run_command([self.script_path("svn-create-patch")], cwd=self.checkout_root, return_stderr=False, d...
return run_command(["svn", "propget", "svn:author", "--revprop", "-r", revision]).rstrip()
return self.run(["svn", "propget", "svn:author", "--revprop", "-r", revision]).rstrip()
def committer_email_for_revision(self, revision): return run_command(["svn", "propget", "svn:author", "--revprop", "-r", revision]).rstrip()
return run_command(["svn", "cat", "-r", revision, remote_path], decode_output=False)
return self.run(["svn", "cat", "-r", revision, remote_path], decode_output=False)
def contents_at_revision(self, path, revision): """Returns a byte array (str()) containing the contents of path @ revision in the repository.""" remote_path = "%s/%s" % (self._repository_url(), path) return run_command(["svn", "cat", "-r", revision, remote_path], decode_output=False)
return run_command(['svn', 'diff', '-c', revision])
return self.run(['svn', 'diff', '-c', revision])
def diff_for_revision(self, revision): # FIXME: This should probably use cwd=self.checkout_root return run_command(['svn', 'diff', '-c', revision])
run_command(svn_merge_args)
self.run(svn_merge_args)
def apply_reverse_diff(self, revision): # '-c -revision' applies the inverse diff of 'revision' svn_merge_args = ['svn', 'merge', '--non-interactive', '-c', '-%s' % revision, self._repository_url()] log("WARNING: svn merge has been known to take more than 10 minutes to complete. It is recommended you use git for rollo...
run_command(['svn', 'revert'] + file_paths)
self.run(['svn', 'revert'] + file_paths)
def revert_files(self, file_paths): # FIXME: This should probably use cwd=self.checkout_root. run_command(['svn', 'revert'] + file_paths)
return run_command(svn_commit_args, error_handler=commit_error_handler)
return self.run(svn_commit_args, error_handler=commit_error_handler)
def commit_with_message(self, message, username=None, git_commit=None, squash=None): # squash and git-commit are not used by SVN. if self.dryrun: # Return a string which looks like a commit so that things which parse this output will succeed. return "Dry run, no commit.\nCommitted revision 0." svn_commit_args = ["svn",...
return run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]);
return self.run(['svn', 'log', '--non-interactive', '--revision', svn_revision])
def svn_commit_log(self, svn_revision): svn_revision = self.strip_r_from_svn_revision(svn_revision) return run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]);
run_command(['git', 'reset', '--hard', self.svn_branch_name()])
self.run(['git', 'reset', '--hard', self.svn_branch_name()])
def discard_local_commits(self): # FIXME: This should probably use cwd=self.checkout_root run_command(['git', 'reset', '--hard', self.svn_branch_name()])
return run_command(['git', 'log', '--pretty=oneline', 'HEAD...' + self.svn_branch_name()]).splitlines()
return self.run(['git', 'log', '--pretty=oneline', 'HEAD...' + self.svn_branch_name()]).splitlines()
def local_commits(self): # FIXME: This should probably use cwd=self.checkout_root return run_command(['git', 'log', '--pretty=oneline', 'HEAD...' + self.svn_branch_name()]).splitlines()
return run_command(['git', 'diff', 'HEAD', '--name-only']) == ""
return self.run(['git', 'diff', 'HEAD', '--name-only']) == ""
def working_directory_is_clean(self): # FIXME: This should probably use cwd=self.checkout_root return run_command(['git', 'diff', 'HEAD', '--name-only']) == ""
run_command(['git', 'reset', '--hard', 'HEAD'])
self.run(['git', 'reset', '--hard', 'HEAD'])
def clean_working_directory(self): # FIXME: These should probably use cwd=self.checkout_root. # Could run git clean here too, but that wouldn't match working_directory_is_clean run_command(['git', 'reset', '--hard', 'HEAD']) # Aborting rebase even though this does not match working_directory_is_clean if self.rebase_in_...
run_command(['git', 'rebase', '--abort'])
self.run(['git', 'rebase', '--abort'])
def clean_working_directory(self): # FIXME: These should probably use cwd=self.checkout_root. # Could run git clean here too, but that wouldn't match working_directory_is_clean run_command(['git', 'reset', '--hard', 'HEAD']) # Aborting rebase even though this does not match working_directory_is_clean if self.rebase_in_...
run_command(["git", "add", path])
self.run(["git", "add", path])
def add(self, path): # path is assumed to be cwd relative? run_command(["git", "add", path])
changed_files = run_command(["git", "show", "--pretty=format:", "--name-only", git_commit]).splitlines()
changed_files = self.run(["git", "show", "--pretty=format:", "--name-only", git_commit]).splitlines()
def _changes_files_for_commit(self, git_commit): # --pretty="format:" makes git show not print the commit log header, changed_files = run_command(["git", "show", "--pretty=format:", "--name-only", git_commit]).splitlines() # instead it just prints a blank line at the top, so we skip the blank line: return changed_files...
return run_command(['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self._merge_base(git_commit, squash)], decode_output=False)
return self.run(['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self._merge_base(git_commit, squash)], decode_output=False)
def create_patch(self, git_commit=None, squash=None): """Returns a byte array (str()) representing the patch file. Patch files are effectively binary since they may contain files of multiple different encodings.""" # FIXME: This should probably use cwd=self.checkout_root return run_command(['git', 'diff', '--binary', "...
return run_command(["git", "show", "%s:%s" % (self.git_commit_from_svn_revision(revision), path)], decode_output=False)
return self.run(["git", "show", "%s:%s" % (self.git_commit_from_svn_revision(revision), path)], decode_output=False)
def contents_at_revision(self, path, revision): """Returns a byte array (str()) containing the contents of path @ revision in the repository.""" return run_command(["git", "show", "%s:%s" % (self.git_commit_from_svn_revision(revision), path)], decode_output=False)
committer_email = run_command(["git", "log", "-1", "--pretty=format:%ce", git_commit])
committer_email = self.run(["git", "log", "-1", "--pretty=format:%ce", git_commit])
def committer_email_for_revision(self, revision): git_commit = self.git_commit_from_svn_revision(revision) committer_email = run_command(["git", "log", "-1", "--pretty=format:%ce", git_commit]) # Git adds an extra @repository_hash to the end of every committer email, remove it: return committer_email.rsplit("@", 1)[0]
run_command(['git', 'revert', '--no-commit', git_commit], error_handler=Executive.ignore_error)
self.run(['git', 'revert', '--no-commit', git_commit], error_handler=Executive.ignore_error)
def apply_reverse_diff(self, revision): # Assume the revision is an svn revision. git_commit = self.git_commit_from_svn_revision(revision) # I think this will always fail due to ChangeLogs. run_command(['git', 'revert', '--no-commit', git_commit], error_handler=Executive.ignore_error)
run_command(['git', 'checkout', 'HEAD'] + file_paths)
self.run(['git', 'checkout', 'HEAD'] + file_paths)
def revert_files(self, file_paths): run_command(['git', 'checkout', 'HEAD'] + file_paths)
run_command(['git', 'reset', '--soft', self.svn_branch_name()])
self.run(['git', 'reset', '--soft', self.svn_branch_name()])
def commit_with_message(self, message, username=None, git_commit=None, squash=None): # Username is ignored during Git commits. if git_commit: # Need working directory changes to be committed so we can checkout the merge branch. if not self.working_directory_is_clean(): # FIXME: webkit-patch land will modify the ChangeL...
branch_ref = run_command(['git', 'symbolic-ref', 'HEAD']).strip()
branch_ref = self.run(['git', 'symbolic-ref', 'HEAD']).strip()
def _commit_on_branch(self, message, git_commit): branch_ref = run_command(['git', 'symbolic-ref', 'HEAD']).strip() branch_name = branch_ref.replace('refs/heads/', '') commit_ids = self.commit_ids_from_commitish_arguments([git_commit])
run_command(['git', 'checkout', '-q', '-b', MERGE_BRANCH, self.svn_branch_name()])
self.run(['git', 'checkout', '-q', '-b', MERGE_BRANCH, self.svn_branch_name()])
def _commit_on_branch(self, message, git_commit): branch_ref = run_command(['git', 'symbolic-ref', 'HEAD']).strip() branch_name = branch_ref.replace('refs/heads/', '') commit_ids = self.commit_ids_from_commitish_arguments([git_commit])
run_command(['git', 'cherry-pick', '--no-commit', commit]) run_command(['git', 'commit', '-m', message])
self.run(['git', 'cherry-pick', '--no-commit', commit]) self.run(['git', 'commit', '-m', message])
def _commit_on_branch(self, message, git_commit): branch_ref = run_command(['git', 'symbolic-ref', 'HEAD']).strip() branch_name = branch_ref.replace('refs/heads/', '') commit_ids = self.commit_ids_from_commitish_arguments([git_commit])
run_command(['git', 'checkout', '-q', branch_name])
self.run(['git', 'checkout', '-q', branch_name])
def _commit_on_branch(self, message, git_commit): branch_ref = run_command(['git', 'symbolic-ref', 'HEAD']).strip() branch_name = branch_ref.replace('refs/heads/', '') commit_ids = self.commit_ids_from_commitish_arguments([git_commit])
return run_command(['git', 'svn', 'log', '-r', svn_revision])
return self.run(['git', 'svn', 'log', '-r', svn_revision])
def svn_commit_log(self, svn_revision): svn_revision = self.strip_r_from_svn_revision(svn_revision) return run_command(['git', 'svn', 'log', '-r', svn_revision])
return run_command(['git', 'svn', 'log', '--limit=1'])
return self.run(['git', 'svn', 'log', '--limit=1'])
def last_svn_commit_log(self): return run_command(['git', 'svn', 'log', '--limit=1'])
if run_command(['git', 'show-ref', '--quiet', '--verify', 'refs/heads/' + branch], return_exit_code=True) == 0: run_command(['git', 'branch', '-D', branch])
if self.run(['git', 'show-ref', '--quiet', '--verify', 'refs/heads/' + branch], return_exit_code=True) == 0: self.run(['git', 'branch', '-D', branch])
def delete_branch(self, branch): if run_command(['git', 'show-ref', '--quiet', '--verify', 'refs/heads/' + branch], return_exit_code=True) == 0: run_command(['git', 'branch', '-D', branch])
return run_command(['git', 'merge-base', self.svn_branch_name(), 'HEAD']).strip()
return self.run(['git', 'merge-base', self.svn_branch_name(), 'HEAD']).strip()
def svn_merge_base(self): return run_command(['git', 'merge-base', self.svn_branch_name(), 'HEAD']).strip()
run_command(['git', 'commit', '--all', '-F', '-'], input=message)
self.run(['git', 'commit', '--all', '-F', '-'], input=message)
def commit_locally_with_message(self, message): run_command(['git', 'commit', '--all', '-F', '-'], input=message)
output = run_command(dcommit_command, error_handler=commit_error_handler)
output = self.run(dcommit_command, error_handler=commit_error_handler)
def push_local_commits_to_server(self): dcommit_command = ['git', 'svn', 'dcommit'] if self.dryrun: dcommit_command.append('--dry-run') output = run_command(dcommit_command, error_handler=commit_error_handler) # Return a string which looks like a commit so that things which parse this output will succeed. if self.dryru...
commit_ids += reversed(run_command(['git', 'rev-list', commitish]).splitlines())
commit_ids += reversed(self.run(['git', 'rev-list', commitish]).splitlines())
def commit_ids_from_commitish_arguments(self, args): if not len(args): args.append('%s..HEAD' % self.svn_branch_name())
commit_ids += run_command(['git', 'rev-parse', '--revs-only', commitish]).splitlines()
commit_ids += self.run(['git', 'rev-parse', '--revs-only', commitish]).splitlines()
def commit_ids_from_commitish_arguments(self, args): if not len(args): args.append('%s..HEAD' % self.svn_branch_name())
commit_lines = run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()
commit_lines = self.run(['git', 'cat-file', 'commit', commit_id]).splitlines()
def commit_message_for_local_commit(self, commit_id): commit_lines = run_command(['git', 'cat-file', 'commit', commit_id]).splitlines()
license_file = metadata["License File"] license_path = os.path.join(path, license_file) if not os.path.exists(license_path): raise LicenseError("License file '" + license_file + "' doesn't exist. " "Either add a 'License File:' section to " "README.chromium or add the missing file.")
for filename in (metadata["License File"], "COPYING"): license_path = os.path.join(path, filename) if os.path.exists(license_path): metadata["License File"] = filename break license_path = None if not license_path: raise LicenseError("License file not found. " "Either add a file named LICENSE, " "import upstream's COP...
def ParseDir(path): """Examine a third_party/foo component and extract its metadata.""" # Try to find README.chromium. readme_path = os.path.join(path, 'README.chromium') if not os.path.exists(readme_path): raise LicenseError("missing README.chromium") # Parse metadata fields out of README.chromium. # We provide a de...
skip_dirs = ('.svn', '.git', 'out', 'Debug', 'Release', 'layout_tests')
def FindThirdPartyDirs(): """Find all third_party directories underneath the current directory.""" skip_dirs = ('.svn', '.git', # VCS metadata 'out', 'Debug', 'Release', # build files 'layout_tests') # lots of subdirs third_party_dirs = [] for path, dirs, files in os.walk('.'): path = path[len...
for skip in skip_dirs:
for skip in PRUNE_DIRS:
def FindThirdPartyDirs(): """Find all third_party directories underneath the current directory.""" skip_dirs = ('.svn', '.git', # VCS metadata 'out', 'Debug', 'Release', # build files 'layout_tests') # lots of subdirs third_party_dirs = [] for path, dirs, files in os.walk('.'): path = path[len...
third_party_dirs.extend([os.path.join(path, dir) for dir in dirs])
for dir in dirs: dirpath = os.path.join(path, dir) if dirpath not in PRUNE_PATHS: third_party_dirs.append(dirpath)
def FindThirdPartyDirs(): """Find all third_party directories underneath the current directory.""" skip_dirs = ('.svn', '.git', # VCS metadata 'out', 'Debug', 'Release', # build files 'layout_tests') # lots of subdirs third_party_dirs = [] for path, dirs, files in os.walk('.'): path = path[len...
'cygwin': 'win',
} platform_flags = { 'darwin': '-DSWIGMAC', 'linux2': '-DSWIGLINUX', 'win32': '-DSWIGWIN',
def main(): swig_dir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir, os.pardir, 'third_party', 'swig')) lib_dir = os.path.join(swig_dir, "Lib") os.putenv("SWIG_LIB", lib_dir) dir_map = { 'darwin': 'mac', 'linux2': 'linux', 'win32': 'win', 'cygwin': 'win', } swig_bin = os.path.join(swig_dir, dir...
os.execv(swig_bin, [swig_bin] + sys.argv[1:])
args = [swig_bin, platform_flags[sys.platform]] + sys.argv[1:] args = [x.replace('/', os.sep) for x in args] print "Executing", args sys.exit(subprocess.call(args))
def main(): swig_dir = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), os.pardir, os.pardir, 'third_party', 'swig')) lib_dir = os.path.join(swig_dir, "Lib") os.putenv("SWIG_LIB", lib_dir) dir_map = { 'darwin': 'mac', 'linux2': 'linux', 'win32': 'win', 'cygwin': 'win', } swig_bin = os.path.join(swig_dir, dir...
default=('http://build.chromium.org/buildbot/'
default=('http://build.chromium.org/f/chromium/'
def parse_options(args): """Parse options and return a pair of host options and target options.""" option_parser = optparse.OptionParser() option_parser.add_option('-v', '--verbose', action='store_true', default=False, help='include debug-level logging.') option_parser.add_option('-q', '--quiet', action='store_true', ...
'xml' : 'text/xml', 'pdf' : 'application/pdf'
'pdf' : 'application/pdf', 'xml' : 'text/xml'
def __init__(self, request, client_address, socket_server): connect_handlers = [ self.RedirectConnectHandler, self.ServerAuthConnectHandler, self.DefaultConnectResponseHandler] get_handlers = [ self.NoCacheMaxAgeTimeHandler, self.NoCacheTimeHandler, self.CacheTimeHandler, self.CacheExpiresHandler, self.CacheProxyRevali...
result = False
return False
def check_sys_deps(self, needs_http): proc = subprocess.Popen([test_shell_binary_path, '--check-layout-test-sys-deps']) if proc.wait(): logging.error('System dependencies check failed.') logging.error('To override, invoke with --nocheck-sys-deps') logging.error('') result = False return True
self._macCodeSign(browser_info)
self._MacCodeSign(browser_info)
def testCodeSign(self): """Check the app for codesign and bail out if it's non-branded.""" browser_info = self.GetBrowserInfo()
SANITY_TEST_SUPPRESSIONS_LINUX = {
SANITY_TEST_SUPPRESSIONS = {
def find_and_truncate(f): f.seek(0) while True: line = f.readline() if line == "": return False if '</valgrindoutput>' in line: # valgrind often has garbage after </valgrindoutput> upon crash f.truncate() return True
} SANITY_TEST_SUPPRESSIONS_MAC = { "Memcheck sanity test 01 (memory leak).": 1, "Memcheck sanity test 02 (malloc/read left).": 1, "Memcheck sanity test 03 (malloc/read right).": 1, "Memcheck sanity test 06 (new/read left).": 1, "Memcheck sanity test 07 (new/read right).": 1, "Memcheck sanity test 10 (write after free)...
def find_and_truncate(f): f.seek(0) while True: line = f.readline() if line == "": return False if '</valgrindoutput>' in line: # valgrind often has garbage after </valgrindoutput> upon crash f.truncate() return True
if common.IsLinux(): remaining_sanity_supp = MemcheckAnalyzer.SANITY_TEST_SUPPRESSIONS_LINUX elif common.IsMac(): remaining_sanity_supp = MemcheckAnalyzer.SANITY_TEST_SUPPRESSIONS_MAC else: remaining_sanity_supp = {} if check_sanity: logging.warn("No sanity test list for platform %s", sys.platform)
remaining_sanity_supp = MemcheckAnalyzer.SANITY_TEST_SUPPRESSIONS
def Report(self, files, check_sanity=False): '''Reads in a set of files and prints Memcheck report.
builder['is_green'] = not re.search('fail', cell.renderContents())
builder['is_green'] = not re.search('fail', cell.renderContents()) or \ re.search('lost', cell.renderContents())
def _parse_last_build_cell(self, builder, cell): status_link = cell.find('a') if status_link: # Will be either a revision number or a build number revision_string = status_link.string # If revision_string has non-digits assume it's not a revision number. builder['built_revision'] = int(revision_string) \ if not re.matc...
self.DownloadAndWaitForStart(file_url) self.WaitForAllDownloadsToComplete() unzip_file_name = os.path.join(self.GetDownloadDirectory().value(), 'a_file.txt')
file_url2 = self.GetFileURLForDataPath(os.path.join('zip', 'test.zip')) unzip_path = os.path.join(self.GetDownloadDirectory().value(), 'test', 'foo') os.path.exists(downloaded_pkg) and os.remove(downloaded_pkg) os.path.exists(unzip_path) and pyauto_utils.RemovePath(unzip_path) self.DownloadAndWaitForStart(file_url2) se...
def testAlwaysOpenFileType(self): """Verify "Always Open Files of this Type" download option
self.assertTrue(self.WaitUntil(lambda: os.path.exists(unzip_file_name)),
self.assertTrue(self.WaitUntil(lambda: os.path.exists(unzip_path)),
def testAlwaysOpenFileType(self): """Verify "Always Open Files of this Type" download option
os.path.exists(unzip_file_name) and os.remove(unzip_file_name)
os.path.exists(unzip_path) and pyauto_utils.RemovePath(unzip_path)
def testAlwaysOpenFileType(self): """Verify "Always Open Files of this Type" download option
time.sleep(1) downloads = self.GetDownloadsInfo().Downloads() percentage = downloads[0]['PercentComplete'] self.assertTrue(percentage > old_percentage, 'Download percentage value is not increasing')
def _PercentInc(): percent = self.GetDownloadsInfo().Downloads()[0]['PercentComplete'] return old_percentage == 100 or percent > old_percentage, self.assertTrue(self.WaitUntil(_PercentInc), msg='Download percentage value is not increasing')
def testDownloadPercentage(self): """Verify that during downloading, % values increases, and once download is over, % value is 100""" file_path = self._MakeFile(2**24) file_url = self.GetFileURLForPath(file_path) downloaded_pkg = os.path.join(self.GetDownloadDirectory().value(), os.path.basename(file_path)) os.path.exi...
BaseTool.__init__(self)
super(ValgrindTool, self).__init__()
def __init__(self): BaseTool.__init__(self) self.RegisterOptionParserHook(ValgrindTool.ExtendOptionParser)
ValgrindTool.__init__(self)
super(Memcheck, self).__init__()
def __init__(self): ValgrindTool.__init__(self) self.RegisterOptionParserHook(Memcheck.ExtendOptionParser)
def __init__(self): BaseTool.__init__(self)
def __init__(self): BaseTool.__init__(self)
def __init__(self): ValgrindTool.__init__(self) ThreadSanitizerBase.__init__(self)
def __init__(self): ValgrindTool.__init__(self) ThreadSanitizerBase.__init__(self)
PinTool.__init__(self) ThreadSanitizerBase.__init__(self)
super(ThreadSanitizerWindows, self).__init__()
def __init__(self): PinTool.__init__(self) ThreadSanitizerBase.__init__(self) self.RegisterOptionParserHook(ThreadSanitizerWindows.ExtendOptionParser)
BaseTool.__init__(self)
super(DrMemory, self).__init__()
def __init__(self): BaseTool.__init__(self) self.RegisterOptionParserHook(DrMemory.ExtendOptionParser)
proc += ['--race-verifier=' + self.TMP_DIR + '/race.log']
proc += ['--race-verifier=' + self.TMP_DIR + '/race.log', '--race-verifier-sleep-ms=%d' % int(self._options.race_verifier_sleep_ms)]
def ToolSpecificFlags(self): proc = super(ThreadSanitizerRV2Mixin, self).ToolSpecificFlags() proc += ['--race-verifier=' + self.TMP_DIR + '/race.log'] return proc
Committer("Kent Tamura", "tkent@chromium.org", "tkent"),
def __init__(self, name, email_or_emails, irc_nickname=None): Committer.__init__(self, name, email_or_emails, irc_nickname) self.can_review = True
return run_command(['git', 'diff-index', 'HEAD']) == ""
return run_command(['git', 'diff', 'HEAD', '--name-only']) == ""
def working_directory_is_clean(self): return run_command(['git', 'diff-index', 'HEAD']) == ""
optparser.add_option('-p', '--port', action='store', default='mac', 'Platform to test (e.g., "mac", "chromium-mac", etc.')
optparser.add_option('-p', '--platform', action='store', default='mac', help='Platform to test (e.g., "mac", "chromium-mac", etc.')
def run_tests(port, options, tests): # |image_path| is a path to the image capture from the driver. image_path = 'image_result.png' driver = port.start_driver(image_path, None) for t in tests: uri = port.filename_to_uri(os.path.join(port.layout_tests_dir(), t)) print "uri: " + uri crash, timeout, checksum, output, err ...
'build type ("Debug" or "Release")')
help='build type ("Debug" or "Release")')
def run_tests(port, options, tests): # |image_path| is a path to the image capture from the driver. image_path = 'image_result.png' driver = port.start_driver(image_path, None) for t in tests: uri = port.filename_to_uri(os.path.join(port.layout_tests_dir(), t)) print "uri: " + uri crash, timeout, checksum, output, err ...
'test timeout in milliseconds (2000 by default)')
help='test timeout in milliseconds (2000 by default)')
def run_tests(port, options, tests): # |image_path| is a path to the image capture from the driver. image_path = 'image_result.png' driver = port.start_driver(image_path, None) for t in tests: uri = port.filename_to_uri(os.path.join(port.layout_tests_dir(), t)) print "uri: " + uri crash, timeout, checksum, output, err ...
p = port.get(options.port, options)
p = port.get(options.platform, options)
def run_tests(port, options, tests): # |image_path| is a path to the image capture from the driver. image_path = 'image_result.png' driver = port.start_driver(image_path, None) for t in tests: uri = port.filename_to_uri(os.path.join(port.layout_tests_dir(), t)) print "uri: " + uri crash, timeout, checksum, output, err ...
ie_paths_re = re.compile('ceee[\\/](ie|common)[\\/]')
ie_paths_re = re.compile('ceee[\\\\/](ie|common)[\\\\/]')
def CheckUnittestsRan(input_api, output_api, committing): '''Checks that the unittests success file is newer than any modified file''' # But only if there were IE files modified, since we only have unit tests # for CEEE IE. files = [] ie_paths_re = re.compile('ceee[\\/](ie|common)[\\/]') for f in input_api.AffectedFile...
self.run_webkit_patch(["land-attachment", "--force-clean", "--non-interactive", "--no-update", "--parent-command=commit-queue", "--build-style=both", "--quiet", patch.id()])
args = [ "land-attachment", "--force-clean", "--non-interactive", "--parent-command=commit-queue", "--build-style=both", "--quiet", patch.id() ] if patch.is_rollout(): args.append("--ignore-builders") else: args.append("--no-update") self.run_webkit_patch(args)
def process_work_item(self, patch): try: self._cc_watchers(patch.bug_id()) # We pass --no-update here because we've already validated # that the current revision actually builds and passes the tests. # If we update, we risk moving to a revision that doesn't! self.run_webkit_patch(["land-attachment", "--force-clean", "-...
def __init__(self, filename, file_comment = None):
def __init__(self, filename, file_comment = None, guard_depth = 3):
def __init__(self, filename, file_comment = None): CWriter.__init__(self, filename) base = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) hpath = os.path.abspath(filename)[len(base) + 1:] self.guard = self._non_alnum_re.sub('_', hpath).upper() + '_'
base = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
base = os.path.dirname(os.path.abspath(filename)) for i in range(guard_depth): base = os.path.dirname(base)
def __init__(self, filename, file_comment = None): CWriter.__init__(self, filename) base = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) hpath = os.path.abspath(filename)[len(base) + 1:] self.guard = self._non_alnum_re.sub('_', hpath).upper() + '_'
step = (num_tests + 1) / 2
FUNCTIONS_PER_FILE = 98
def WriteServiceUnitTests(self, filename): """Writes the service decorder unit tests.""" num_tests = len(self.functions) step = (num_tests + 1) / 2 count = 0 for test_num in range(0, num_tests, step): count += 1 name = filename % count file = CHeaderWriter( name, "// It is included by gles2_cmd_decoder_unittest_%d.cc\n...
for test_num in range(0, num_tests, step):
for test_num in range(0, num_tests, FUNCTIONS_PER_FILE):
def WriteServiceUnitTests(self, filename): """Writes the service decorder unit tests.""" num_tests = len(self.functions) step = (num_tests + 1) / 2 count = 0 for test_num in range(0, num_tests, step): count += 1 name = filename % count file = CHeaderWriter( name, "// It is included by gles2_cmd_decoder_unittest_%d.cc\n...
end = test_num + step
end = test_num + FUNCTIONS_PER_FILE
def WriteServiceUnitTests(self, filename): """Writes the service decorder unit tests.""" num_tests = len(self.functions) step = (num_tests + 1) / 2 count = 0 for test_num in range(0, num_tests, step): count += 1 name = filename % count file = CHeaderWriter( name, "// It is included by gles2_cmd_decoder_unittest_%d.cc\n...
self._update_status("Patch could not be landed with first attempt, doing a clean build as a sanity check", patch)
self._update_status("Doing a clean build as a sanity check", patch)
def process_work_item(self, patch): self._cc_watchers(patch.bug_id()) if not self._land(patch, first_run=True): self._update_status("Patch could not be landed with first attempt, doing a clean build as a sanity check", patch) # The patch failed to land, but the bots were green. It's possible # that the bots were behind...
We poll the url 5 times with a 1 second delay. If we don't
We poll the url 20 times with a 0.5 second delay. If we don't
def url_is_alive(url): """Checks to see if we get an http response from |url|. We poll the url 5 times with a 1 second delay. If we don't get a reply in that time, we give up and assume the httpd didn't start properly. Args: url: The URL to check. Return: True if the url is alive. """ sleep_time = 0.5 wait_time = 5 w...
wait_time = 5
wait_time = 10
def url_is_alive(url): """Checks to see if we get an http response from |url|. We poll the url 5 times with a 1 second delay. If we don't get a reply in that time, we give up and assume the httpd didn't start properly. Args: url: The URL to check. Return: True if the url is alive. """ sleep_time = 0.5 wait_time = 5 w...
platform enough.
platform enough. the function seems simple: "print output of child, kill it if there is no output by timeout. But it was tricky to get this right in a x-platform way (see warnings about deadlock on the python subprocess doc page).
def TerminateSignalHandler(sig, stack): """When killed, try and kill our child processes.""" signal.signal(sig, signal.SIG_DFL) for pid in gChildPIDs: if 'kill' in os.__all__: # POSIX os.kill(pid, sig) else: subprocess.call(['taskkill.exe', '/PID', str(pid)]) sys.exit(0)
LINE = 0 DIED = 1
PROGRESS = 0 DONE = 1
def TerminateSignalHandler(sig, stack): """When killed, try and kill our child processes.""" signal.signal(sig, signal.SIG_DFL) for pid in gChildPIDs: if 'kill' in os.__all__: # POSIX os.kill(pid, sig) else: subprocess.call(['taskkill.exe', '/PID', str(pid)]) sys.exit(0)
self._process = subprocess.Popen(self._cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) gChildPIDs.append(self._process.pid)
stdout_file = tempfile.TemporaryFile()
def run(self): self._process = subprocess.Popen(self._cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) gChildPIDs.append(self._process.pid) try: while True: line = self._process.stdout.readline() if not line: # EOF break print line, self._queue.put(RunProgramThread.LINE, True) except IOError: pass # If we get he...
while True: line = self._process.stdout.readline() if not line: break print line, self._queue.put(RunProgramThread.LINE, True) except IOError: pass
self._process = subprocess.Popen(self._cmd, stdin=subprocess.PIPE, stdout=stdout_file, stderr=subprocess.STDOUT) gChildPIDs.append(self._process.pid) try: previous_tell = 0 self._retcode = None while self._retcode is None: self._retcode = self._process.poll() current_tell = stdout_file.tell() if current_tell > pr...
def run(self): self._process = subprocess.Popen(self._cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) gChildPIDs.append(self._process.pid) try: while True: line = self._process.stdout.readline() if not line: # EOF break print line, self._queue.put(RunProgramThread.LINE, True) except IOError: pass # If we get he...
self._queue.put(RunProgramThread.DIED)
self._queue.put(RunProgramThread.DONE)
def run(self): self._process = subprocess.Popen(self._cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) gChildPIDs.append(self._process.pid) try: while True: line = self._process.stdout.readline() if not line: # EOF break print line, self._queue.put(RunProgramThread.LINE, True) except IOError: pass # If we get he...
if x == RunProgramThread.DIED:
if x == RunProgramThread.DONE:
def RunUntilCompletion(self, timeout): """Run thread until completion or timeout (in seconds).
'', '--ui-test-flags', type='string', default='', help='Flags passed to the UI test suite. Refer ui_test.h for options')
'', '--chrome-flags', type='string', default='', help='Flags passed to Chrome. This is in addition to the usual flags ' 'like suppressing first-run dialogs, enabling automation. ' 'See chrome/common/chrome_switches.cc for the list of flags ' 'chrome understands.')
def _ParseArgs(self): """Parse command line args.""" parser = optparse.OptionParser() parser.add_option( '-v', '--verbose', action='store_true', default=False, help='Make PyAuto verbose.') parser.add_option( '-D', '--wait-for-debugger', action='store_true', default=False, help='Block PyAuto on startup for attaching deb...
pyauto_suite = PyUITestSuite(re.split('\s+', self._options.ui_test_flags))
suite_args = [sys.argv[0]] if self._options.chrome_flags: suite_args.append('--extra-chrome-flags=' + self._options.chrome_flags) pyauto_suite = PyUITestSuite(suite_args)
def _Run(self): """Run the tests.""" if self._options.wait_for_debugger: raw_input('Attach debugger to process %s and hit <enter> ' % os.getpid())