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

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

Issue 2620103002: [WPT Export] Add "github" remote repo in LocalWPT constructor if it doesn't exist. (Closed)
Patch Set: 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_fetches_if_wpt_exists(self): 15 def test_fetches_if_wpt_exists(self):
qyearsley 2017/01/10 20:42:46 Thought about naming: the purpose of the first thr
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 LocalWPT(host)
22 22
23 self.assertEqual(len(host.executive.calls), 2) 23 self.assertEqual(len(host.executive.calls), 4)
24 self.assertEqual(host.executive.calls[0][1], 'fetch') 24 self.assertEqual([cmd[1] for cmd in host.executive.calls],
25 self.assertEqual(host.executive.calls[1][1], 'checkout') 25 ['fetch', 'checkout', 'remote', 'remote'])
qyearsley 2017/01/10 20:42:46 Possible rephrasing: subcommands = [argv[1] for
jeffcarp 2017/01/10 22:11:58 Sure (to your last point). We do it elsewhere so I
26 26
27 def test_clones_if_wpt_does_not_exist(self): 27 def test_clones_if_wpt_does_not_exist(self):
28 host = MockHost() 28 host = MockHost()
29 host.filesystem = MockFileSystem() 29 host.filesystem = MockFileSystem()
30 30
31 LocalWPT(host) 31 LocalWPT(host)
32 32
33 self.assertEqual(len(host.executive.calls), 1) 33 self.assertEqual(len(host.executive.calls), 3)
34 self.assertEqual(host.executive.calls[0][1], 'clone') 34 self.assertEqual(host.executive.calls[0][1], 'clone')
35 35
36 def test_no_fetch_flag(self): 36 def test_no_fetch_flag(self):
37 host = MockHost() 37 host = MockHost()
38 host.filesystem = MockFileSystem(files={ 38 host.filesystem = MockFileSystem(files={
39 '/tmp/wpt': '' 39 '/tmp/wpt': ''
40 }) 40 })
41 41
42 LocalWPT(host, no_fetch=True) 42 LocalWPT(host, no_fetch=True)
43 43
44 self.assertEqual(len(host.executive.calls), 0) 44 self.assertEqual(len(host.executive.calls), 0)
45 45
46 def test_run(self): 46 def test_run(self):
47 host = MockHost() 47 host = MockHost()
48 host.filesystem = MockFileSystem() 48 host.filesystem = MockFileSystem()
49 49
50 local_wpt = LocalWPT(host) 50 local_wpt = LocalWPT(host)
51 51
52 local_wpt.run(['echo', 'rutabaga']) 52 local_wpt.run(['echo', 'rutabaga'])
53 self.assertEqual(len(host.executive.calls), 2) 53 self.assertEqual(len(host.executive.calls), 4)
54 self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga']) 54 self.assertEqual(host.executive.calls[3], ['echo', 'rutabaga'])
55 55
56 def test_last_wpt_exported_commit(self): 56 def test_last_wpt_exported_commit(self):
57 host = MockHost() 57 host = MockHost()
58 return_vals = [ 58 return_vals = [
59 'deadbeefcafe', 59 'deadbeefcafe',
60 '123', 60 '123',
61 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', 61 '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
62 ] 62 ]
63 host.executive = MockExecutive(run_command_fn=lambda _: return_vals.pop( )) 63 host.executive = MockExecutive(run_command_fn=lambda _: return_vals.pop( ))
64 host.filesystem = MockFileSystem() 64 host.filesystem = MockFileSystem()
65 local_wpt = LocalWPT(host, no_fetch=True) 65 local_wpt = LocalWPT(host, no_fetch=True)
66 66
67 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit() 67 wpt_sha, chromium_commit = local_wpt.most_recent_chromium_commit()
68 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8') 68 self.assertEqual(wpt_sha, '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8')
69 self.assertEqual(chromium_commit.position, '123') 69 self.assertEqual(chromium_commit.position, '123')
70 self.assertEqual(chromium_commit.sha, 'deadbeefcafe') 70 self.assertEqual(chromium_commit.sha, 'deadbeefcafe')
71 71
72 def test_last_wpt_exported_commit_not_found(self): 72 def test_last_wpt_exported_commit_not_found(self):
73 host = MockHost() 73 host = MockHost()
74 host.executive = MockExecutive(run_command_fn=lambda _: None) 74 host.executive = MockExecutive(run_command_fn=lambda _: '')
75 host.filesystem = MockFileSystem() 75 host.filesystem = MockFileSystem()
76 local_wpt = LocalWPT(host) 76 local_wpt = LocalWPT(host)
77 77
78 commit = local_wpt.most_recent_chromium_commit() 78 commit = local_wpt.most_recent_chromium_commit()
79 self.assertEqual(commit, (None, None)) 79 self.assertEqual(commit, (None, None))
80 80
81 def test_create_branch_with_patch(self): 81 def test_create_branch_with_patch(self):
82 host = MockHost() 82 host = MockHost()
83 host.filesystem = MockFileSystem() 83 host.filesystem = MockFileSystem()
84 84
85 local_wpt = LocalWPT(host) 85 local_wpt = LocalWPT(host)
86 86
87 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch ', 'author') 87 local_branch_name = local_wpt.create_branch_with_patch('message', 'patch ', 'author')
88 self.assertEqual(len(host.executive.calls), 10) 88 self.assertEqual(len(host.executive.calls), 12)
qyearsley 2017/01/10 20:42:46 Note, asserting the length is redundant if you ass
jeffcarp 2017/01/10 22:11:58 Good catch
89 self.assertEqual(local_branch_name, 'chromium-export-try') 89 self.assertEqual(local_branch_name, 'chromium-export-try')
90 self.assertEqual(host.executive.calls, [ 90 self.assertEqual(host.executive.calls, [
91 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'], 91 ['git', 'clone', 'https://chromium.googlesource.com/external/w3c/web -platform-tests.git', '/tmp/wpt'],
92 ['git', 'remote'],
93 ['git', 'remote', 'add', 'github', 'git@github.com:w3c/web-platform- tests.git'],
92 ['git', 'reset', '--hard', 'HEAD'], 94 ['git', 'reset', '--hard', 'HEAD'],
93 ['git', 'clean', '-fdx'], 95 ['git', 'clean', '-fdx'],
94 ['git', 'checkout', 'origin/master'], 96 ['git', 'checkout', 'origin/master'],
95 ['git', 'branch', '-a'], 97 ['git', 'branch', '-a'],
96 ['git', 'branch', '-a'], 98 ['git', 'branch', '-a'],
97 ['git', 'checkout', '-b', 'chromium-export-try'], 99 ['git', 'checkout', '-b', 'chromium-export-try'],
98 ['git', 'apply', '-'], 100 ['git', 'apply', '-'],
99 ['git', 'commit', '--author', 'author', '-am', 'message'], 101 ['git', 'commit', '--author', 'author', '-am', 'message'],
100 ['git', 'push', 'github', 'chromium-export-try']]) 102 ['git', 'push', 'github', 'chromium-export-try']])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698