summaryrefslogtreecommitdiffstats
path: root/Tools/Scripts/webkitpy/tool
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Tools/Scripts/webkitpy/tool
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Tools/Scripts/webkitpy/tool')
-rw-r--r--Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py23
-rw-r--r--Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py38
-rw-r--r--Tools/Scripts/webkitpy/tool/bot/feeders.py5
-rw-r--r--Tools/Scripts/webkitpy/tool/bot/feeders_unittest.py10
-rw-r--r--Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py48
-rw-r--r--Tools/Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py24
-rw-r--r--Tools/Scripts/webkitpy/tool/commands/queues.py24
-rw-r--r--Tools/Scripts/webkitpy/tool/commands/queues_unittest.py24
-rwxr-xr-xTools/Scripts/webkitpy/tool/main.py17
-rw-r--r--Tools/Scripts/webkitpy/tool/mocktool.py15
-rw-r--r--Tools/Scripts/webkitpy/tool/steps/preparechangelog.py2
-rw-r--r--Tools/Scripts/webkitpy/tool/steps/validatechangelogs.py3
-rw-r--r--Tools/Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py18
13 files changed, 198 insertions, 53 deletions
diff --git a/Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py b/Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py
index 4bdc79b..3be2556 100644
--- a/Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py
+++ b/Tools/Scripts/webkitpy/tool/bot/commitqueuetask.py
@@ -46,7 +46,11 @@ class CommitQueueTaskDelegate(object):
def layout_test_results(self):
raise NotImplementedError("subclasses must implement")
- def report_flaky_tests(self, patch, flaky_tests):
+ def archive_last_layout_test_results(self, patch):
+ raise NotImplementedError("subclasses must implement")
+
+ # We could make results_archive optional, but for now it's required.
+ def report_flaky_tests(self, patch, flaky_tests, results_archive):
raise NotImplementedError("subclasses must implement")
@@ -66,6 +70,8 @@ class CommitQueueTask(object):
return False
if not self._patch.committer():
return False
+ if not self._patch.review() != "-":
+ return False
# Reviewer is not required. Missing reviewers will be caught during
# the ChangeLog check during landing.
return True
@@ -168,8 +174,8 @@ class CommitQueueTask(object):
"Landed patch",
"Unable to land patch")
- def _report_flaky_tests(self, flaky_test_results):
- self._delegate.report_flaky_tests(self._patch, flaky_test_results)
+ def _report_flaky_tests(self, flaky_test_results, results_archive):
+ self._delegate.report_flaky_tests(self._patch, flaky_test_results, results_archive)
def _test_patch(self):
if self._patch.is_rollout():
@@ -177,14 +183,15 @@ class CommitQueueTask(object):
if self._test():
return True
- first_failing_results = self._failing_results_from_last_run()
- first_failing_tests = [result.filename for result in first_failing_results]
+ first_results = self._failing_results_from_last_run()
+ first_failing_tests = [result.filename for result in first_results]
+ first_results_archive = self._delegate.archive_last_layout_test_results(self._patch)
if self._test():
- self._report_flaky_tests(first_failing_results)
+ self._report_flaky_tests(first_results, first_results_archive)
return True
- second_failing_results = self._failing_results_from_last_run()
- second_failing_tests = [result.filename for result in second_failing_results]
+ second_results = self._failing_results_from_last_run()
+ second_failing_tests = [result.filename for result in second_results]
if first_failing_tests != second_failing_tests:
# We could report flaky tests here, but since run-webkit-tests
# is run with --exit-after-N-failures=1, we would need to
diff --git a/Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py b/Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py
index f279cac..26231ae 100644
--- a/Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py
+++ b/Tools/Scripts/webkitpy/tool/bot/commitqueuetask_unittest.py
@@ -29,6 +29,7 @@
from datetime import datetime
import unittest
+from webkitpy.common.net import bugzilla
from webkitpy.common.system.deprecated_logging import error, log
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.layout_tests.layout_package import test_results
@@ -64,9 +65,15 @@ class MockCommitQueue(CommitQueueTaskDelegate):
def layout_test_results(self):
return None
- def report_flaky_tests(self, patch, flaky_results):
+ def report_flaky_tests(self, patch, flaky_results, results_archive):
flaky_tests = [result.filename for result in flaky_results]
- log("report_flaky_tests: patch='%s' flaky_tests='%s'" % (patch.id(), flaky_tests))
+ log("report_flaky_tests: patch='%s' flaky_tests='%s' archive='%s'" % (patch.id(), flaky_tests, results_archive.filename))
+
+ def archive_last_layout_test_results(self, patch):
+ log("archive_last_layout_test_results: patch='%s'" % patch.id())
+ archive = Mock()
+ archive.filename = "mock-archive-%s.zip" % patch.id()
+ return archive
class CommitQueueTaskTest(unittest.TestCase):
@@ -193,9 +200,10 @@ run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=both']
command_passed: success_message='Built patch' patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_failed: failure_message='Patch does not pass tests' script_error='MOCK tests failure' patch='197'
+archive_last_layout_test_results: patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_passed: success_message='Passed tests' patch='197'
-report_flaky_tests: patch='197' flaky_tests='[]'
+report_flaky_tests: patch='197' flaky_tests='[]' archive='mock-archive-197.zip'
run_webkit_patch: ['land-attachment', '--force-clean', '--ignore-builders', '--non-interactive', '--parent-command=commit-queue', 197]
command_passed: success_message='Landed patch' patch='197'
"""
@@ -225,6 +233,7 @@ run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=both']
command_passed: success_message='Built patch' patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_failed: failure_message='Patch does not pass tests' script_error='MOCK test failure' patch='197'
+archive_last_layout_test_results: patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_failed: failure_message='Patch does not pass tests' script_error='MOCK test failure again' patch='197'
"""
@@ -262,6 +271,7 @@ run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=both']
command_passed: success_message='Built patch' patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_failed: failure_message='Patch does not pass tests' script_error='MOCK test failure' patch='197'
+archive_last_layout_test_results: patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_failed: failure_message='Patch does not pass tests' script_error='MOCK test failure again' patch='197'
run_webkit_patch: ['build-and-test', '--force-clean', '--no-update', '--build', '--test', '--non-interactive']
@@ -289,6 +299,7 @@ run_webkit_patch: ['build', '--no-clean', '--no-update', '--build-style=both']
command_passed: success_message='Built patch' patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_failed: failure_message='Patch does not pass tests' script_error='MOCK test failure' patch='197'
+archive_last_layout_test_results: patch='197'
run_webkit_patch: ['build-and-test', '--no-clean', '--no-update', '--test', '--non-interactive']
command_failed: failure_message='Patch does not pass tests' script_error='MOCK test failure again' patch='197'
run_webkit_patch: ['build-and-test', '--force-clean', '--no-update', '--build', '--test', '--non-interactive']
@@ -320,3 +331,24 @@ command_failed: failure_message='Unable to land patch' script_error='MOCK land f
"""
# FIXME: This should really be expect_retry=True for a better user experiance.
self._run_through_task(commit_queue, expected_stderr, ScriptError)
+
+ def _expect_validate(self, patch, is_valid):
+ class MockDelegate(object):
+ def refetch_patch(self, patch):
+ return patch
+
+ task = CommitQueueTask(MockDelegate(), patch)
+ self.assertEquals(task._validate(), is_valid)
+
+ def _mock_patch(self, attachment_dict={}, bug_dict={'bug_status': 'NEW'}, committer="fake"):
+ bug = bugzilla.Bug(bug_dict, None)
+ patch = bugzilla.Attachment(attachment_dict, bug)
+ patch._committer = committer
+ return patch
+
+ def test_validate(self):
+ self._expect_validate(self._mock_patch(), True)
+ self._expect_validate(self._mock_patch({'is_obsolete': True}), False)
+ self._expect_validate(self._mock_patch(bug_dict={'bug_status': 'CLOSED'}), False)
+ self._expect_validate(self._mock_patch(committer=None), False)
+ self._expect_validate(self._mock_patch({'review': '-'}), False)
diff --git a/Tools/Scripts/webkitpy/tool/bot/feeders.py b/Tools/Scripts/webkitpy/tool/bot/feeders.py
index 046c4c1..0b7f23d 100644
--- a/Tools/Scripts/webkitpy/tool/bot/feeders.py
+++ b/Tools/Scripts/webkitpy/tool/bot/feeders.py
@@ -54,6 +54,7 @@ class CommitQueueFeeder(AbstractFeeder):
def feed(self):
patches = self._validate_patches()
+ patches = self._patches_with_acceptable_review_flag(patches)
patches = sorted(patches, self._patch_cmp)
patch_ids = [patch.id() for patch in patches]
self._update_work_items(patch_ids)
@@ -61,6 +62,10 @@ class CommitQueueFeeder(AbstractFeeder):
def _patches_for_bug(self, bug_id):
return self._tool.bugs.fetch_bug(bug_id).commit_queued_patches(include_invalid=True)
+ # Filters out patches with r? or r-, only r+ or no review are OK to land.
+ def _patches_with_acceptable_review_flag(self, patches):
+ return [patch for patch in patches if patch.review() in [None, '+']]
+
def _validate_patches(self):
# Not using BugzillaQueries.fetch_patches_from_commit_queue() so we can reject patches with invalid committers/reviewers.
bug_ids = self._tool.bugs.queries.fetch_bug_ids_from_commit_queue()
diff --git a/Tools/Scripts/webkitpy/tool/bot/feeders_unittest.py b/Tools/Scripts/webkitpy/tool/bot/feeders_unittest.py
index 580f840..e956a8f 100644
--- a/Tools/Scripts/webkitpy/tool/bot/feeders_unittest.py
+++ b/Tools/Scripts/webkitpy/tool/bot/feeders_unittest.py
@@ -68,3 +68,13 @@ Feeding commit-queue items [106, 197]
queue = CommitQueueFeeder(MockTool())
attachments.sort(queue._patch_cmp)
self.assertEqual(attachments, expected_sort)
+
+ def test_patches_with_acceptable_review_flag(self):
+ class MockPatch(object):
+ def __init__(self, patch_id, review):
+ self.id = patch_id
+ self.review = lambda: review
+
+ feeder = CommitQueueFeeder(MockTool())
+ patches = [MockPatch(1, None), MockPatch(2, '-'), MockPatch(3, "+")]
+ self.assertEquals([patch.id for patch in feeder._patches_with_acceptable_review_flag(patches)], [1, 3])
diff --git a/Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py b/Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py
index 91fcb85..270a656 100644
--- a/Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py
+++ b/Tools/Scripts/webkitpy/tool/bot/flakytestreporter.py
@@ -131,13 +131,10 @@ If you would like to track this test fix with another bug, please close this bug
flake_message = "The %s just saw %s flake (%s) while processing attachment %s on bug %s." % (self._bot_name, flaky_result.filename, ", ".join(failure_messages), patch.id(), patch.bug_id())
return "%s\n%s" % (flake_message, self._bot_information())
- def _results_diff_path_for_test(self, flaky_test):
+ def _results_diff_path_for_test(self, test_path):
# FIXME: This is a big hack. We should get this path from results.json
# except that old-run-webkit-tests doesn't produce a results.json
# so we just guess at the file path.
- results_path = self._tool.port().layout_tests_results_path()
- results_directory = os.path.dirname(results_path)
- test_path = os.path.join(results_directory, flaky_test)
(test_path_root, _) = os.path.splitext(test_path)
return "%s-diffs.txt" % test_path_root
@@ -153,7 +150,32 @@ If you would like to track this test fix with another bug, please close this bug
else:
self._tool.bugs.post_comment_to_bug(bug.id(), latest_flake_message)
- def report_flaky_tests(self, flaky_test_results, patch):
+ # This method is needed because our archive paths include a leading tmp/layout-test-results
+ def _find_in_archive(self, path, archive):
+ for archived_path in archive.namelist():
+ # Archives are currently created with full paths.
+ if archived_path.endswith(path):
+ return archived_path
+ return None
+
+ def _attach_failure_diff(self, flake_bug_id, flaky_test, results_archive):
+ results_diff_path = self._results_diff_path_for_test(flaky_test)
+ # Check to make sure that the path makes sense.
+ # Since we're not actually getting this path from the results.html
+ # there is a chance it's wrong.
+ bot_id = self._tool.status_server.bot_id or "bot"
+ archive_path = self._find_in_archive(results_diff_path, results_archive)
+ if archive_path:
+ results_diff = results_archive.read(archive_path)
+ description = "Failure diff from %s" % bot_id
+ self._tool.bugs.add_attachment_to_bug(flake_bug_id, results_diff, description, filename="failure.diff")
+ else:
+ _log.warn("%s does not exist in results archive, uploading entire archive." % results_diff_path)
+ description = "Archive of layout-test-results from %s" % bot_id
+ # results_archive is a ZipFile object, grab the File object (.fp) to pass to Mechanize for uploading.
+ self._tool.bugs.add_attachment_to_bug(flake_bug_id, results_archive.fp, description, filename="layout-test-results.zip")
+
+ def report_flaky_tests(self, patch, flaky_test_results, results_archive):
message = "The %s encountered the following flaky tests while processing attachment %s:\n\n" % (self._bot_name, patch.id())
for flaky_result in flaky_test_results:
flaky_test = flaky_result.filename
@@ -165,20 +187,12 @@ If you would like to track this test fix with another bug, please close this bug
flake_bug_id = self._create_bug_for_flaky_test(flaky_test, author_emails, latest_flake_message)
else:
bug = self._follow_duplicate_chain(bug)
+ # FIXME: Ideally we'd only make one comment per flake, not two. But that's not possible
+ # in all cases (e.g. when reopening), so for now file attachment and comment are separate.
self._update_bug_for_flaky_test(bug, latest_flake_message)
flake_bug_id = bug.id()
- # FIXME: Ideally we'd only make one comment per flake, not two. But that's not possible
- # in all cases (e.g. when reopening), so for now we do the attachment in a second step.
- results_diff_path = self._results_diff_path_for_test(flaky_test)
- # Check to make sure that the path makes sense.
- # Since we're not actually getting this path from the results.html
- # there is a high probaility it's totally wrong.
- if self._tool.filesystem.exists(results_diff_path):
- results_diff = self._tool.filesystem.read_binary_file(results_diff_path)
- bot_id = self._tool.status_server.bot_id or "bot"
- self._tool.bugs.add_attachment_to_bug(flake_bug_id, results_diff, "Failure diff from %s" % bot_id, filename="failure.diff")
- else:
- _log.error("%s does not exist as expected, not uploading." % results_diff_path)
+
+ self._attach_failure_diff(flake_bug_id, flaky_test, results_archive)
message += "%s bug %s%s\n" % (flaky_test, flake_bug_id, self._optional_author_string(author_emails))
message += "The %s is continuing to process your patch." % self._bot_name
diff --git a/Tools/Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py b/Tools/Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py
index 631f8d1..26c98c1 100644
--- a/Tools/Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py
+++ b/Tools/Scripts/webkitpy/tool/bot/flakytestreporter_unittest.py
@@ -33,6 +33,7 @@ from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.layout_tests.layout_package import test_results
from webkitpy.layout_tests.layout_package import test_failures
+from webkitpy.thirdparty.mock import Mock
from webkitpy.tool.bot.flakytestreporter import FlakyTestReporter
from webkitpy.tool.mocktool import MockTool, MockStatusServer
@@ -140,7 +141,15 @@ The dummy-queue is continuing to process your patch.
"""
test_results = [self._mock_test_result('foo/bar.html')]
- OutputCapture().assert_outputs(self, reporter.report_flaky_tests, [test_results, patch], expected_stderr=expected_stderr)
+
+ class MockZipFile(object):
+ def read(self, path):
+ return ""
+
+ def namelist(self):
+ return ['foo/bar-diffs.txt']
+
+ OutputCapture().assert_outputs(self, reporter.report_flaky_tests, [patch, test_results, MockZipFile()], expected_stderr=expected_stderr)
def test_optional_author_string(self):
reporter = FlakyTestReporter(MockTool(), 'dummy-queue')
@@ -150,6 +159,15 @@ The dummy-queue is continuing to process your patch.
def test_results_diff_path_for_test(self):
reporter = FlakyTestReporter(MockTool(), 'dummy-queue')
- self.assertEqual(reporter._results_diff_path_for_test("test.html"), "/mock/test-diffs.txt")
+ self.assertEqual(reporter._results_diff_path_for_test("test.html"), "test-diffs.txt")
+
+ def test_find_in_archive(self):
+ reporter = FlakyTestReporter(MockTool(), 'dummy-queue')
+
+ class MockZipFile(object):
+ def namelist(self):
+ return ["tmp/layout-test-results/foo/bar-diffs.txt"]
- # report_flaky_tests is also tested by queues_unittest
+ reporter._find_in_archive("foo/bar-diffs.txt", MockZipFile())
+ # This is not ideal, but its
+ reporter._find_in_archive("txt", MockZipFile())
diff --git a/Tools/Scripts/webkitpy/tool/commands/queues.py b/Tools/Scripts/webkitpy/tool/commands/queues.py
index 5628543..42321cf 100644
--- a/Tools/Scripts/webkitpy/tool/commands/queues.py
+++ b/Tools/Scripts/webkitpy/tool/commands/queues.py
@@ -309,12 +309,32 @@ class CommitQueue(AbstractPatchQueue, StepSequenceErrorHandler, CommitQueueTaskD
return None
return LayoutTestResults.results_from_string(results_html)
+ def _results_directory(self):
+ results_path = self._tool.port().layout_tests_results_path()
+ # FIXME: This is wrong in two ways:
+ # 1. It assumes that results.html is at the top level of the results tree.
+ # 2. This uses the "old" ports.py infrastructure instead of the new layout_tests/port
+ # which will not support Chromium. However the new arch doesn't work with old-run-webkit-tests
+ # so we have to use this for now.
+ return os.path.dirname(results_path)
+
+ def archive_last_layout_test_results(self, patch):
+ results_directory = self._results_directory()
+ results_name, _ = os.path.splitext(os.path.basename(results_directory))
+ # Note: We name the zip with the bug_id instead of patch_id to match work_item_log_path().
+ zip_path = self._tool.workspace.find_unused_filename(self._log_directory(), "%s-%s" % (patch.bug_id(), results_name), "zip")
+ archive = self._tool.workspace.create_zip(zip_path, results_directory)
+ # Remove the results directory to prevent http logs, etc. from getting huge between runs.
+ # We could have create_zip remove the original, but this is more explicit.
+ self._tool.filesystem.remove_tree(results_directory, ignore_errors=True)
+ return archive
+
def refetch_patch(self, patch):
return self._tool.bugs.fetch_attachment(patch.id())
- def report_flaky_tests(self, patch, flaky_test_results):
+ def report_flaky_tests(self, patch, flaky_test_results, results_archive=None):
reporter = FlakyTestReporter(self._tool, self.name)
- reporter.report_flaky_tests(flaky_test_results, patch)
+ reporter.report_flaky_tests(patch, flaky_test_results, results_archive)
# StepSequenceErrorHandler methods
diff --git a/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py b/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py
index 34a6a64..8f5c9e6 100644
--- a/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py
+++ b/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py
@@ -27,9 +27,11 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
+import StringIO
from webkitpy.common.checkout.scm import CheckoutNeedsUpdate
from webkitpy.common.net.bugzilla import Attachment
+from webkitpy.common.system.filesystem_mock import MockFileSystem
from webkitpy.common.system.outputcapture import OutputCapture
from webkitpy.layout_tests.layout_package import test_results
from webkitpy.layout_tests.layout_package import test_failures
@@ -342,12 +344,14 @@ The commit-queue just saw foo/bar.html flake (Text diff mismatch) while processi
Port: MockPort Platform: MockPlatform 1.0
--- End comment ---
+MOCK add_attachment_to_bug: bug_id=76, description=Failure diff from bot filename=failure.diff
MOCK bug comment: bug_id=76, cc=None
--- Begin comment ---
The commit-queue just saw bar/baz.html flake (Text diff mismatch) while processing attachment 197 on bug 42.
Port: MockPort Platform: MockPlatform 1.0
--- End comment ---
+MOCK add_attachment_to_bug: bug_id=76, description=Archive of layout-test-results from bot filename=layout-test-results.zip
MOCK bug comment: bug_id=42, cc=None
--- Begin comment ---
The commit-queue encountered the following flaky tests while processing attachment 197:
@@ -360,7 +364,19 @@ The commit-queue is continuing to process your patch.
"""
test_names = ["foo/bar.html", "bar/baz.html"]
test_results = [self._mock_test_result(name) for name in test_names]
- OutputCapture().assert_outputs(self, queue.report_flaky_tests, [QueuesTest.mock_work_item, test_results], expected_stderr=expected_stderr)
+
+ class MockZipFile(object):
+ def __init__(self):
+ self.fp = StringIO()
+
+ def read(self, path):
+ return ""
+
+ def namelist(self):
+ # This is intentionally missing one diffs.txt to exercise the "upload the whole zip" codepath.
+ return ['foo/bar-diffs.txt']
+
+ OutputCapture().assert_outputs(self, queue.report_flaky_tests, [QueuesTest.mock_work_item, test_results, MockZipFile()], expected_stderr=expected_stderr)
def test_layout_test_results(self):
queue = CommitQueue()
@@ -370,6 +386,12 @@ The commit-queue is continuing to process your patch.
queue._read_file_contents = lambda path: ""
self.assertEquals(queue.layout_test_results(), None)
+ def test_archive_last_layout_test_results(self):
+ queue = CommitQueue()
+ queue.bind_to_tool(MockTool())
+ patch = queue._tool.bugs.fetch_attachment(128)
+ queue.archive_last_layout_test_results(patch)
+
class StyleQueueTest(QueuesTest):
def test_style_queue(self):
diff --git a/Tools/Scripts/webkitpy/tool/main.py b/Tools/Scripts/webkitpy/tool/main.py
index 0006e87..76d5bef 100755
--- a/Tools/Scripts/webkitpy/tool/main.py
+++ b/Tools/Scripts/webkitpy/tool/main.py
@@ -40,10 +40,7 @@ from webkitpy.common.net.bugzilla import Bugzilla
from webkitpy.common.net.buildbot import BuildBot
from webkitpy.common.net.irc.ircproxy import IRCProxy
from webkitpy.common.net.statusserver import StatusServer
-from webkitpy.common.system.executive import Executive
-from webkitpy.common.system.filesystem import FileSystem
-from webkitpy.common.system.platforminfo import PlatformInfo
-from webkitpy.common.system.user import User
+from webkitpy.common.system import executive, filesystem, platforminfo, user, workspace
from webkitpy.layout_tests import port
from webkitpy.tool.multicommandtool import MultiCommandTool
import webkitpy.tool.commands as commands
@@ -52,6 +49,7 @@ import webkitpy.tool.commands as commands
class WebKitPatch(MultiCommandTool):
global_options = [
make_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="enable all logging"),
+ make_option("-d", "--directory", action="append", dest="patch_directories", default=[], help="Directory to look at for changed files"),
make_option("--dry-run", action="store_true", dest="dry_run", default=False, help="do not touch remote servers"),
make_option("--status-host", action="store", dest="status_host", type="string", help="Hostname (e.g. localhost or commit.webkit.org) where status updates should be posted."),
make_option("--bot-id", action="store", dest="bot_id", type="string", help="Identifier for this bot (if multiple bots are running for a queue)"),
@@ -70,21 +68,22 @@ class WebKitPatch(MultiCommandTool):
# manual getter functions (e.g. scm()).
self.bugs = Bugzilla()
self.buildbot = BuildBot()
- self.executive = Executive()
+ self.executive = executive.Executive()
self._irc = None
- self.filesystem = FileSystem()
+ self.filesystem = filesystem.FileSystem()
+ self.workspace = workspace.Workspace(self.filesystem, self.executive)
self._port = None
- self.user = User()
+ self.user = user.User()
self._scm = None
self._checkout = None
self.status_server = StatusServer()
self.port_factory = port.factory
- self.platform = PlatformInfo()
+ self.platform = platforminfo.PlatformInfo()
def scm(self):
# Lazily initialize SCM to not error-out before command line parsing (or when running non-scm commands).
if not self._scm:
- self._scm = default_scm()
+ self._scm = default_scm(self._options.patch_directories)
return self._scm
def checkout(self):
diff --git a/Tools/Scripts/webkitpy/tool/mocktool.py b/Tools/Scripts/webkitpy/tool/mocktool.py
index eb7c248..7db2996 100644
--- a/Tools/Scripts/webkitpy/tool/mocktool.py
+++ b/Tools/Scripts/webkitpy/tool/mocktool.py
@@ -623,10 +623,10 @@ class MockStatusServer(object):
# FIXME: Unify with common.system.executive_mock.MockExecutive.
class MockExecutive(Mock):
def __init__(self, should_log):
- self._should_log = should_log
+ self.should_log = should_log
def run_and_throw_if_fail(self, args, quiet=False):
- if self._should_log:
+ if self.should_log:
log("MOCK run_and_throw_if_fail: %s" % args)
return "MOCK output of child process"
@@ -638,7 +638,7 @@ class MockExecutive(Mock):
return_exit_code=False,
return_stderr=True,
decode_output=False):
- if self._should_log:
+ if self.should_log:
log("MOCK run_command: %s" % args)
return "MOCK output of child process"
@@ -686,6 +686,14 @@ class MockPlatformInfo(object):
return "MockPlatform 1.0"
+class MockWorkspace(object):
+ def find_unused_filename(self, directory, name, extension, search_limit=10):
+ return "%s/%s.%s" % (directory, name, extension)
+
+ def create_zip(self, zip_path, source_path):
+ pass
+
+
class MockTool(object):
def __init__(self, log_executive=False):
@@ -694,6 +702,7 @@ class MockTool(object):
self.buildbot = MockBuildBot()
self.executive = MockExecutive(should_log=log_executive)
self.filesystem = MockFileSystem()
+ self.workspace = MockWorkspace()
self._irc = None
self.user = MockUser()
self._scm = MockSCM()
diff --git a/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py b/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py
index 099dfe3..392cd32 100644
--- a/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py
+++ b/Tools/Scripts/webkitpy/tool/steps/preparechangelog.py
@@ -70,6 +70,8 @@ class PrepareChangeLog(AbstractStep):
if self._tool.scm().supports_local_commits():
args.append("--merge-base=%s" % self._tool.scm().merge_base(self._options.git_commit))
+ args.extend(self._changed_files(state))
+
try:
self._tool.executive.run_and_throw_if_fail(args, self._options.quiet)
except ScriptError, e:
diff --git a/Tools/Scripts/webkitpy/tool/steps/validatechangelogs.py b/Tools/Scripts/webkitpy/tool/steps/validatechangelogs.py
index e812f94..a27ed77 100644
--- a/Tools/Scripts/webkitpy/tool/steps/validatechangelogs.py
+++ b/Tools/Scripts/webkitpy/tool/steps/validatechangelogs.py
@@ -44,6 +44,9 @@ class ValidateChangeLogs(AbstractStep):
# later than that, assume that the entry is wrong.
if diff_file.lines[0][0] < 8:
return True
+ if self._options.non_interactive:
+ return False
+
log("The diff to %s looks wrong. Are you sure your ChangeLog entry is at the top of the file?" % (diff_file.filename))
# FIXME: Do we need to make the file path absolute?
self._tool.scm().diff_for_file(diff_file.filename)
diff --git a/Tools/Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py b/Tools/Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py
index 66db793..db35a58 100644
--- a/Tools/Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py
+++ b/Tools/Scripts/webkitpy/tool/steps/validatechangelogs_unittest.py
@@ -36,20 +36,24 @@ from webkitpy.tool.steps.validatechangelogs import ValidateChangeLogs
class ValidateChangeLogsTest(unittest.TestCase):
- def _assert_start_line_produces_output(self, start_line, should_prompt_user=False):
+ def _assert_start_line_produces_output(self, start_line, should_fail=False, non_interactive=False):
tool = MockTool()
tool._checkout.is_path_to_changelog = lambda path: True
- step = ValidateChangeLogs(tool, MockOptions(git_commit=None))
+ step = ValidateChangeLogs(tool, MockOptions(git_commit=None, non_interactive=non_interactive))
diff_file = Mock()
diff_file.filename = "mock/ChangeLog"
diff_file.lines = [(start_line, start_line, "foo")]
expected_stdout = expected_stderr = ""
- if should_prompt_user:
+ if should_fail and not non_interactive:
expected_stdout = "OK to continue?\n"
expected_stderr = "The diff to mock/ChangeLog looks wrong. Are you sure your ChangeLog entry is at the top of the file?\n"
- OutputCapture().assert_outputs(self, step._check_changelog_diff, [diff_file], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
+ result = OutputCapture().assert_outputs(self, step._check_changelog_diff, [diff_file], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
+ self.assertEqual(not result, should_fail)
def test_check_changelog_diff(self):
- self._assert_start_line_produces_output(1, should_prompt_user=False)
- self._assert_start_line_produces_output(7, should_prompt_user=False)
- self._assert_start_line_produces_output(8, should_prompt_user=True)
+ self._assert_start_line_produces_output(1)
+ self._assert_start_line_produces_output(7)
+ self._assert_start_line_produces_output(8, should_fail=True)
+
+ self._assert_start_line_produces_output(1, non_interactive=False)
+ self._assert_start_line_produces_output(8, non_interactive=True, should_fail=True)