提交 cb0bfcd5 编写于 作者: O Ojan Vafai

Get test_webkitpy to actually run again.

-Fix all the Tools/Scripts paths to use tools.
-Fix imports of deleted modules.
-Delete SVN module

TBR=abarth@chromium.org

Review URL: https://codereview.chromium.org/639883003
上级 7d0b4fb7
......@@ -93,10 +93,10 @@ class DiffParserTest(unittest.TestCase):
]
svn_diff_lines = [
"Index: Tools/Scripts/webkitpy/common/checkout/diff_parser.py\n",
"Index: tools/webkitpy/common/checkout/diff_parser.py\n",
"===================================================================\n",
"--- Tools/Scripts/webkitpy/common/checkout/diff_parser.py\n",
"+++ Tools/Scripts/webkitpy/common/checkout/diff_parser.py\n",
"--- tools/webkitpy/common/checkout/diff_parser.py\n",
"+++ tools/webkitpy/common/checkout/diff_parser.py\n",
"@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):\n",
]
self.assertEqual(diff_parser.get_diff_converter(svn_diff_lines), diff_parser.svn_diff_to_svn_diff)
......@@ -104,10 +104,10 @@ class DiffParserTest(unittest.TestCase):
self.assertEqual(diff_parser.get_diff_converter(revision_lines + svn_diff_lines), diff_parser.svn_diff_to_svn_diff)
git_diff_lines = [
"diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py\n",
"diff --git a/tools/webkitpy/common/checkout/diff_parser.py b/tools/webkitpy/common/checkout/diff_parser.py\n",
"index 3c5b45b..0197ead 100644\n",
"--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py\n",
"+++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py\n",
"--- a/tools/webkitpy/common/checkout/diff_parser.py\n",
"+++ b/tools/webkitpy/common/checkout/diff_parser.py\n",
"@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):\n",
]
self.assertEqual(diff_parser.get_diff_converter(git_diff_lines), diff_parser.git_diff_to_svn_diff)
......@@ -131,10 +131,10 @@ class DiffParserTest(unittest.TestCase):
def test_git_diff_to_svn_diff(self):
output = """\
Index: Tools/Scripts/webkitpy/common/checkout/diff_parser.py
Index: tools/webkitpy/common/checkout/diff_parser.py
===================================================================
--- Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+++ Tools/Scripts/webkitpy/common/checkout/diff_parser.py
--- tools/webkitpy/common/checkout/diff_parser.py
+++ tools/webkitpy/common/checkout/diff_parser.py
@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
A
B
......@@ -145,10 +145,10 @@ Index: Tools/Scripts/webkitpy/common/checkout/diff_parser.py
"""
inputfmt = StringIO.StringIO("""\
diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
diff --git a/tools/webkitpy/common/checkout/diff_parser.py b/tools/webkitpy/common/checkout/diff_parser.py
index 2ed552c4555db72df16b212547f2c125ae301a04..72870482000c0dba64ce4300ed782c03ee79b74f 100644
--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
--- a/tools/webkitpy/common/checkout/diff_parser.py
+++ b/tools/webkitpy/common/checkout/diff_parser.py
@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
A
B
......@@ -158,10 +158,10 @@ index 2ed552c4555db72df16b212547f2c125ae301a04..72870482000c0dba64ce4300ed782c03
F
""")
shortfmt = StringIO.StringIO("""\
diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
diff --git a/tools/webkitpy/common/checkout/diff_parser.py b/tools/webkitpy/common/checkout/diff_parser.py
index b48b162..f300960 100644
--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
--- a/tools/webkitpy/common/checkout/diff_parser.py
+++ b/tools/webkitpy/common/checkout/diff_parser.py
@@ -59,6 +59,7 @@ def git_diff_to_svn_diff(line):
A
B
......
......@@ -4,4 +4,3 @@
from .detection import SCMDetector
from .git import Git, AmbiguousCommitError
from .scm import SCM
from .svn import SVN
......@@ -32,7 +32,6 @@ import logging
from webkitpy.common.system.filesystem import FileSystem
from webkitpy.common.system.executive import Executive
from .svn import SVN
from .git import Git
_log = logging.getLogger(__name__)
......@@ -68,9 +67,6 @@ class SCMDetector(object):
if patch_directories == []:
patch_directories = None
if SVN.in_working_directory(absolute_path, executive=self._executive):
return SVN(cwd=absolute_path, patch_directories=patch_directories, filesystem=self._filesystem, executive=self._executive)
if Git.in_working_directory(absolute_path, executive=self._executive):
return Git(cwd=absolute_path, filesystem=self._filesystem, executive=self._executive)
......
......@@ -40,7 +40,6 @@ from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.checkout.scm.detection import detect_scm_system
from webkitpy.common.checkout.scm.git import Git, AmbiguousCommitError
from webkitpy.common.checkout.scm.scm import SCM
from webkitpy.common.checkout.scm.svn import SVN
# We cache the mock SVN repo so that we don't create it again for each call to an SVNTest or GitTest test_ method.
......@@ -254,55 +253,6 @@ class SCMTestBase(unittest.TestCase):
self.assertIn('moved_dir/another_added_file', self.scm._added_files())
class SVNTest(SCMTestBase):
def setUp(self):
super(SVNTest, self).setUp()
self._set_up_svn_checkout()
self._chdir(self.svn_checkout_path)
self.scm = detect_scm_system(self.svn_checkout_path)
self.scm.svn_server_realm = None
def tearDown(self):
super(SVNTest, self).tearDown()
self._tear_down_svn_checkout()
def test_detect_scm_system_relative_url(self):
scm = detect_scm_system(".")
# I wanted to assert that we got the right path, but there was some
# crazy magic with temp folder names that I couldn't figure out.
self.assertTrue(scm.checkout_root)
def test_detection(self):
self.assertEqual(self.scm.display_name(), "svn")
self.assertEqual(self.scm.supports_local_commits(), False)
def test_add_recursively(self):
self._shared_test_add_recursively()
def test_delete(self):
self._chdir(self.svn_checkout_path)
self.scm.delete("test_file")
self.assertIn("test_file", self.scm._deleted_files())
def test_delete_list(self):
self._chdir(self.svn_checkout_path)
self.scm.delete_list(["test_file", "test_file2"])
self.assertIn("test_file", self.scm._deleted_files())
self.assertIn("test_file2", self.scm._deleted_files())
def test_delete_recursively(self):
self._shared_test_delete_recursively()
def test_delete_recursively_or_not(self):
self._shared_test_delete_recursively_or_not()
def test_move(self):
self._shared_test_move()
def test_move_recursive(self):
self._shared_test_move_recursive()
class GitTest(SCMTestBase):
def setUp(self):
super(GitTest, self).setUp()
......@@ -362,328 +312,6 @@ class GitTest(SCMTestBase):
scm.commit_locally_with_message('message')
class GitSVNTest(SCMTestBase):
def setUp(self):
super(GitSVNTest, self).setUp()
self._set_up_svn_checkout()
self._set_up_gitsvn_checkout()
self.scm = detect_scm_system(self.git_checkout_path)
self.scm.svn_server_realm = None
def tearDown(self):
super(GitSVNTest, self).tearDown()
self._tear_down_svn_checkout()
self._tear_down_gitsvn_checkout()
def _set_up_gitsvn_checkout(self):
self.git_checkout_path = self._mkdtemp(suffix="git_test_checkout")
# --quiet doesn't make git svn silent
self._run_silent(['git', 'svn', 'clone', '-T', 'trunk', self.svn_repo_url, self.git_checkout_path])
self._chdir(self.git_checkout_path)
self.git_v2 = self._run(['git', '--version']).startswith('git version 2')
if self.git_v2:
# The semantics of 'git svn clone -T' changed in v2 (apparently), so the branch names are different.
# This works around it, for compatibility w/ v1.
self._run_silent(['git', 'branch', 'trunk', 'origin/trunk'])
def _tear_down_gitsvn_checkout(self):
self._rmtree(self.git_checkout_path)
def test_detection(self):
self.assertEqual(self.scm.display_name(), "git")
self.assertEqual(self.scm.supports_local_commits(), True)
def test_read_git_config(self):
key = 'test.git-config'
value = 'git-config value'
self._run(['git', 'config', key, value])
self.assertEqual(self.scm.read_git_config(key), value)
def test_local_commits(self):
test_file = self._join(self.git_checkout_path, 'test_file')
self._write_text_file(test_file, 'foo')
self._run(['git', 'commit', '-a', '-m', 'local commit'])
self.assertEqual(len(self.scm._local_commits()), 1)
def test_discard_local_commits(self):
test_file = self._join(self.git_checkout_path, 'test_file')
self._write_text_file(test_file, 'foo')
self._run(['git', 'commit', '-a', '-m', 'local commit'])
self.assertEqual(len(self.scm._local_commits()), 1)
self.scm._discard_local_commits()
self.assertEqual(len(self.scm._local_commits()), 0)
def test_delete_branch(self):
new_branch = 'foo'
self._run(['git', 'checkout', '-b', new_branch])
self.assertEqual(self._run(['git', 'symbolic-ref', 'HEAD']).strip(), 'refs/heads/' + new_branch)
self._run(['git', 'checkout', '-b', 'bar'])
self.scm.delete_branch(new_branch)
self.assertNotRegexpMatches(self._run(['git', 'branch']), r'foo')
def test_rebase_in_progress(self):
svn_test_file = self._join(self.svn_checkout_path, 'test_file')
self._write_text_file(svn_test_file, "svn_checkout")
self._run(['svn', 'commit', '--message', 'commit to conflict with git commit'], cwd=self.svn_checkout_path)
git_test_file = self._join(self.git_checkout_path, 'test_file')
self._write_text_file(git_test_file, "git_checkout")
self._run(['git', 'commit', '-a', '-m', 'commit to be thrown away by rebase abort'])
# Should fail due to a conflict leaving us mid-rebase.
# we use self._run_slient because --quiet doesn't actually make git svn silent.
self.assertRaises(ScriptError, self._run_silent, ['git', 'svn', '--quiet', 'rebase'])
self.assertTrue(self.scm._rebase_in_progress())
# Make sure our cleanup works.
self.scm._discard_working_directory_changes()
self.assertFalse(self.scm._rebase_in_progress())
# Make sure cleanup doesn't throw when no rebase is in progress.
self.scm._discard_working_directory_changes()
def _local_commit(self, filename, contents, message):
self._write_text_file(filename, contents)
self._run(['git', 'add', filename])
self.scm.commit_locally_with_message(message)
def _one_local_commit(self):
self._local_commit('test_file_commit1', 'more test content', 'another test commit')
def _one_local_commit_plus_working_copy_changes(self):
self._one_local_commit()
self._write_text_file('test_file_commit2', 'still more test content')
self._run(['git', 'add', 'test_file_commit2'])
def _second_local_commit(self):
self._local_commit('test_file_commit2', 'still more test content', 'yet another test commit')
def _two_local_commits(self):
self._one_local_commit()
self._second_local_commit()
def _three_local_commits(self):
self._local_commit('test_file_commit0', 'more test content', 'another test commit')
self._two_local_commits()
def test_locally_commit_all_working_copy_changes(self):
self._local_commit('test_file', 'test content', 'test commit')
self._write_text_file('test_file', 'changed test content')
self.assertTrue(self.scm.has_working_directory_changes())
self.scm.commit_locally_with_message('all working copy changes')
self.assertFalse(self.scm.has_working_directory_changes())
def test_locally_commit_no_working_copy_changes(self):
self._local_commit('test_file', 'test content', 'test commit')
self._write_text_file('test_file', 'changed test content')
self.assertTrue(self.scm.has_working_directory_changes())
self.assertRaises(ScriptError, self.scm.commit_locally_with_message, 'no working copy changes', False)
def _test_upstream_branch(self):
self._run(['git', 'checkout', '-t', '-b', 'my-branch'])
self._run(['git', 'checkout', '-t', '-b', 'my-second-branch'])
self.assertEqual(self.scm._upstream_branch(), 'my-branch')
def test_remote_branch_ref(self):
remote_branch_ref = self.scm._remote_branch_ref()
if self.git_v2:
self.assertEqual(remote_branch_ref, 'refs/remotes/origin/trunk')
else:
self.assertEqual(remote_branch_ref, 'refs/remotes/trunk')
def test_create_patch_local_plus_working_copy(self):
self._one_local_commit_plus_working_copy_changes()
patch = self.scm.create_patch()
self.assertRegexpMatches(patch, r'test_file_commit1')
self.assertRegexpMatches(patch, r'test_file_commit2')
def test_create_patch(self):
self._one_local_commit_plus_working_copy_changes()
patch = self.scm.create_patch()
self.assertRegexpMatches(patch, r'test_file_commit2')
self.assertRegexpMatches(patch, r'test_file_commit1')
self.assertRegexpMatches(patch, r'Subversion Revision: 5')
def test_create_patch_after_merge(self):
self._run(['git', 'checkout', '-b', 'dummy-branch', 'trunk~3'])
self._one_local_commit()
self._run(['git', 'merge', 'trunk'])
patch = self.scm.create_patch()
self.assertRegexpMatches(patch, r'test_file_commit1')
self.assertRegexpMatches(patch, r'Subversion Revision: 5')
def test_create_patch_with_changed_files(self):
self._one_local_commit_plus_working_copy_changes()
patch = self.scm.create_patch(changed_files=['test_file_commit2'])
self.assertRegexpMatches(patch, r'test_file_commit2')
def test_create_patch_with_rm_and_changed_files(self):
self._one_local_commit_plus_working_copy_changes()
self._remove('test_file_commit1')
patch = self.scm.create_patch()
patch_with_changed_files = self.scm.create_patch(changed_files=['test_file_commit1', 'test_file_commit2'])
self.assertEqual(patch, patch_with_changed_files)
def test_create_patch_git_commit(self):
self._two_local_commits()
patch = self.scm.create_patch(git_commit="HEAD^")
self.assertRegexpMatches(patch, r'test_file_commit1')
self.assertNotRegexpMatches(patch, r'test_file_commit2')
def test_create_patch_git_commit_range(self):
self._three_local_commits()
patch = self.scm.create_patch(git_commit="HEAD~2..HEAD")
self.assertNotRegexpMatches(patch, r'test_file_commit0')
self.assertRegexpMatches(patch, r'test_file_commit2')
self.assertRegexpMatches(patch, r'test_file_commit1')
def test_create_patch_working_copy_only(self):
self._one_local_commit_plus_working_copy_changes()
patch = self.scm.create_patch(git_commit="HEAD....")
self.assertNotRegexpMatches(patch, r'test_file_commit1')
self.assertRegexpMatches(patch, r'test_file_commit2')
def test_create_patch_multiple_local_commits(self):
self._two_local_commits()
patch = self.scm.create_patch()
self.assertRegexpMatches(patch, r'test_file_commit2')
self.assertRegexpMatches(patch, r'test_file_commit1')
def test_create_patch_not_synced(self):
self._run(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
self._two_local_commits()
patch = self.scm.create_patch()
self.assertNotRegexpMatches(patch, r'test_file2')
self.assertRegexpMatches(patch, r'test_file_commit2')
self.assertRegexpMatches(patch, r'test_file_commit1')
def test_create_binary_patch(self):
# Create a git binary patch and check the contents.
test_file_name = 'binary_file'
test_file_path = self.fs.join(self.git_checkout_path, test_file_name)
file_contents = ''.join(map(chr, range(256)))
self._write_binary_file(test_file_path, file_contents)
self._run(['git', 'add', test_file_name])
patch = self.scm.create_patch()
self.assertRegexpMatches(patch, r'\nliteral 0\n')
self.assertRegexpMatches(patch, r'\nliteral 256\n')
# Check if we can create a patch from a local commit.
self._write_binary_file(test_file_path, file_contents)
self._run(['git', 'add', test_file_name])
self._run(['git', 'commit', '-m', 'binary diff'])
patch_from_local_commit = self.scm.create_patch('HEAD')
self.assertRegexpMatches(patch_from_local_commit, r'\nliteral 0\n')
self.assertRegexpMatches(patch_from_local_commit, r'\nliteral 256\n')
def test_changed_files_local_plus_working_copy(self):
self._one_local_commit_plus_working_copy_changes()
files = self.scm.changed_files()
self.assertIn('test_file_commit1', files)
self.assertIn('test_file_commit2', files)
# working copy should *not* be in the list.
files = self.scm.changed_files('trunk..')
self.assertIn('test_file_commit1', files)
self.assertNotIn('test_file_commit2', files)
# working copy *should* be in the list.
files = self.scm.changed_files('trunk....')
self.assertIn('test_file_commit1', files)
self.assertIn('test_file_commit2', files)
def test_changed_files_git_commit(self):
self._two_local_commits()
files = self.scm.changed_files(git_commit="HEAD^")
self.assertIn('test_file_commit1', files)
self.assertNotIn('test_file_commit2', files)
def test_changed_files_git_commit_range(self):
self._three_local_commits()
files = self.scm.changed_files(git_commit="HEAD~2..HEAD")
self.assertNotIn('test_file_commit0', files)
self.assertIn('test_file_commit1', files)
self.assertIn('test_file_commit2', files)
def test_changed_files_working_copy_only(self):
self._one_local_commit_plus_working_copy_changes()
files = self.scm.changed_files(git_commit="HEAD....")
self.assertNotIn('test_file_commit1', files)
self.assertIn('test_file_commit2', files)
def test_changed_files_multiple_local_commits(self):
self._two_local_commits()
files = self.scm.changed_files()
self.assertIn('test_file_commit2', files)
self.assertIn('test_file_commit1', files)
def test_changed_files_not_synced(self):
self._run(['git', 'checkout', '-b', 'my-branch', 'trunk~3'])
self._two_local_commits()
files = self.scm.changed_files()
self.assertNotIn('test_file2', files)
self.assertIn('test_file_commit2', files)
self.assertIn('test_file_commit1', files)
def test_changed_files_upstream(self):
self._run(['git', 'checkout', '-t', '-b', 'my-branch'])
self._one_local_commit()
self._run(['git', 'checkout', '-t', '-b', 'my-second-branch'])
self._second_local_commit()
self._write_text_file('test_file_commit0', 'more test content')
self._run(['git', 'add', 'test_file_commit0'])
# equivalent to 'git diff my-branch..HEAD, should not include working changes
files = self.scm.changed_files(git_commit='UPSTREAM..')
self.assertNotIn('test_file_commit1', files)
self.assertIn('test_file_commit2', files)
self.assertNotIn('test_file_commit0', files)
# equivalent to 'git diff my-branch', *should* include working changes
files = self.scm.changed_files(git_commit='UPSTREAM....')
self.assertNotIn('test_file_commit1', files)
self.assertIn('test_file_commit2', files)
self.assertIn('test_file_commit0', files)
def test_add_recursively(self):
self._shared_test_add_recursively()
def test_delete(self):
self._two_local_commits()
self.scm.delete('test_file_commit1')
self.assertIn("test_file_commit1", self.scm._deleted_files())
def test_delete_list(self):
self._two_local_commits()
self.scm.delete_list(["test_file_commit1", "test_file_commit2"])
self.assertIn("test_file_commit1", self.scm._deleted_files())
self.assertIn("test_file_commit2", self.scm._deleted_files())
def test_delete_recursively(self):
self._shared_test_delete_recursively()
def test_delete_recursively_or_not(self):
self._shared_test_delete_recursively_or_not()
def test_move(self):
self._shared_test_move()
def test_move_recursive(self):
self._shared_test_move_recursive()
def test_exists(self):
self._shared_test_exists(self.scm, self.scm.commit_locally_with_message)
class GitTestWithMock(SCMTestBase):
def make_scm(self):
scm = Git(cwd=".", executive=MockExecutive(), filesystem=MockFileSystem())
......
# Copyright (c) 2009, 2010, 2011 Google Inc. All rights reserved.
# Copyright (c) 2009 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
import os
import random
import re
import shutil
import string
import sys
import tempfile
from webkitpy.common.memoized import memoized
from webkitpy.common.system.executive import Executive, ScriptError
from .scm import SCM
_log = logging.getLogger(__name__)
class SVN(SCM):
executable_name = "svn"
_svn_metadata_files = frozenset(['.svn', '_svn'])
def __init__(self, cwd, patch_directories, **kwargs):
SCM.__init__(self, cwd, **kwargs)
self._bogus_dir = None
if patch_directories == []:
raise Exception(message='Empty list of patch directories passed to SCM.__init__')
elif patch_directories == None:
self._patch_directories = [self._filesystem.relpath(cwd, self.checkout_root)]
else:
self._patch_directories = patch_directories
@classmethod
def in_working_directory(cls, path, executive=None):
if os.path.isdir(os.path.join(path, '.svn')):
# This is a fast shortcut for svn info that is usually correct for SVN < 1.7,
# but doesn't work for SVN >= 1.7.
return True
executive = executive or Executive()
svn_info_args = [cls.executable_name, 'info']
exit_code = executive.run_command(svn_info_args, cwd=path, return_exit_code=True)
return (exit_code == 0)
def _find_uuid(self, path):
if not self.in_working_directory(path):
return None
return self.value_from_svn_info(path, 'Repository UUID')
@classmethod
def value_from_svn_info(cls, path, field_name):
svn_info_args = [cls.executable_name, 'info']
# FIXME: This method should use a passed in executive or be made an instance method and use self._executive.
info_output = Executive().run_command(svn_info_args, cwd=path).rstrip()
match = re.search("^%s: (?P<value>.+)$" % field_name, info_output, re.MULTILINE)
if not match:
raise ScriptError(script_args=svn_info_args, message='svn info did not contain a %s.' % field_name)
return match.group('value').rstrip('\r')
def find_checkout_root(self, path):
uuid = self._find_uuid(path)
# If |path| is not in a working directory, we're supposed to return |path|.
if not uuid:
return path
# Search up the directory hierarchy until we find a different UUID.
last_path = None
while True:
if uuid != self._find_uuid(path):
return last_path
last_path = path
(path, last_component) = self._filesystem.split(path)
if last_path == path:
return None
def _run_svn(self, args, **kwargs):
return self._run([self.executable_name] + args, **kwargs)
@memoized
def _svn_version(self):
return self._run_svn(['--version', '--quiet'])
def has_working_directory_changes(self):
# FIXME: What about files which are not committed yet?
return self._run_svn(["diff"], cwd=self.checkout_root, decode_output=False) != ""
def status_command(self):
return [self.executable_name, 'status']
def _status_regexp(self, expected_types):
field_count = 6 if self._svn_version() > "1.6" else 5
return "^(?P<status>[%s]).{%s} (?P<filename>.+)$" % (expected_types, field_count)
def _add_parent_directories(self, path, recurse):
"""Does 'svn add' to the path and its parents."""
if self.in_working_directory(path):
return
self.add(path, recurse=recurse)
def add_list(self, paths, return_exit_code=False, recurse=True):
for path in paths:
self._add_parent_directories(os.path.dirname(os.path.abspath(path)),
recurse=False)
if recurse:
cmd = ["add"] + paths
else:
cmd = ["add", "--depth", "empty"] + paths
return self._run_svn(cmd, return_exit_code=return_exit_code)
def _delete_parent_directories(self, path):
if not self.in_working_directory(path):
return
if set(os.listdir(path)) - self._svn_metadata_files:
return # Directory has non-trivial files in it.
self.delete(path)
def delete_list(self, paths):
for path in paths:
abs_path = os.path.abspath(path)
parent, base = os.path.split(abs_path)
result = self._run_svn(["delete", "--force", base], cwd=parent)
self._delete_parent_directories(os.path.dirname(abs_path))
return result
def move(self, origin, destination):
return self._run_svn(["mv", "--force", origin, destination], return_exit_code=True)
def exists(self, path):
return not self._run_svn(["info", path], return_exit_code=True, decode_output=False)
def changed_files(self, git_commit=None):
status_command = [self.executable_name, "status"]
status_command.extend(self._patch_directories)
# ACDMR: Addded, Conflicted, Deleted, Modified or Replaced
return self._run_status_and_extract_filenames(status_command, self._status_regexp("ACDMR"))
def _added_files(self):
return self._run_status_and_extract_filenames(self.status_command(), self._status_regexp("A"))
def _deleted_files(self):
return self._run_status_and_extract_filenames(self.status_command(), self._status_regexp("D"))
@staticmethod
def supports_local_commits():
return False
def display_name(self):
return "svn"
def svn_revision(self, path):
return self.value_from_svn_info(path, 'Revision')
def timestamp_of_revision(self, path, revision):
# We use --xml to get timestamps like 2013-02-08T08:18:04.964409Z
repository_root = self.value_from_svn_info(self.checkout_root, 'Repository Root')
info_output = Executive().run_command([self.executable_name, 'log', '-r', revision, '--xml', repository_root], cwd=path).rstrip()
match = re.search(r"^<date>(?P<value>.+)</date>\r?$", info_output, re.MULTILINE)
return match.group('value')
def create_patch(self, git_commit=None, changed_files=None):
"""Returns a byte array (str()) representing the patch file.
Patch files are effectively binary since they may contain
files of multiple different encodings."""
if changed_files == []:
return ""
elif changed_files == None:
changed_files = []
return self._run([self._filesystem.join(self.checkout_root, 'Tools', 'Scripts', 'svn-create-patch')] + changed_files,
cwd=self.checkout_root, return_stderr=False,
decode_output=False)
def blame(self, path):
return self._run_svn(['blame', path])
engine*ChangeLog
engine*
Tools*ChangeLog
Tools*
Websites*ChangeLog
Websites*
tools*ChangeLog
tools*
tests*ChangeLog
tests*
......@@ -36,7 +36,7 @@ import time
import unittest
# Since we execute this script directly as part of the unit tests, we need to ensure
# that Tools/Scripts and Tools/Scripts/thirdparty are in sys.path for the next imports to work correctly.
# that tools and tools/thirdparty are in sys.path for the next imports to work correctly.
script_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
if script_dir not in sys.path:
sys.path.append(script_dir)
......
......@@ -96,7 +96,7 @@ class MockFileSystem(object):
return home_directory + self.sep + parts[1]
def path_to_module(self, module_name):
return "/mock-checkout/third_party/WebKit/Tools/Scripts/" + module_name.replace('.', '/') + ".py"
return "/mock-checkout/third_party/WebKit/tools/" + module_name.replace('.', '/') + ".py"
def chdir(self, path):
path = self.normpath(path)
......
......@@ -46,10 +46,10 @@ class GetLoggerTest(unittest.TestCase):
root_dir = "/"
os.chdir(root_dir)
logger = logutils.get_logger("/Tools/Scripts/test-webkitpy")
logger = logutils.get_logger("/tools/test-webkitpy")
self.assertEqual(logger.name, "test-webkitpy")
logger = logutils.get_logger("/Tools/Scripts/test-webkitpy.py")
logger = logutils.get_logger("/tools/test-webkitpy.py")
self.assertEqual(logger.name, "test-webkitpy")
os.chdir(working_directory)
......
......@@ -48,7 +48,7 @@ class WebKitFinder(object):
# scm.find_checkout_root(). However, that code only works if the top
# of the SCM repository also matches the top of the WebKit tree. Some SVN users
# (the chromium test bots, for example), might only check out subdirectories like
# Tools/Scripts. This code will also work if there is no SCM system at all.
# tools. This code will also work if there is no SCM system at all.
if not self._webkit_base:
self._webkit_base = self._webkit_base
module_path = self._filesystem.abspath(self._filesystem.path_to_module(self.__module__))
......
......@@ -146,7 +146,7 @@ class Bisector(object):
def test_fails(self, tests):
extra_args = ['--debug'] if self.is_debug else []
path_to_run_webkit_tests = self.webkit_finder.path_from_webkit_base('Tools', 'Scripts', 'run-webkit-tests')
path_to_run_webkit_tests = self.webkit_finder.path_from_webkit_base('tools', 'test_sky')
output = self.executive.popen([path_to_run_webkit_tests, '--child-processes', '1', '--order', 'none', '--no-retry', '--no-show-results', '--verbose'] + extra_args + tests, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
failure_string = self.expected_failure + ' failed'
if failure_string in output.stderr.read():
......
......@@ -44,7 +44,7 @@ import sys
import types
# Since we execute this script directly as part of the unit tests, we need to ensure
# that Tools/Scripts is in sys.path for the next imports to work correctly.
# that tools is in sys.path for the next imports to work correctly.
script_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
if script_dir not in sys.path:
sys.path.append(script_dir)
......
......@@ -59,7 +59,7 @@ class PyWebSocket(server_base.ServerBase):
time_str = time.strftime('%d%b%Y-%H%M%S')
log_file_name = _WS_LOG_PREFIX + time_str
self._error_log = self._filesystem.join(self._output_dir, log_file_name + "-err.txt")
pywebsocket_base = self._port_obj.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty')
pywebsocket_base = self._port_obj.path_from_webkit_base('tools', 'webkitpy', 'thirdparty')
pywebsocket_script = self._filesystem.join(pywebsocket_base, 'mod_pywebsocket', 'standalone.py')
self._start_cmd = [
......
......@@ -51,25 +51,12 @@ def main():
filesystem = FileSystem()
wkf = WebKitFinder(filesystem)
tester = Tester(filesystem, wkf)
tester.add_tree(wkf.path_from_webkit_base('Tools', 'Scripts'), 'webkitpy')
tester.add_tree(wkf.path_from_webkit_base('tools'), 'webkitpy')
tester.skip(('webkitpy.common.checkout.scm.scm_unittest',), 'are really, really, slow', 31818)
if sys.platform == 'win32':
tester.skip(('webkitpy.common.checkout', 'webkitpy.common.config', 'webkitpy.tool', 'webkitpy.w3c', 'webkitpy.layout_tests.layout_package.bot_test_expectations'), 'fail horribly on win32', 54526)
# This only needs to run on Unix, so don't worry about win32 for now.
appengine_sdk_path = '/usr/local/google_appengine'
if os.path.exists(appengine_sdk_path):
if not appengine_sdk_path in sys.path:
sys.path.append(appengine_sdk_path)
import dev_appserver
from google.appengine.dist import use_library
use_library('django', '1.2')
dev_appserver.fix_sys_path()
tester.add_tree(wkf.path_from_webkit_base('Tools', 'TestResultServer'))
else:
_log.info('Skipping TestResultServer tests; the Google AppEngine Python SDK is not installed.')
return not tester.run()
......@@ -118,7 +105,7 @@ class Tester(object):
sys.path = self.finder.additional_paths(sys.path) + sys.path
# FIXME: coverage needs to be in sys.path for its internal imports to work.
thirdparty_path = self.webkit_finder.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty')
thirdparty_path = self.webkit_finder.path_from_webkit_base('tools', 'webkitpy', 'thirdparty')
if not thirdparty_path in sys.path:
sys.path.append(thirdparty_path)
......
......@@ -79,7 +79,7 @@ class TesterTest(unittest.TestCase):
def test_coverage_works(self):
# This is awkward; by design, running test-webkitpy -c will
# create a .coverage file in Tools/Scripts, so we need to be
# create a .coverage file in tools, so we need to be
# careful not to clobber an existing one, and to clean up.
# FIXME: This design needs to change since it means we can't actually
# run this method itself under coverage properly.
......
......@@ -73,7 +73,7 @@ class _Worker(object):
self._loader = loader
# FIXME: coverage needs to be in sys.path for its internal imports to work.
thirdparty_path = webkit_finder.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty')
thirdparty_path = webkit_finder.path_from_webkit_base('tools', 'webkitpy', 'thirdparty')
if not thirdparty_path in sys.path:
sys.path.append(thirdparty_path)
......
# Required for Python to search this directory for module files
from webkitpy.tool.commands.commitannouncer import CommitAnnouncerCommand
from webkitpy.tool.commands.flakytests import FlakyTests
from webkitpy.tool.commands.prettydiff import PrettyDiff
from webkitpy.tool.commands.queries import *
from webkitpy.tool.commands.rebaseline import Rebaseline
from webkitpy.tool.commands.rebaselineserver import RebaselineServer
# Copyright (c) 2013 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import logging
from optparse import make_option
import time
import traceback
from webkitpy.common.config.irc import update_wait_seconds
from webkitpy.tool.bot.commitannouncer import CommitAnnouncer, CommitAnnouncerThread
from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand
_log = logging.getLogger(__name__)
class CommitAnnouncerCommand(AbstractDeclarativeCommand):
name = "commit-announcer"
help_text = "Start an IRC bot for announcing new git commits."
show_in_main_help = True
def __init__(self):
options = [
make_option("--irc-password", default=None, help="Specify IRC password to use."),
]
AbstractDeclarativeCommand.__init__(self, options)
def execute(self, options, args, tool):
bot_thread = CommitAnnouncerThread(tool, options.irc_password)
bot_thread.start()
_log.info("Bot started")
try:
while bot_thread.is_alive():
bot_thread.bot.post_new_commits()
time.sleep(update_wait_seconds)
except KeyboardInterrupt:
_log.error("Terminated by keyboard interrupt")
except Exception, e:
_log.error("Unexpected error:")
_log.error(traceback.format_exc())
if bot_thread.is_alive():
_log.info("Disconnecting bot")
bot_thread.stop()
else:
_log.info("Bot offline")
_log.info("Done")
......@@ -925,7 +925,7 @@ class RebaselineOMatic(AbstractDeclarativeCommand):
try:
old_branch_name = self._tool.scm().current_branch()
self._run_logged_command(['git', 'pull'])
rebaseline_command = [self._tool.filesystem.join(self._tool.scm().checkout_root, 'Tools', 'Scripts', 'webkit-patch'), 'auto-rebaseline']
rebaseline_command = [self._tool.filesystem.join(self._tool.scm().checkout_root, 'tools', 'webkit-patch'), 'auto-rebaseline']
if self._verbose:
rebaseline_command.append('--verbose')
self._run_logged_command(rebaseline_command)
......
......@@ -1246,7 +1246,7 @@ class TestRebaselineOMatic(_BaseTestCase):
self.assertEqual(out, '')
self.assertEqual(self.tool.executive.calls, [
['git', 'pull'],
['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'auto-rebaseline'],
['/mock-checkout/third_party/WebKit/tools/webkit-patch', 'auto-rebaseline'],
])
self.assertEqual(self._logs, ['MOCK STDOUT'])
......@@ -1262,6 +1262,6 @@ class TestRebaselineOMatic(_BaseTestCase):
self.assertEqual(out, 'MOCK STDOUT\n')
self.assertEqual(self.tool.executive.calls, [
['git', 'pull'],
['/mock-checkout/third_party/WebKit/Tools/Scripts/webkit-patch', 'auto-rebaseline', '--verbose'],
['/mock-checkout/third_party/WebKit/tools/webkit-patch', 'auto-rebaseline', '--verbose'],
])
self.assertEqual(self._logs, ['MOCK STDOUT'])
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册