Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Linting Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import unittest
6 from webkitpy.w3c.local_wpt import LocalWPT
7 from webkitpy.common.host_mock import MockHost
8 from webkitpy.common.system.executive_mock import MockExecutive2
9 from webkitpy.common.system.filesystem_mock import MockFileSystem
10
11
12 class LocalWPTTest(unittest.TestCase):
13
14 def test_fetches_if_wpt_exists(self):
15 host = MockHost()
16 host.executive = MockExecutive2()
17 host.filesystem = MockFileSystem(files={
18 '/tmp/wpt': ''
19 })
20
21 LocalWPT(host)
22
23 self.assertEqual(len(host.executive.calls), 3)
24 self.assertEqual(host.executive.calls[0][1], 'checkout')
25 self.assertEqual(host.executive.calls[1][1], 'fetch')
26 self.assertEqual(host.executive.calls[2][1], 'merge')
27
28 def test_clones_if_wpt_does_not_exist(self):
29 host = MockHost()
30 host.executive = MockExecutive2()
31 host.filesystem = MockFileSystem()
32
33 LocalWPT(host)
34
35 self.assertEqual(len(host.executive.calls), 1)
36 self.assertEqual(host.executive.calls[0][1], 'clone')
37
38 def test_no_fetch_flag(self):
39 host = MockHost()
40 host.executive = MockExecutive2()
41 host.filesystem = MockFileSystem(files={
42 '/tmp/wpt': ''
43 })
44
45 LocalWPT(host, no_fetch=True)
46
47 self.assertEqual(len(host.executive.calls), 0)
48
49 def test_run(self):
50 host = MockHost()
51 host.executive = MockExecutive2()
52 host.filesystem = MockFileSystem()
53
54 local_wpt = LocalWPT(host)
55
56 local_wpt.run(['echo', 'rutabaga'])
57 self.assertEqual(len(host.executive.calls), 2)
58 self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga'])
59
60 def test_last_wpt_exported_commit(self):
61 host = MockHost()
62
63 messages = [
64 'Cr-Commit-Position: 123',
65 'Random message 2',
66 'Random message 1',
67 ]
68
69 shas = [
70 'ac12d9a15df23cf25cbfb904902dad2bd6dfdf6a',
71 'd06d731f466f056f9b98303609b7ecb21e71d395',
72 '00165ae67a970f17e38deee90a3df1a67c8deece',
73 '0acd8f62f12e8ddafea77d57f425e68cc11e16b0',
74 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
75 ]
76
77 def run_command_fn(args):
78 if args[1] == 'show':
79 return messages.pop()
80 elif args[1] == 'rev-list':
81 return '\n'.join(shas)
82
83 host.executive = MockExecutive2(run_command_fn=run_command_fn)
84 host.filesystem = MockFileSystem()
85
86 local_wpt = LocalWPT(host)
87
88 commit = local_wpt.most_recent_cr_commit()
89 self.assertEqual(commit, (shas[2], '123'))
90
91 def test_last_wpt_exported_commit_not_found(self):
92 host = MockHost()
93
94 messages = [
95 'Random message 3',
96 'Random message 2',
97 'Random message 1',
98 ]
99
100 def run_command_fn(args):
101 if args[1] == 'show':
102 return messages.pop()
103 elif args[1] == 'rev-list':
104 return '\n'.join([
105 'ac12d9a15df23cf25cbfb904902dad2bd6dfdf6a',
106 'd06d731f466f056f9b98303609b7ecb21e71d395',
107 '00165ae67a970f17e38deee90a3df1a67c8deece',
108 ])
109
110 host.executive = MockExecutive2(run_command_fn=run_command_fn)
111 host.filesystem = MockFileSystem()
112
113 local_wpt = LocalWPT(host)
114
115 commit = local_wpt.most_recent_cr_commit()
116 self.assertEqual(commit, (None, None))
117
118 def test_create_local_branch_with_patch(self):
119 host = MockHost()
120 host.executive = MockExecutive2()
121 host.filesystem = MockFileSystem()
122
123 local_wpt = LocalWPT(host)
124
125 local_wpt.create_branch_with_patch('branch-name', 'message', 'patch')
126 self.assertEqual(len(host.executive.calls), 9)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698