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

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

Issue 2439153002: Script for exporting WPT (Closed)
Patch Set: Fix spacing issues 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 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..bd4f643731c81bece1bc2038926d9b9985da7217
--- /dev/null
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt_unittest.py
@@ -0,0 +1,86 @@
+# 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.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.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.filesystem = MockFileSystem(files={
+ '/tmp/wpt': ''
+ })
+
+ LocalWPT(host, no_fetch=True)
+
+ self.assertEqual(len(host.executive.calls), 0)
+
+ def test_run(self):
+ host = MockHost()
+ 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()
+ return_vals = [
+ '123',
+ '9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8',
+ ]
+ host.executive = MockExecutive2(run_command_fn=lambda _: return_vals.pop())
+ host.filesystem = MockFileSystem()
+ local_wpt = LocalWPT(host, no_fetch=True)
+
+ commit = local_wpt.most_recent_chromium_commit()
+ self.assertEqual(commit, ('9ea4fc353a4b1c11c6e524270b11baa4d1ddfde8', '123'))
+
+ def test_last_wpt_exported_commit_not_found(self):
+ host = MockHost()
+ host.executive = MockExecutive2(run_command_fn=lambda _: None)
+ host.filesystem = MockFileSystem()
+ local_wpt = LocalWPT(host)
+
+ commit = local_wpt.most_recent_chromium_commit()
+ self.assertEqual(commit, (None, None))
+
+ def test_create_branch_with_patch(self):
+ host = MockHost()
+ host.filesystem = MockFileSystem()
+
+ local_wpt = LocalWPT(host)
+
+ local_wpt.create_branch_with_patch('branch-name', 'message', 'patch')
+ self.assertEqual(len(host.executive.calls), 9)
+ # TODO(jeffcarp): Add more specific assertions
« no previous file with comments | « third_party/WebKit/Tools/Scripts/webkitpy/w3c/local_wpt.py ('k') | third_party/WebKit/Tools/Scripts/webkitpy/w3c/sync_wpt.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698