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

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

Issue 2627323008: Move WPT fetch out of the LocalWPT constructor. (Closed)
Patch Set: Move WPT fetch out of the LocalWPT constructor. Created 3 years, 11 months 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
1 # Copyright 2016 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import unittest 5 import unittest
6 6
7 from webkitpy.common.host_mock import MockHost 7 from webkitpy.common.host_mock import MockHost
8 from webkitpy.common.system.executive_mock import MockExecutive 8 from webkitpy.common.system.executive_mock import MockExecutive
9 from webkitpy.common.system.filesystem_mock import MockFileSystem 9 from webkitpy.common.system.filesystem_mock import MockFileSystem
10 from webkitpy.w3c.local_wpt import LocalWPT 10 from webkitpy.w3c.local_wpt import LocalWPT
11 11
12 12
13 class LocalWPTTest(unittest.TestCase): 13 class LocalWPTTest(unittest.TestCase):
14 14
15 def test_constructor_fetches_if_wpt_dir_exists(self): 15 def test_fetch_when_wpt_dir_exists(self):
16 host = MockHost() 16 host = MockHost()
17 host.filesystem = MockFileSystem(files={ 17 host.filesystem = MockFileSystem(files={
18 '/tmp/wpt': '' 18 '/tmp/wpt': ''
19 }) 19 })
20 20
21 LocalWPT(host) 21 local_wpt = LocalWPT(host)
22 local_wpt.fetch()
22 23
23 self.assertEqual(host.executive.calls, [ 24 self.assertEqual(host.executive.calls, [
24 ['git', 'fetch', '--all'], 25 ['git', 'fetch', '--all'],
25 ['git', 'checkout', 'origin/master'], 26 ['git', 'checkout', 'origin/master'],
26 ['git', 'remote'], 27 ['git', 'remote'],
27 ['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform- tests.git']]) 28 ['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform- tests.git']
29 ])
jeffcarp 2017/01/18 20:21:22 Is this the proper way to format? I'm always confu
qyearsley 2017/01/18 23:26:24 There are multiple proper ways. The main rules are
28 30
29 def test_constructor_clones_if_wpt_dir_does_not_exist(self): 31 def test_fetch_when_wpt_dir_does_not_exist(self):
30 host = MockHost() 32 host = MockHost()
31 host.filesystem = MockFileSystem() 33 host.filesystem = MockFileSystem()
32 34
33 LocalWPT(host) 35 local_wpt = LocalWPT(host)
36 local_wpt.fetch()
34 37
35 self.assertEqual(len(host.executive.calls), 3) 38 self.assertEqual(len(host.executive.calls), 3)
36 self.assertEqual(host.executive.calls[0][1], 'clone') 39 self.assertEqual(host.executive.calls[0][1], 'clone')
37 40
38 def test_constructor_no_fetch_flag(self): 41 def test_constructor(self):
42 #
jeffcarp 2017/01/18 20:21:23 Looks like this got left behind
qyearsley 2017/01/18 23:26:24 Oh! I didn't see this comment. Will have to clean
39 host = MockHost() 43 host = MockHost()
40 host.filesystem = MockFileSystem(files={ 44 LocalWPT(host)
41 '/tmp/wpt': ''
42 })
43
44 LocalWPT(host, no_fetch=True)
45
46 self.assertEqual(len(host.executive.calls), 0) 45 self.assertEqual(len(host.executive.calls), 0)
47 46
48 def test_run(self): 47 def test_run(self):
49 host = MockHost() 48 host = MockHost()
50 host.filesystem = MockFileSystem() 49 host.filesystem = MockFileSystem()
51
52 local_wpt = LocalWPT(host) 50 local_wpt = LocalWPT(host)
53
54 local_wpt.run(['echo', 'rutabaga']) 51 local_wpt.run(['echo', 'rutabaga'])
55 self.assertEqual(len(host.executive.calls), 4) 52 self.assertEqual(host.executive.calls, [['echo', 'rutabaga']])
56 self.assertEqual(host.executive.calls[3], ['echo', 'rutabaga'])
57 53
58 def test_last_wpt_exported_commit(self): 54 def test_last_wpt_exported_commit(self):
59 host = MockHost() 55 host = MockHost()
60 return_vals = [ 56 return_vals = [
61 'deadbeefcafe', 57 'deadbeefcafe',
62 '123', 58 '123',
63 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', 59 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
64 ] 60 ]
65 host.executive = MockExecutive(run_command_fn=lambda _: return_vals.pop( )) 61 host.executive = MockExecutive(run_command_fn=lambda _: return_vals.pop( ))
66 host.filesystem = MockFileSystem() 62 host.filesystem = MockFileSystem()
67 local_wpt = LocalWPT(host, no_fetch=True) 63 local_wpt = LocalWPT(host)
68 64
69 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit() 65 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit()
70 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8') 66 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8')
71 self.assertEqual(chromium_commit.position, '123') 67 self.assertEqual(chromium_commit.position, '123')
72 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') 68 self.assertEqual(chromium_commit.sha, 'deadbeefcafe')
73 69
74 def test_last_wpt_exported_commit_not_found(self): 70 def test_last_wpt_exported_commit_not_found(self):
75 host = MockHost() 71 host = MockHost()
76 host.executive = MockExecutive(run_command_fn=lambda _: '') 72 host.executive = MockExecutive(run_command_fn=lambda _: '')
77 host.filesystem = MockFileSystem() 73 host.filesystem = MockFileSystem()
78 local_wpt = LocalWPT(host) 74 local_wpt = LocalWPT(host)
79 75
80 commit = local_wpt.most_recent_chromium_commit() 76 commit = local_wpt.most_recent_chromium_commit()
81 self.assertEqual(commit, (None, None)) 77 self.assertEqual(commit, (None, None))
82 78
83 def test_create_branch_with_patch(self): 79 def test_create_branch_with_patch(self):
84 host = MockHost() 80 host = MockHost()
85 host.filesystem = MockFileSystem() 81 host.filesystem = MockFileSystem()
86 82
87 local_wpt = LocalWPT(host) 83 local_wpt = LocalWPT(host)
84 local_wpt.fetch()
88 85
89 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch ', 'author') 86 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch ', 'author')
90 self.assertEqual(local_branch_name, 'chromium-export-try') 87 self.assertEqual(local_branch_name, 'chromium-export-try')
91 self.assertEqual(host.executive.calls, [ 88 self.assertEqual(host.executive.calls, [
92 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'], 89 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'],
93 ['git', 'remote'], 90 ['git', 'remote'],
94 ['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform- tests.git'], 91 ['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform- tests.git'],
95 ['git', 'reset', '--hard', 'HEAD'], 92 ['git', 'reset', '--hard', 'HEAD'],
96 ['git', 'clean', '-fdx'], 93 ['git', 'clean', '-fdx'],
97 ['git', 'checkout', 'origin/master'], 94 ['git', 'checkout', 'origin/master'],
98 ['git', 'branch', '-a'], 95 ['git', 'branch', '-a'],
99 ['git', 'branch', '-a'], 96 ['git', 'branch', '-a'],
100 ['git', 'checkout', '-b', 'chromium-export-try'], 97 ['git', 'checkout', '-b', 'chromium-export-try'],
101 ['git', 'apply', '-'], 98 ['git', 'apply', '-'],
102 ['git', 'commit', '--author', 'author', '-am', 'message'], 99 ['git', 'commit', '--author', 'author', '-am', 'message'],
103 ['git', 'push', 'github', 'chromium-export-try']]) 100 ['git', 'push', 'github', 'chromium-export-try']])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698