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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..b88381f583e4176b31125d73e08a022f131fdb5b
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py
@@ -0,0 +1,126 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import unittest
+from webkitpy.w3c.local_wpt import LocalWPT
+from webkitpy.common.host_mock import MockHost
+from webkitpy.common.system.executive_mock import MockExecutive2
+from webkitpy.common.system.filesystem_mock import MockFileSystem
+
+
+class LocalWPTTest(unittest.TestCase):
+
+ def test_fetches_if_wpt_exists(self):
+ host = MockHost()
+ host.executive = MockExecutive2()
+ host.filesystem = MockFileSystem(files={
+ '/tmp/wpt': ''
+ })
+
+ LocalWPT(host)
+
+ self.assertEqual(len(host.executive.calls), 3)
+ self.assertEqual(host.executive.calls[0][1], 'checkout')
+ self.assertEqual(host.executive.calls[1][1], 'fetch')
+ self.assertEqual(host.executive.calls[2][1], 'merge')
+
+ def test_clones_if_wpt_does_not_exist(self):
+ host = MockHost()
+ host.executive = MockExecutive2()
+ host.filesystem = MockFileSystem()
+
+ LocalWPT(host)
+
+ self.assertEqual(len(host.executive.calls), 1)
+ self.assertEqual(host.executive.calls[0][1], 'clone')
+
+ def test_no_fetch_flag(self):
+ host = MockHost()
+ host.executive = MockExecutive2()
+ host.filesystem = MockFileSystem(files={
+ '/tmp/wpt': ''
+ })
+
+ LocalWPT(host, no_fetch=True)
+
+ self.assertEqual(len(host.executive.calls), 0)
+
+ def test_run(self):
+ host = MockHost()
+ host.executive = MockExecutive2()
+ host.filesystem = MockFileSystem()
+
+ local_wpt = LocalWPT(host)
+
+ local_wpt.run(['echo', 'rutabaga'])
+ self.assertEqual(len(host.executive.calls), 2)
+ self.assertEqual(host.executive.calls[1], ['echo', 'rutabaga'])
+
+ def test_last_wpt_exported_commit(self):
+ host = MockHost()
+
+ messages = [
+ 'Cr-Commit-Position: 123',
+ 'Random message 2',
+ 'Random message 1',
+ ]
+
+ shas = [
+ 'ac12d9a15df23cf25cbfb904902dad2bd6dfdf6a',
+ 'd06d731f466f056f9b98303609b7ecb21e71d395',
+ '00165ae67a970f17e38deee90a3df1a67c8deece',
+ '0acd8f62f12e8ddafea77d57f425e68cc11e16b0',
+ '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
+ ]
+
+ def run_command_fn(args):
+ if args[1] == 'show':
+ return messages.pop()
+ elif args[1] == 'rev-list':
+ return '\n'.join(shas)
+
+ host.executive = MockExecutive2(run_command_fn=run_command_fn)
+ host.filesystem = MockFileSystem()
+
+ local_wpt = LocalWPT(host)
+
+ commit = local_wpt.most_recent_cr_commit()
+ self.assertEqual(commit, (shas[2], '123'))
+
+ def test_last_wpt_exported_commit_not_found(self):
+ host = MockHost()
+
+ messages = [
+ 'Random message 3',
+ 'Random message 2',
+ 'Random message 1',
+ ]
+
+ def run_command_fn(args):
+ if args[1] == 'show':
+ return messages.pop()
+ elif args[1] == 'rev-list':
+ return '\n'.join([
+ 'ac12d9a15df23cf25cbfb904902dad2bd6dfdf6a',
+ 'd06d731f466f056f9b98303609b7ecb21e71d395',
+ '00165ae67a970f17e38deee90a3df1a67c8deece',
+ ])
+
+ host.executive = MockExecutive2(run_command_fn=run_command_fn)
+ host.filesystem = MockFileSystem()
+
+ local_wpt = LocalWPT(host)
+
+ commit = local_wpt.most_recent_cr_commit()
+ self.assertEqual(commit, (None, None))
+
+ def test_create_local_branch_with_patch(self):
+ host = MockHost()
+ host.executive = MockExecutive2()
+ host.filesystem = MockFileSystem()
+
+ local_wpt = LocalWPT(host)
+
+ local_wpt.create_branch_with_patch('branch-name', 'message', 'patch')
+ self.assertEqual(len(host.executive.calls), 9)

Powered by Google App Engine
This is Rietveld 408576698