| Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
|
| index f8629e1baa68f72d32c18d6732d2361b8a27c439..16ef1b9831c0b6060c7d4976ec8be7e0a0ba7f43 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
|
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_exporter_unittest.py
|
| @@ -6,12 +6,25 @@ import unittest
|
|
|
| from webkitpy.common.host_mock import MockHost
|
| from webkitpy.common.system.executive_mock import MockExecutive2
|
| +from webkitpy.w3c.chromium_commit import ChromiumCommit
|
| from webkitpy.w3c.test_exporter import TestExporter
|
| from webkitpy.w3c.wpt_github_mock import MockWPTGitHub
|
|
|
|
|
| +def mock_command_exec(vals):
|
| + def run_fn(args):
|
| + sub_command = args[1]
|
| + return vals.get(sub_command, '')
|
| + return MockExecutive2(run_command_fn=run_fn)
|
| +
|
| +
|
| +
|
| class TestExporterTest(unittest.TestCase):
|
|
|
| + def setUp(self):
|
| + self.host = MockHost()
|
| + self.wpt_github = MockWPTGitHub(pull_requests=[])
|
| +
|
| def test_stops_if_more_than_one_pr_is_in_flight(self):
|
| host = MockHost()
|
| wpt_github = MockWPTGitHub(pull_requests=[{'id': 1}, {'id': 2}])
|
| @@ -69,3 +82,75 @@ class TestExporterTest(unittest.TestCase):
|
| self.assertEqual(wpt_github.calls, ['in_flight_pull_requests', 'create_pr'])
|
| self.assertEqual(wpt_github.pull_requests_created,
|
| [('chromium-export-try', 'older fake text', 'older fake text')])
|
| +
|
| + def test_exportable_commits_since(self):
|
| + self.host.executive = mock_command_exec({
|
| + 'show': 'fake message',
|
| + 'rev-list': 'badbeef8',
|
| + 'rev-parse': 'badbeef8',
|
| + 'crrev-parse': 'badbeef8',
|
| + 'diff': 'fake diff',
|
| + 'diff-tree': 'some\nfiles',
|
| + 'format-patch': 'hey I\'m a patch',
|
| + 'footers': 'cr-rev-position',
|
| + })
|
| + test_exporter = TestExporter(self.host, self.wpt_github)
|
| +
|
| + commits = test_exporter.exportable_commits_since('beefcafe')
|
| + self.assertEqual(len(commits), 1)
|
| + self.assertIsInstance(commits[0], ChromiumCommit)
|
| + self.assertEqual(self.host.executive.calls, [
|
| + ['git', 'rev-parse', '--show-toplevel'],
|
| + ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
|
| + ['git', 'show', '--format=%B', '--no-patch', 'badbeef8'],
|
| + ['git', 'diff-tree', '--no-commit-id', '--name-only', '-r', 'badbeef8']])
|
| +
|
| + def test_ignores_commits_with_noexport_true(self):
|
| + self.host.executive = mock_command_exec({
|
| + 'show': 'Commit message\nNOEXPORT=true',
|
| + 'rev-list': 'badbeef8',
|
| + 'rev-parse': 'badbeef8',
|
| + 'footers': 'cr-rev-position',
|
| + })
|
| + test_exporter = TestExporter(self.host, self.wpt_github)
|
| +
|
| + commits = test_exporter.exportable_commits_since('beefcafe')
|
| + self.assertEqual(len(commits), 0)
|
| + self.assertEqual(self.host.executive.calls, [
|
| + ['git', 'rev-parse', '--show-toplevel'],
|
| + ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
|
| + ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])
|
| +
|
| + def test_ignores_reverted_commits_with_noexport_true(self):
|
| + self.host.executive = mock_command_exec({
|
| + 'show': 'Commit message\n> NOEXPORT=true',
|
| + 'rev-list': 'badbeef8',
|
| + 'rev-parse': 'badbeef8',
|
| + 'footers': 'cr-rev-position',
|
| + })
|
| + wpt_github = MockWPTGitHub(pull_requests=[])
|
| + test_exporter = TestExporter(self.host, wpt_github)
|
| +
|
| + commits = test_exporter.exportable_commits_since('beefcafe')
|
| + self.assertEqual(len(commits), 0)
|
| + self.assertEqual(self.host.executive.calls, [
|
| + ['git', 'rev-parse', '--show-toplevel'],
|
| + ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
|
| + ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])
|
| +
|
| + def test_ignores_commits_that_start_with_import(self):
|
| + self.host.executive = mock_command_exec({
|
| + 'show': 'Import rutabaga@deadbeef',
|
| + 'rev-list': 'badbeef8',
|
| + 'rev-parse': 'badbeef8',
|
| + 'footers': 'cr-rev-position',
|
| + })
|
| + wpt_github = MockWPTGitHub(pull_requests=[])
|
| + test_exporter = TestExporter(self.host, wpt_github)
|
| +
|
| + commits = test_exporter.exportable_commits_since('beefcafe')
|
| + self.assertEqual(len(commits), 0)
|
| + self.assertEqual(self.host.executive.calls, [
|
| + ['git', 'rev-parse', '--show-toplevel'],
|
| + ['git', 'rev-list', 'beefcafe..HEAD', '--reverse', '--', 'badbeef8/third_party/WebKit/LayoutTests/imported/wpt/'],
|
| + ['git', 'show', '--format=%B', '--no-patch', 'badbeef8']])
|
|
|